1/* 2 * BK Id: %F% %I% %G% %U% %#% 3 */ 4/* 5 * linux/arch/ppc/kernel/signal.c 6 * 7 * PowerPC version 8 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) 9 * 10 * Derived from "arch/i386/kernel/signal.c" 11 * Copyright (C) 1991, 1992 Linus Torvalds 12 * 1997-11-28 Modified for POSIX.1b signals by Richard Henderson 13 * 14 * This program is free software; you can redistribute it and/or 15 * modify it under the terms of the GNU General Public License 16 * as published by the Free Software Foundation; either version 17 * 2 of the License, or (at your option) any later version. 18 */ 19 20#include <linux/sched.h> 21#include <linux/mm.h> 22#include <linux/smp.h> 23#include <linux/smp_lock.h> 24#include <linux/kernel.h> 25#include <linux/signal.h> 26#include <linux/errno.h> 27#include <linux/wait.h> 28#include <linux/ptrace.h> 29#include <linux/unistd.h> 30#include <linux/stddef.h> 31#include <linux/elf.h> 32#include <asm/ucontext.h> 33#include <asm/uaccess.h> 34#include <asm/pgtable.h> 35 36#define DEBUG_SIG 0 37 38#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) 39 40#ifndef MIN 41#define MIN(a,b) (((a) < (b)) ? (a) : (b)) 42#endif 43 44#define GP_REGS_SIZE MIN(sizeof(elf_gregset_t), sizeof(struct pt_regs)) 45 46/* 47 * These are the flags in the MSR that the user is allowed to change 48 * by modifying the saved value of the MSR on the stack. SE and BE 49 * should not be in this list since gdb may want to change these. I.e, 50 * you should be able to step out of a signal handler to see what 51 * instruction executes next after the signal handler completes. 52 * Alternately, if you stepped into a signal handler, you should be 53 * able to continue 'til the next breakpoint from within the signal 54 * handler, even if the handler returns. 55 */ 56#define MSR_USERCHANGE (MSR_FE0 | MSR_FE1) 57 58int do_signal(sigset_t *oldset, struct pt_regs *regs); 59 60int copy_siginfo_to_user(siginfo_t *to, siginfo_t *from) 61{ 62 if (!access_ok (VERIFY_WRITE, to, sizeof(siginfo_t))) 63 return -EFAULT; 64 if (from->si_code < 0) 65 return __copy_to_user(to, from, sizeof(siginfo_t)); 66 else { 67 int err; 68 69 /* If you change siginfo_t structure, please be sure 70 this code is fixed accordingly. 71 It should never copy any pad contained in the structure 72 to avoid security leaks, but must copy the generic 73 3 ints plus the relevant union member. */ 74 err = __put_user(from->si_signo, &to->si_signo); 75 err |= __put_user(from->si_errno, &to->si_errno); 76 err |= __put_user((short)from->si_code, &to->si_code); 77 /* First 32bits of unions are always present. */ 78 err |= __put_user(from->si_pid, &to->si_pid); 79 switch (from->si_code >> 16) { 80 case __SI_FAULT >> 16: 81 break; 82 case __SI_CHLD >> 16: 83 err |= __put_user(from->si_utime, &to->si_utime); 84 err |= __put_user(from->si_stime, &to->si_stime); 85 err |= __put_user(from->si_status, &to->si_status); 86 default: 87 err |= __put_user(from->si_uid, &to->si_uid); 88 break; 89 /* case __SI_RT: This is not generated by the kernel as of now. */ 90 } 91 return err; 92 } 93} 94 95/* 96 * Atomically swap in the new signal mask, and wait for a signal. 97 */ 98int 99sys_sigsuspend(old_sigset_t mask, int p2, int p3, int p4, int p6, int p7, 100 struct pt_regs *regs) 101{ 102 sigset_t saveset; 103 104 mask &= _BLOCKABLE; 105 spin_lock_irq(¤t->sigmask_lock); 106 saveset = current->blocked; 107 siginitset(¤t->blocked, mask); 108 recalc_sigpending(current); 109 spin_unlock_irq(¤t->sigmask_lock); 110 111 regs->result = -EINTR; 112 regs->gpr[3] = EINTR; 113 regs->ccr |= 0x10000000; 114 while (1) { 115 current->state = TASK_INTERRUPTIBLE; 116 schedule(); 117 if (do_signal(&saveset, regs)) 118 /* 119 * If a signal handler needs to be called, 120 * do_signal() has set R3 to the signal number (the 121 * first argument of the signal handler), so don't 122 * overwrite that with EINTR ! 123 * In the other cases, do_signal() doesn't touch 124 * R3, so it's still set to -EINTR (see above). 125 */ 126 return regs->gpr[3]; 127 } 128} 129 130int 131sys_rt_sigsuspend(sigset_t *unewset, size_t sigsetsize, int p3, int p4, int p6, 132 int p7, struct pt_regs *regs) 133{ 134 sigset_t saveset, newset; 135 136 if (sigsetsize != sizeof(sigset_t)) 137 return -EINVAL; 138 139 if (copy_from_user(&newset, unewset, sizeof(newset))) 140 return -EFAULT; 141 sigdelsetmask(&newset, ~_BLOCKABLE); 142 143 spin_lock_irq(¤t->sigmask_lock); 144 saveset = current->blocked; 145 current->blocked = newset; 146 recalc_sigpending(current); 147 spin_unlock_irq(¤t->sigmask_lock); 148 149 regs->result = -EINTR; 150 regs->gpr[3] = EINTR; 151 regs->ccr |= 0x10000000; 152 while (1) { 153 current->state = TASK_INTERRUPTIBLE; 154 schedule(); 155 if (do_signal(&saveset, regs)) 156 return regs->gpr[3]; 157 } 158} 159 160 161int 162sys_sigaltstack(const stack_t *uss, stack_t *uoss) 163{ 164 struct pt_regs *regs = (struct pt_regs *) &uss; 165 return do_sigaltstack(uss, uoss, regs->gpr[1]); 166} 167 168int 169sys_sigaction(int sig, const struct old_sigaction *act, 170 struct old_sigaction *oact) 171{ 172 struct k_sigaction new_ka, old_ka; 173 int ret; 174 175 if (act) { 176 old_sigset_t mask; 177 if (verify_area(VERIFY_READ, act, sizeof(*act)) || 178 __get_user(new_ka.sa.sa_handler, &act->sa_handler) || 179 __get_user(new_ka.sa.sa_restorer, &act->sa_restorer)) 180 return -EFAULT; 181 __get_user(new_ka.sa.sa_flags, &act->sa_flags); 182 __get_user(mask, &act->sa_mask); 183 siginitset(&new_ka.sa.sa_mask, mask); 184 } 185 186 ret = do_sigaction(sig, (act? &new_ka: NULL), (oact? &old_ka: NULL)); 187 188 if (!ret && oact) { 189 if (verify_area(VERIFY_WRITE, oact, sizeof(*oact)) || 190 __put_user(old_ka.sa.sa_handler, &oact->sa_handler) || 191 __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer)) 192 return -EFAULT; 193 __put_user(old_ka.sa.sa_flags, &oact->sa_flags); 194 __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask); 195 } 196 197 return ret; 198} 199 200/* 201 * When we have signals to deliver, we set up on the 202 * user stack, going down from the original stack pointer: 203 * a sigregs struct 204 * one or more sigcontext structs with 205 * a gap of __SIGNAL_FRAMESIZE bytes 206 * 207 * Each of these things must be a multiple of 16 bytes in size. 208 * 209 */ 210struct sigregs { 211 elf_gregset_t gp_regs; 212 double fp_regs[ELF_NFPREG]; 213 unsigned long tramp[2]; 214 /* Programs using the rs6000/xcoff abi can save up to 19 gp regs 215 and 18 fp regs below sp before decrementing it. */ 216 int abigap[56]; 217}; 218 219struct rt_sigframe 220{ 221 unsigned long _unused[2]; 222 struct siginfo *pinfo; 223 void *puc; 224 struct siginfo info; 225 struct ucontext uc; 226}; 227 228 229/* 230 * When we have rt signals to deliver, we set up on the 231 * user stack, going down from the original stack pointer: 232 * a sigregs struct 233 * one rt_sigframe struct (siginfo + ucontext) 234 * a gap of __SIGNAL_FRAMESIZE bytes 235 * 236 * Each of these things must be a multiple of 16 bytes in size. 237 * 238 */ 239int sys_rt_sigreturn(struct pt_regs *regs) 240{ 241 struct rt_sigframe *rt_sf; 242 struct sigcontext_struct sigctx; 243 struct sigregs *sr; 244 int ret; 245 elf_gregset_t saved_regs; /* an array of ELF_NGREG unsigned longs */ 246 sigset_t set; 247 stack_t st; 248 unsigned long prevsp; 249 250 rt_sf = (struct rt_sigframe *)(regs->gpr[1] + __SIGNAL_FRAMESIZE); 251 if (copy_from_user(&sigctx, &rt_sf->uc.uc_mcontext, sizeof(sigctx)) 252 || copy_from_user(&set, &rt_sf->uc.uc_sigmask, sizeof(set)) 253 || copy_from_user(&st, &rt_sf->uc.uc_stack, sizeof(st))) 254 goto badframe; 255 sigdelsetmask(&set, ~_BLOCKABLE); 256 spin_lock_irq(¤t->sigmask_lock); 257 current->blocked = set; 258 recalc_sigpending(current); 259 spin_unlock_irq(¤t->sigmask_lock); 260 if (regs->msr & MSR_FP) 261 giveup_fpu(current); 262 263 rt_sf++; /* Look at next rt_sigframe */ 264 if (rt_sf == (struct rt_sigframe *)(sigctx.regs)) { 265 /* Last stacked signal - restore registers - 266 * sigctx is initialized to point to the 267 * preamble frame (where registers are stored) 268 * see handle_signal() 269 */ 270 sr = (struct sigregs *) sigctx.regs; 271 if (copy_from_user(saved_regs, &sr->gp_regs, 272 sizeof(sr->gp_regs))) 273 goto badframe; 274 saved_regs[PT_MSR] = (regs->msr & ~MSR_USERCHANGE) 275 | (saved_regs[PT_MSR] & MSR_USERCHANGE); 276 memcpy(regs, saved_regs, GP_REGS_SIZE); 277 if (copy_from_user(current->thread.fpr, &sr->fp_regs, 278 sizeof(sr->fp_regs))) 279 goto badframe; 280 /* This function sets back the stack flags into 281 the current task structure. */ 282 sys_sigaltstack(&st, NULL); 283 284 ret = regs->result; 285 } else { 286 /* More signals to go */ 287 /* Set up registers for next signal handler */ 288 regs->gpr[1] = (unsigned long)rt_sf - __SIGNAL_FRAMESIZE; 289 if (copy_from_user(&sigctx, &rt_sf->uc.uc_mcontext, sizeof(sigctx))) 290 goto badframe; 291 sr = (struct sigregs *) sigctx.regs; 292 regs->gpr[3] = ret = sigctx.signal; 293 /* Get the siginfo */ 294 get_user(regs->gpr[4], (unsigned long *)&rt_sf->pinfo); 295 /* Get the ucontext */ 296 get_user(regs->gpr[5], (unsigned long *)&rt_sf->puc); 297 regs->gpr[6] = (unsigned long) rt_sf; 298 299 regs->link = (unsigned long) &sr->tramp; 300 regs->nip = sigctx.handler; 301 if (get_user(prevsp, &sr->gp_regs[PT_R1]) 302 || put_user(prevsp, (unsigned long *) regs->gpr[1])) 303 goto badframe; 304 current->thread.fpscr = 0; 305 } 306 return ret; 307 308badframe: 309 do_exit(SIGSEGV); 310} 311 312static void 313setup_rt_frame(struct pt_regs *regs, struct sigregs *frame, 314 signed long newsp) 315{ 316 struct rt_sigframe *rt_sf = (struct rt_sigframe *) newsp; 317 318 /* Set up preamble frame */ 319 if (verify_area(VERIFY_WRITE, frame, sizeof(*frame))) 320 goto badframe; 321 if (regs->msr & MSR_FP) 322 giveup_fpu(current); 323 if (__copy_to_user(&frame->gp_regs, regs, GP_REGS_SIZE) 324 || __copy_to_user(&frame->fp_regs, current->thread.fpr, 325 ELF_NFPREG * sizeof(double)) 326 /* Set up to return from user space. 327 It calls the sc exception at offset 0x9999 328 for sys_rt_sigreturn(). 329 */ 330 || __put_user(0x38006666UL, &frame->tramp[0]) /* li r0,0x6666 */ 331 || __put_user(0x44000002UL, &frame->tramp[1])) /* sc */ 332 goto badframe; 333 flush_icache_range((unsigned long) &frame->tramp[0], 334 (unsigned long) &frame->tramp[2]); 335 current->thread.fpscr = 0; /* turn off all fp exceptions */ 336 337 /* Retrieve rt_sigframe from stack and 338 set up registers for signal handler 339 */ 340 newsp -= __SIGNAL_FRAMESIZE; 341 if (put_user(regs->gpr[1], (unsigned long *)newsp) 342 || get_user(regs->nip, &rt_sf->uc.uc_mcontext.handler) 343 || get_user(regs->gpr[3], &rt_sf->uc.uc_mcontext.signal) 344 || get_user(regs->gpr[4], (unsigned long *)&rt_sf->pinfo) 345 || get_user(regs->gpr[5], (unsigned long *)&rt_sf->puc)) 346 goto badframe; 347 348 regs->gpr[1] = newsp; 349 regs->gpr[6] = (unsigned long) rt_sf; 350 regs->link = (unsigned long) frame->tramp; 351 352 return; 353 354badframe: 355#if DEBUG_SIG 356 printk("badframe in setup_rt_frame, regs=%p frame=%p newsp=%lx\n", 357 regs, frame, newsp); 358#endif 359 do_exit(SIGSEGV); 360} 361 362/* 363 * Do a signal return; undo the signal stack. 364 */ 365int sys_sigreturn(struct pt_regs *regs) 366{ 367 struct sigcontext_struct *sc, sigctx; 368 struct sigregs *sr; 369 int ret; 370 elf_gregset_t saved_regs; /* an array of ELF_NGREG unsigned longs */ 371 sigset_t set; 372 unsigned long prevsp; 373 374 sc = (struct sigcontext_struct *)(regs->gpr[1] + __SIGNAL_FRAMESIZE); 375 if (copy_from_user(&sigctx, sc, sizeof(sigctx))) 376 goto badframe; 377 378 set.sig[0] = sigctx.oldmask; 379#if _NSIG_WORDS > 1 380 set.sig[1] = sigctx._unused[3]; 381#endif 382 sigdelsetmask(&set, ~_BLOCKABLE); 383 spin_lock_irq(¤t->sigmask_lock); 384 current->blocked = set; 385 recalc_sigpending(current); 386 spin_unlock_irq(¤t->sigmask_lock); 387 if (regs->msr & MSR_FP ) 388 giveup_fpu(current); 389 390 sc++; /* Look at next sigcontext */ 391 if (sc == (struct sigcontext_struct *)(sigctx.regs)) { 392 /* Last stacked signal - restore registers */ 393 sr = (struct sigregs *) sigctx.regs; 394 if (copy_from_user(saved_regs, &sr->gp_regs, 395 sizeof(sr->gp_regs))) 396 goto badframe; 397 saved_regs[PT_MSR] = (regs->msr & ~MSR_USERCHANGE) 398 | (saved_regs[PT_MSR] & MSR_USERCHANGE); 399 memcpy(regs, saved_regs, GP_REGS_SIZE); 400 401 if (copy_from_user(current->thread.fpr, &sr->fp_regs, 402 sizeof(sr->fp_regs))) 403 goto badframe; 404 405 ret = regs->result; 406 407 } else { 408 /* More signals to go */ 409 regs->gpr[1] = (unsigned long)sc - __SIGNAL_FRAMESIZE; 410 if (copy_from_user(&sigctx, sc, sizeof(sigctx))) 411 goto badframe; 412 sr = (struct sigregs *) sigctx.regs; 413 regs->gpr[3] = ret = sigctx.signal; 414 regs->gpr[4] = (unsigned long) sc; 415 regs->link = (unsigned long) &sr->tramp; 416 regs->nip = sigctx.handler; 417 418 if (get_user(prevsp, &sr->gp_regs[PT_R1]) 419 || put_user(prevsp, (unsigned long *) regs->gpr[1])) 420 goto badframe; 421 current->thread.fpscr = 0; 422 } 423 return ret; 424 425badframe: 426 do_exit(SIGSEGV); 427} 428 429/* 430 * Set up a signal frame. 431 */ 432static void 433setup_frame(struct pt_regs *regs, struct sigregs *frame, 434 unsigned long newsp) 435{ 436 struct sigcontext_struct *sc = (struct sigcontext_struct *) newsp; 437 438 if (verify_area(VERIFY_WRITE, frame, sizeof(*frame))) 439 goto badframe; 440 if (regs->msr & MSR_FP) 441 giveup_fpu(current); 442 if (__copy_to_user(&frame->gp_regs, regs, GP_REGS_SIZE) 443 || __copy_to_user(&frame->fp_regs, current->thread.fpr, 444 ELF_NFPREG * sizeof(double)) 445 || __put_user(0x38007777UL, &frame->tramp[0]) /* li r0,0x7777 */ 446 || __put_user(0x44000002UL, &frame->tramp[1])) /* sc */ 447 goto badframe; 448 flush_icache_range((unsigned long) &frame->tramp[0], 449 (unsigned long) &frame->tramp[2]); 450 current->thread.fpscr = 0; /* turn off all fp exceptions */ 451 452 newsp -= __SIGNAL_FRAMESIZE; 453 if (put_user(regs->gpr[1], (unsigned long *)newsp) 454 || get_user(regs->nip, &sc->handler) 455 || get_user(regs->gpr[3], &sc->signal)) 456 goto badframe; 457 regs->gpr[1] = newsp; 458 regs->gpr[4] = (unsigned long) sc; 459 regs->link = (unsigned long) frame->tramp; 460 461 return; 462 463badframe: 464#if DEBUG_SIG 465 printk("badframe in setup_frame, regs=%p frame=%p newsp=%lx\n", 466 regs, frame, newsp); 467#endif 468 do_exit(SIGSEGV); 469} 470 471/* 472 * OK, we're invoking a handler 473 */ 474static void 475handle_signal(unsigned long sig, struct k_sigaction *ka, 476 siginfo_t *info, sigset_t *oldset, struct pt_regs * regs, 477 unsigned long *newspp, unsigned long frame) 478{ 479 struct sigcontext_struct *sc; 480 struct rt_sigframe *rt_sf; 481 482 if (regs->trap == 0x0C00 /* System Call! */ 483 && ((int)regs->result == -ERESTARTNOHAND || 484 ((int)regs->result == -ERESTARTSYS && 485 !(ka->sa.sa_flags & SA_RESTART)))) 486 regs->result = -EINTR; 487 488 /* Set up Signal Frame */ 489 if (ka->sa.sa_flags & SA_SIGINFO) { 490 /* Put a Real Time Context onto stack */ 491 *newspp -= sizeof(*rt_sf); 492 rt_sf = (struct rt_sigframe *) *newspp; 493 if (verify_area(VERIFY_WRITE, rt_sf, sizeof(*rt_sf))) 494 goto badframe; 495 496 if (__put_user((unsigned long) ka->sa.sa_handler, &rt_sf->uc.uc_mcontext.handler) 497 || __put_user(&rt_sf->info, &rt_sf->pinfo) 498 || __put_user(&rt_sf->uc, &rt_sf->puc) 499 /* Put the siginfo */ 500 || __copy_to_user(&rt_sf->info, info, sizeof(*info)) 501 /* Create the ucontext */ 502 || __put_user(0, &rt_sf->uc.uc_flags) 503 || __put_user(0, &rt_sf->uc.uc_link) 504 || __put_user(current->sas_ss_sp, &rt_sf->uc.uc_stack.ss_sp) 505 || __put_user(sas_ss_flags(regs->gpr[1]), 506 &rt_sf->uc.uc_stack.ss_flags) 507 || __put_user(current->sas_ss_size, &rt_sf->uc.uc_stack.ss_size) 508 || __copy_to_user(&rt_sf->uc.uc_sigmask, oldset, sizeof(*oldset)) 509 /* mcontext.regs points to preamble register frame */ 510 || __put_user((struct pt_regs *)frame, &rt_sf->uc.uc_mcontext.regs) 511 || __put_user(sig, &rt_sf->uc.uc_mcontext.signal)) 512 goto badframe; 513 } else { 514 /* Put another sigcontext on the stack */ 515 *newspp -= sizeof(*sc); 516 sc = (struct sigcontext_struct *) *newspp; 517 if (verify_area(VERIFY_WRITE, sc, sizeof(*sc))) 518 goto badframe; 519 520 if (__put_user((unsigned long) ka->sa.sa_handler, &sc->handler) 521 || __put_user(oldset->sig[0], &sc->oldmask) 522#if _NSIG_WORDS > 1 523 || __put_user(oldset->sig[1], &sc->_unused[3]) 524#endif 525 || __put_user((struct pt_regs *)frame, &sc->regs) 526 || __put_user(sig, &sc->signal)) 527 goto badframe; 528 } 529 530 if (ka->sa.sa_flags & SA_ONESHOT) 531 ka->sa.sa_handler = SIG_DFL; 532 533 if (!(ka->sa.sa_flags & SA_NODEFER)) { 534 spin_lock_irq(¤t->sigmask_lock); 535 sigorsets(¤t->blocked,¤t->blocked,&ka->sa.sa_mask); 536 sigaddset(¤t->blocked,sig); 537 recalc_sigpending(current); 538 spin_unlock_irq(¤t->sigmask_lock); 539 } 540 return; 541 542badframe: 543#if DEBUG_SIG 544 printk("badframe in handle_signal, regs=%p frame=%lx newsp=%lx\n", 545 regs, frame, *newspp); 546 printk("sc=%p sig=%d ka=%p info=%p oldset=%p\n", sc, sig, ka, info, oldset); 547#endif 548 do_exit(SIGSEGV); 549} 550 551/* 552 * Note that 'init' is a special process: it doesn't get signals it doesn't 553 * want to handle. Thus you cannot kill init even with a SIGKILL even by 554 * mistake. 555 */ 556int do_signal(sigset_t *oldset, struct pt_regs *regs) 557{ 558 siginfo_t info; 559 struct k_sigaction *ka; 560 unsigned long frame, newsp; 561 562 if (!oldset) 563 oldset = ¤t->blocked; 564 565 newsp = frame = 0; 566 567 for (;;) { 568 unsigned long signr; 569 570 spin_lock_irq(¤t->sigmask_lock); 571 signr = dequeue_signal(¤t->blocked, &info); 572 spin_unlock_irq(¤t->sigmask_lock); 573 574 if (!signr) 575 break; 576 577 if ((current->ptrace & PT_PTRACED) && signr != SIGKILL) { 578 /* Let the debugger run. */ 579 current->exit_code = signr; 580 current->state = TASK_STOPPED; 581 notify_parent(current, SIGCHLD); 582 schedule(); 583 584 /* We're back. Did the debugger cancel the sig? */ 585 if (!(signr = current->exit_code)) 586 continue; 587 current->exit_code = 0; 588 589 /* The debugger continued. Ignore SIGSTOP. */ 590 if (signr == SIGSTOP) 591 continue; 592 593 /* Update the siginfo structure. Is this good? */ 594 if (signr != info.si_signo) { 595 info.si_signo = signr; 596 info.si_errno = 0; 597 info.si_code = SI_USER; 598 info.si_pid = current->p_pptr->pid; 599 info.si_uid = current->p_pptr->uid; 600 } 601 602 /* If the (new) signal is now blocked, requeue it. */ 603 if (sigismember(¤t->blocked, signr)) { 604 send_sig_info(signr, &info, current); 605 continue; 606 } 607 } 608 609 ka = ¤t->sig->action[signr-1]; 610 if (ka->sa.sa_handler == SIG_IGN) { 611 if (signr != SIGCHLD) 612 continue; 613 /* Check for SIGCHLD: it's special. */ 614 while (sys_wait4(-1, NULL, WNOHANG, NULL) > 0) 615 /* nothing */; 616 continue; 617 } 618 619 if (ka->sa.sa_handler == SIG_DFL) { 620 int exit_code = signr; 621 622 /* Init gets no signals it doesn't want. */ 623 if (current->pid == 1) 624 continue; 625 626 switch (signr) { 627 case SIGCONT: case SIGCHLD: case SIGWINCH: case SIGURG: 628 continue; 629 630 case SIGTSTP: case SIGTTIN: case SIGTTOU: 631 if (is_orphaned_pgrp(current->pgrp)) 632 continue; 633 /* FALLTHRU */ 634 635 case SIGSTOP: 636 current->state = TASK_STOPPED; 637 current->exit_code = signr; 638 if (!(current->p_pptr->sig->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDSTOP)) 639 notify_parent(current, SIGCHLD); 640 schedule(); 641 continue; 642 643 case SIGQUIT: case SIGILL: case SIGTRAP: 644 case SIGABRT: case SIGFPE: case SIGSEGV: 645 case SIGBUS: case SIGSYS: case SIGXCPU: case SIGXFSZ: 646 if (do_coredump(signr, regs)) 647 exit_code |= 0x80; 648 /* FALLTHRU */ 649 650 default: 651 sig_exit(signr, exit_code, &info); 652 /* NOTREACHED */ 653 } 654 } 655 656 if ( (ka->sa.sa_flags & SA_ONSTACK) 657 && (! on_sig_stack(regs->gpr[1]))) 658 newsp = (current->sas_ss_sp + current->sas_ss_size); 659 else 660 newsp = regs->gpr[1]; 661 newsp = frame = newsp - sizeof(struct sigregs); 662 663 /* Whee! Actually deliver the signal. */ 664 handle_signal(signr, ka, &info, oldset, regs, &newsp, frame); 665 break; 666 } 667 668 if (regs->trap == 0x0C00 /* System Call! */ && 669 ((int)regs->result == -ERESTARTNOHAND || 670 (int)regs->result == -ERESTARTSYS || 671 (int)regs->result == -ERESTARTNOINTR)) { 672 regs->gpr[3] = regs->orig_gpr3; 673 regs->nip -= 4; /* Back up & retry system call */ 674 regs->result = 0; 675 } 676 677 if (newsp == frame) 678 return 0; /* no signals delivered */ 679 680 if (ka->sa.sa_flags & SA_SIGINFO) 681 setup_rt_frame(regs, (struct sigregs *) frame, newsp); 682 else 683 setup_frame(regs, (struct sigregs *) frame, newsp); 684 return 1; 685} 686 687