diff options
author | Richard Henderson <rth@twiddle.net> | 2007-05-29 19:03:28 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-30 13:07:54 -0400 |
commit | b927b3e2c9bc39b7eeeaca91e4cd6c3ed59f165a (patch) | |
tree | abdb72c2f2b8ab6cfaa954b558e8c078d04d1a85 /arch/alpha/kernel/signal.c | |
parent | 74fd1b687fbeba566ceb59cc1fdbc7a64c5e0c0b (diff) |
alpha: support new syscalls
Some of the new syscalls require supporting TIF_RESTORE_SIGMASK.
Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/alpha/kernel/signal.c')
-rw-r--r-- | arch/alpha/kernel/signal.c | 110 |
1 files changed, 63 insertions, 47 deletions
diff --git a/arch/alpha/kernel/signal.c b/arch/alpha/kernel/signal.c index 7f64aa767d5a..410af4f3140e 100644 --- a/arch/alpha/kernel/signal.c +++ b/arch/alpha/kernel/signal.c | |||
@@ -32,8 +32,8 @@ | |||
32 | #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) | 32 | #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) |
33 | 33 | ||
34 | asmlinkage void ret_from_sys_call(void); | 34 | asmlinkage void ret_from_sys_call(void); |
35 | static int do_signal(sigset_t *, struct pt_regs *, struct switch_stack *, | 35 | static void do_signal(struct pt_regs *, struct switch_stack *, |
36 | unsigned long, unsigned long); | 36 | unsigned long, unsigned long); |
37 | 37 | ||
38 | 38 | ||
39 | /* | 39 | /* |
@@ -146,11 +146,9 @@ sys_rt_sigaction(int sig, const struct sigaction __user *act, | |||
146 | asmlinkage int | 146 | asmlinkage int |
147 | do_sigsuspend(old_sigset_t mask, struct pt_regs *regs, struct switch_stack *sw) | 147 | do_sigsuspend(old_sigset_t mask, struct pt_regs *regs, struct switch_stack *sw) |
148 | { | 148 | { |
149 | sigset_t oldset; | ||
150 | |||
151 | mask &= _BLOCKABLE; | 149 | mask &= _BLOCKABLE; |
152 | spin_lock_irq(¤t->sighand->siglock); | 150 | spin_lock_irq(¤t->sighand->siglock); |
153 | oldset = current->blocked; | 151 | current->saved_sigmask = current->blocked; |
154 | siginitset(¤t->blocked, mask); | 152 | siginitset(¤t->blocked, mask); |
155 | recalc_sigpending(); | 153 | recalc_sigpending(); |
156 | spin_unlock_irq(¤t->sighand->siglock); | 154 | spin_unlock_irq(¤t->sighand->siglock); |
@@ -160,19 +158,17 @@ do_sigsuspend(old_sigset_t mask, struct pt_regs *regs, struct switch_stack *sw) | |||
160 | regs->r0 = EINTR; | 158 | regs->r0 = EINTR; |
161 | regs->r19 = 1; | 159 | regs->r19 = 1; |
162 | 160 | ||
163 | while (1) { | 161 | current->state = TASK_INTERRUPTIBLE; |
164 | current->state = TASK_INTERRUPTIBLE; | 162 | schedule(); |
165 | schedule(); | 163 | set_thread_flag(TIF_RESTORE_SIGMASK); |
166 | if (do_signal(&oldset, regs, sw, 0, 0)) | 164 | return -ERESTARTNOHAND; |
167 | return -EINTR; | ||
168 | } | ||
169 | } | 165 | } |
170 | 166 | ||
171 | asmlinkage int | 167 | asmlinkage int |
172 | do_rt_sigsuspend(sigset_t __user *uset, size_t sigsetsize, | 168 | do_rt_sigsuspend(sigset_t __user *uset, size_t sigsetsize, |
173 | struct pt_regs *regs, struct switch_stack *sw) | 169 | struct pt_regs *regs, struct switch_stack *sw) |
174 | { | 170 | { |
175 | sigset_t oldset, set; | 171 | sigset_t set; |
176 | 172 | ||
177 | /* XXX: Don't preclude handling different sized sigset_t's. */ | 173 | /* XXX: Don't preclude handling different sized sigset_t's. */ |
178 | if (sigsetsize != sizeof(sigset_t)) | 174 | if (sigsetsize != sizeof(sigset_t)) |
@@ -182,7 +178,7 @@ do_rt_sigsuspend(sigset_t __user *uset, size_t sigsetsize, | |||
182 | 178 | ||
183 | sigdelsetmask(&set, ~_BLOCKABLE); | 179 | sigdelsetmask(&set, ~_BLOCKABLE); |
184 | spin_lock_irq(¤t->sighand->siglock); | 180 | spin_lock_irq(¤t->sighand->siglock); |
185 | oldset = current->blocked; | 181 | current->saved_sigmask = current->blocked; |
186 | current->blocked = set; | 182 | current->blocked = set; |
187 | recalc_sigpending(); | 183 | recalc_sigpending(); |
188 | spin_unlock_irq(¤t->sighand->siglock); | 184 | spin_unlock_irq(¤t->sighand->siglock); |
@@ -192,12 +188,10 @@ do_rt_sigsuspend(sigset_t __user *uset, size_t sigsetsize, | |||
192 | regs->r0 = EINTR; | 188 | regs->r0 = EINTR; |
193 | regs->r19 = 1; | 189 | regs->r19 = 1; |
194 | 190 | ||
195 | while (1) { | 191 | current->state = TASK_INTERRUPTIBLE; |
196 | current->state = TASK_INTERRUPTIBLE; | 192 | schedule(); |
197 | schedule(); | 193 | set_thread_flag(TIF_RESTORE_SIGMASK); |
198 | if (do_signal(&oldset, regs, sw, 0, 0)) | 194 | return -ERESTARTNOHAND; |
199 | return -EINTR; | ||
200 | } | ||
201 | } | 195 | } |
202 | 196 | ||
203 | asmlinkage int | 197 | asmlinkage int |
@@ -436,7 +430,7 @@ setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs, | |||
436 | return err; | 430 | return err; |
437 | } | 431 | } |
438 | 432 | ||
439 | static void | 433 | static int |
440 | setup_frame(int sig, struct k_sigaction *ka, sigset_t *set, | 434 | setup_frame(int sig, struct k_sigaction *ka, sigset_t *set, |
441 | struct pt_regs *regs, struct switch_stack * sw) | 435 | struct pt_regs *regs, struct switch_stack * sw) |
442 | { | 436 | { |
@@ -481,13 +475,14 @@ setup_frame(int sig, struct k_sigaction *ka, sigset_t *set, | |||
481 | current->comm, current->pid, frame, regs->pc, regs->r26); | 475 | current->comm, current->pid, frame, regs->pc, regs->r26); |
482 | #endif | 476 | #endif |
483 | 477 | ||
484 | return; | 478 | return 0; |
485 | 479 | ||
486 | give_sigsegv: | 480 | give_sigsegv: |
487 | force_sigsegv(sig, current); | 481 | force_sigsegv(sig, current); |
482 | return -EFAULT; | ||
488 | } | 483 | } |
489 | 484 | ||
490 | static void | 485 | static int |
491 | setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | 486 | setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, |
492 | sigset_t *set, struct pt_regs *regs, struct switch_stack * sw) | 487 | sigset_t *set, struct pt_regs *regs, struct switch_stack * sw) |
493 | { | 488 | { |
@@ -543,34 +538,38 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
543 | current->comm, current->pid, frame, regs->pc, regs->r26); | 538 | current->comm, current->pid, frame, regs->pc, regs->r26); |
544 | #endif | 539 | #endif |
545 | 540 | ||
546 | return; | 541 | return 0; |
547 | 542 | ||
548 | give_sigsegv: | 543 | give_sigsegv: |
549 | force_sigsegv(sig, current); | 544 | force_sigsegv(sig, current); |
545 | return -EFAULT; | ||
550 | } | 546 | } |
551 | 547 | ||
552 | 548 | ||
553 | /* | 549 | /* |
554 | * OK, we're invoking a handler. | 550 | * OK, we're invoking a handler. |
555 | */ | 551 | */ |
556 | static inline void | 552 | static inline int |
557 | handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info, | 553 | handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info, |
558 | sigset_t *oldset, struct pt_regs * regs, struct switch_stack *sw) | 554 | sigset_t *oldset, struct pt_regs * regs, struct switch_stack *sw) |
559 | { | 555 | { |
556 | int ret; | ||
557 | |||
560 | if (ka->sa.sa_flags & SA_SIGINFO) | 558 | if (ka->sa.sa_flags & SA_SIGINFO) |
561 | setup_rt_frame(sig, ka, info, oldset, regs, sw); | 559 | ret = setup_rt_frame(sig, ka, info, oldset, regs, sw); |
562 | else | 560 | else |
563 | setup_frame(sig, ka, oldset, regs, sw); | 561 | ret = setup_frame(sig, ka, oldset, regs, sw); |
564 | 562 | ||
565 | if (ka->sa.sa_flags & SA_RESETHAND) | 563 | if (ret == 0) { |
566 | ka->sa.sa_handler = SIG_DFL; | 564 | spin_lock_irq(¤t->sighand->siglock); |
565 | sigorsets(¤t->blocked,¤t->blocked,&ka->sa.sa_mask); | ||
566 | if (!(ka->sa.sa_flags & SA_NODEFER)) | ||
567 | sigaddset(¤t->blocked,sig); | ||
568 | recalc_sigpending(); | ||
569 | spin_unlock_irq(¤t->sighand->siglock); | ||
570 | } | ||
567 | 571 | ||
568 | spin_lock_irq(¤t->sighand->siglock); | 572 | return ret; |
569 | sigorsets(¤t->blocked,¤t->blocked,&ka->sa.sa_mask); | ||
570 | if (!(ka->sa.sa_flags & SA_NODEFER)) | ||
571 | sigaddset(¤t->blocked,sig); | ||
572 | recalc_sigpending(); | ||
573 | spin_unlock_irq(¤t->sighand->siglock); | ||
574 | } | 573 | } |
575 | 574 | ||
576 | static inline void | 575 | static inline void |
@@ -611,30 +610,42 @@ syscall_restart(unsigned long r0, unsigned long r19, | |||
611 | * restart. "r0" is also used as an indicator whether we can restart at | 610 | * restart. "r0" is also used as an indicator whether we can restart at |
612 | * all (if we get here from anything but a syscall return, it will be 0) | 611 | * all (if we get here from anything but a syscall return, it will be 0) |
613 | */ | 612 | */ |
614 | static int | 613 | static void |
615 | do_signal(sigset_t *oldset, struct pt_regs * regs, struct switch_stack * sw, | 614 | do_signal(struct pt_regs * regs, struct switch_stack * sw, |
616 | unsigned long r0, unsigned long r19) | 615 | unsigned long r0, unsigned long r19) |
617 | { | 616 | { |
618 | siginfo_t info; | 617 | siginfo_t info; |
619 | int signr; | 618 | int signr; |
620 | unsigned long single_stepping = ptrace_cancel_bpt(current); | 619 | unsigned long single_stepping = ptrace_cancel_bpt(current); |
621 | struct k_sigaction ka; | 620 | struct k_sigaction ka; |
621 | sigset_t *oldset; | ||
622 | 622 | ||
623 | if (!oldset) | 623 | if (test_thread_flag(TIF_RESTORE_SIGMASK)) |
624 | oldset = ¤t->saved_sigmask; | ||
625 | else | ||
624 | oldset = ¤t->blocked; | 626 | oldset = ¤t->blocked; |
625 | 627 | ||
626 | /* This lets the debugger run, ... */ | 628 | /* This lets the debugger run, ... */ |
627 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); | 629 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); |
630 | |||
628 | /* ... so re-check the single stepping. */ | 631 | /* ... so re-check the single stepping. */ |
629 | single_stepping |= ptrace_cancel_bpt(current); | 632 | single_stepping |= ptrace_cancel_bpt(current); |
630 | 633 | ||
631 | if (signr > 0) { | 634 | if (signr > 0) { |
632 | /* Whee! Actually deliver the signal. */ | 635 | /* Whee! Actually deliver the signal. */ |
633 | if (r0) syscall_restart(r0, r19, regs, &ka); | 636 | if (r0) |
634 | handle_signal(signr, &ka, &info, oldset, regs, sw); | 637 | syscall_restart(r0, r19, regs, &ka); |
638 | if (handle_signal(signr, &ka, &info, oldset, regs, sw) == 0) { | ||
639 | /* A signal was successfully delivered, and the | ||
640 | saved sigmask was stored on the signal frame, | ||
641 | and will be restored by sigreturn. So we can | ||
642 | simply clear the restore sigmask flag. */ | ||
643 | if (test_thread_flag(TIF_RESTORE_SIGMASK)) | ||
644 | clear_thread_flag(TIF_RESTORE_SIGMASK); | ||
645 | } | ||
635 | if (single_stepping) | 646 | if (single_stepping) |
636 | ptrace_set_bpt(current); /* re-set bpt */ | 647 | ptrace_set_bpt(current); /* re-set bpt */ |
637 | return 1; | 648 | return; |
638 | } | 649 | } |
639 | 650 | ||
640 | if (r0) { | 651 | if (r0) { |
@@ -654,17 +665,22 @@ do_signal(sigset_t *oldset, struct pt_regs * regs, struct switch_stack * sw, | |||
654 | break; | 665 | break; |
655 | } | 666 | } |
656 | } | 667 | } |
668 | |||
669 | /* If there's no signal to deliver, we just restore the saved mask. */ | ||
670 | if (test_thread_flag(TIF_RESTORE_SIGMASK)) { | ||
671 | clear_thread_flag(TIF_RESTORE_SIGMASK); | ||
672 | sigprocmask(SIG_SETMASK, ¤t->saved_sigmask, NULL); | ||
673 | } | ||
674 | |||
657 | if (single_stepping) | 675 | if (single_stepping) |
658 | ptrace_set_bpt(current); /* re-set breakpoint */ | 676 | ptrace_set_bpt(current); /* re-set breakpoint */ |
659 | |||
660 | return 0; | ||
661 | } | 677 | } |
662 | 678 | ||
663 | void | 679 | void |
664 | do_notify_resume(sigset_t *oldset, struct pt_regs *regs, | 680 | do_notify_resume(struct pt_regs *regs, struct switch_stack *sw, |
665 | struct switch_stack *sw, unsigned long r0, | 681 | unsigned long thread_info_flags, |
666 | unsigned long r19, unsigned long thread_info_flags) | 682 | unsigned long r0, unsigned long r19) |
667 | { | 683 | { |
668 | if (thread_info_flags & _TIF_SIGPENDING) | 684 | if (thread_info_flags & (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK)) |
669 | do_signal(oldset, regs, sw, r0, r19); | 685 | do_signal(regs, sw, r0, r19); |
670 | } | 686 | } |