diff options
-rw-r--r-- | arch/mips/kernel/process.c | 4 | ||||
-rw-r--r-- | arch/mips/kernel/signal.c | 86 | ||||
-rw-r--r-- | arch/mips/kernel/signal32.c | 8 | ||||
-rw-r--r-- | arch/mips/kernel/signal_n32.c | 4 | ||||
-rw-r--r-- | include/asm-mips/abi.h | 4 | ||||
-rw-r--r-- | include/asm-mips/thread_info.h | 2 |
6 files changed, 62 insertions, 46 deletions
diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c index fa98f10d0132..02adc7384153 100644 --- a/arch/mips/kernel/process.c +++ b/arch/mips/kernel/process.c | |||
@@ -58,8 +58,8 @@ ATTRIB_NORET void cpu_idle(void) | |||
58 | } | 58 | } |
59 | } | 59 | } |
60 | 60 | ||
61 | extern int do_signal(sigset_t *oldset, struct pt_regs *regs); | 61 | extern int do_signal(struct pt_regs *regs); |
62 | extern int do_signal32(sigset_t *oldset, struct pt_regs *regs); | 62 | extern int do_signal32(struct pt_regs *regs); |
63 | 63 | ||
64 | /* | 64 | /* |
65 | * Native o32 and N64 ABI without DSP ASE | 65 | * Native o32 and N64 ABI without DSP ASE |
diff --git a/arch/mips/kernel/signal.c b/arch/mips/kernel/signal.c index aaec4785e9a6..86a14d7b8534 100644 --- a/arch/mips/kernel/signal.c +++ b/arch/mips/kernel/signal.c | |||
@@ -39,8 +39,6 @@ | |||
39 | 39 | ||
40 | #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) | 40 | #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) |
41 | 41 | ||
42 | int do_signal(sigset_t *oldset, struct pt_regs *regs); | ||
43 | |||
44 | /* | 42 | /* |
45 | * Atomically swap in the new signal mask, and wait for a signal. | 43 | * Atomically swap in the new signal mask, and wait for a signal. |
46 | */ | 44 | */ |
@@ -50,7 +48,7 @@ save_static_function(sys_sigsuspend); | |||
50 | __attribute_used__ noinline static int | 48 | __attribute_used__ noinline static int |
51 | _sys_sigsuspend(nabi_no_regargs struct pt_regs regs) | 49 | _sys_sigsuspend(nabi_no_regargs struct pt_regs regs) |
52 | { | 50 | { |
53 | sigset_t saveset, newset; | 51 | sigset_t newset; |
54 | sigset_t __user *uset; | 52 | sigset_t __user *uset; |
55 | 53 | ||
56 | uset = (sigset_t __user *) regs.regs[4]; | 54 | uset = (sigset_t __user *) regs.regs[4]; |
@@ -59,19 +57,15 @@ _sys_sigsuspend(nabi_no_regargs struct pt_regs regs) | |||
59 | sigdelsetmask(&newset, ~_BLOCKABLE); | 57 | sigdelsetmask(&newset, ~_BLOCKABLE); |
60 | 58 | ||
61 | spin_lock_irq(¤t->sighand->siglock); | 59 | spin_lock_irq(¤t->sighand->siglock); |
62 | saveset = current->blocked; | 60 | current->saved_sigmask = current->blocked; |
63 | current->blocked = newset; | 61 | current->blocked = newset; |
64 | recalc_sigpending(); | 62 | recalc_sigpending(); |
65 | spin_unlock_irq(¤t->sighand->siglock); | 63 | spin_unlock_irq(¤t->sighand->siglock); |
66 | 64 | ||
67 | regs.regs[2] = EINTR; | 65 | current->state = TASK_INTERRUPTIBLE; |
68 | regs.regs[7] = 1; | 66 | schedule(); |
69 | while (1) { | 67 | set_thread_flag(TIF_RESTORE_SIGMASK); |
70 | current->state = TASK_INTERRUPTIBLE; | 68 | return -ERESTARTNOHAND; |
71 | schedule(); | ||
72 | if (do_signal(&saveset, ®s)) | ||
73 | return -EINTR; | ||
74 | } | ||
75 | } | 69 | } |
76 | #endif | 70 | #endif |
77 | 71 | ||
@@ -79,7 +73,7 @@ save_static_function(sys_rt_sigsuspend); | |||
79 | __attribute_used__ noinline static int | 73 | __attribute_used__ noinline static int |
80 | _sys_rt_sigsuspend(nabi_no_regargs struct pt_regs regs) | 74 | _sys_rt_sigsuspend(nabi_no_regargs struct pt_regs regs) |
81 | { | 75 | { |
82 | sigset_t saveset, newset; | 76 | sigset_t newset; |
83 | sigset_t __user *unewset; | 77 | sigset_t __user *unewset; |
84 | size_t sigsetsize; | 78 | size_t sigsetsize; |
85 | 79 | ||
@@ -94,19 +88,15 @@ _sys_rt_sigsuspend(nabi_no_regargs struct pt_regs regs) | |||
94 | sigdelsetmask(&newset, ~_BLOCKABLE); | 88 | sigdelsetmask(&newset, ~_BLOCKABLE); |
95 | 89 | ||
96 | spin_lock_irq(¤t->sighand->siglock); | 90 | spin_lock_irq(¤t->sighand->siglock); |
97 | saveset = current->blocked; | 91 | current->saved_sigmask = current->blocked; |
98 | current->blocked = newset; | 92 | current->blocked = newset; |
99 | recalc_sigpending(); | 93 | recalc_sigpending(); |
100 | spin_unlock_irq(¤t->sighand->siglock); | 94 | spin_unlock_irq(¤t->sighand->siglock); |
101 | 95 | ||
102 | regs.regs[2] = EINTR; | 96 | current->state = TASK_INTERRUPTIBLE; |
103 | regs.regs[7] = 1; | 97 | schedule(); |
104 | while (1) { | 98 | set_thread_flag(TIF_RESTORE_SIGMASK); |
105 | current->state = TASK_INTERRUPTIBLE; | 99 | return -ERESTARTNOHAND; |
106 | schedule(); | ||
107 | if (do_signal(&saveset, ®s)) | ||
108 | return -EINTR; | ||
109 | } | ||
110 | } | 100 | } |
111 | 101 | ||
112 | #ifdef CONFIG_TRAD_SIGNALS | 102 | #ifdef CONFIG_TRAD_SIGNALS |
@@ -315,11 +305,11 @@ int setup_frame(struct k_sigaction * ka, struct pt_regs *regs, | |||
315 | current->comm, current->pid, | 305 | current->comm, current->pid, |
316 | frame, regs->cp0_epc, frame->regs[31]); | 306 | frame, regs->cp0_epc, frame->regs[31]); |
317 | #endif | 307 | #endif |
318 | return 1; | 308 | return 0; |
319 | 309 | ||
320 | give_sigsegv: | 310 | give_sigsegv: |
321 | force_sigsegv(signr, current); | 311 | force_sigsegv(signr, current); |
322 | return 0; | 312 | return -EFAULT; |
323 | } | 313 | } |
324 | #endif | 314 | #endif |
325 | 315 | ||
@@ -375,11 +365,11 @@ int setup_rt_frame(struct k_sigaction * ka, struct pt_regs *regs, | |||
375 | current->comm, current->pid, | 365 | current->comm, current->pid, |
376 | frame, regs->cp0_epc, regs->regs[31]); | 366 | frame, regs->cp0_epc, regs->regs[31]); |
377 | #endif | 367 | #endif |
378 | return 1; | 368 | return 0; |
379 | 369 | ||
380 | give_sigsegv: | 370 | give_sigsegv: |
381 | force_sigsegv(signr, current); | 371 | force_sigsegv(signr, current); |
382 | return 0; | 372 | return -EFAULT; |
383 | } | 373 | } |
384 | 374 | ||
385 | static inline int handle_signal(unsigned long sig, siginfo_t *info, | 375 | static inline int handle_signal(unsigned long sig, siginfo_t *info, |
@@ -393,7 +383,7 @@ static inline int handle_signal(unsigned long sig, siginfo_t *info, | |||
393 | regs->regs[2] = EINTR; | 383 | regs->regs[2] = EINTR; |
394 | break; | 384 | break; |
395 | case ERESTARTSYS: | 385 | case ERESTARTSYS: |
396 | if(!(ka->sa.sa_flags & SA_RESTART)) { | 386 | if (!(ka->sa.sa_flags & SA_RESTART)) { |
397 | regs->regs[2] = EINTR; | 387 | regs->regs[2] = EINTR; |
398 | break; | 388 | break; |
399 | } | 389 | } |
@@ -420,9 +410,10 @@ static inline int handle_signal(unsigned long sig, siginfo_t *info, | |||
420 | return ret; | 410 | return ret; |
421 | } | 411 | } |
422 | 412 | ||
423 | int do_signal(sigset_t *oldset, struct pt_regs *regs) | 413 | int do_signal(struct pt_regs *regs) |
424 | { | 414 | { |
425 | struct k_sigaction ka; | 415 | struct k_sigaction ka; |
416 | sigset_t *oldset; | ||
426 | siginfo_t info; | 417 | siginfo_t info; |
427 | int signr; | 418 | int signr; |
428 | 419 | ||
@@ -437,12 +428,26 @@ int do_signal(sigset_t *oldset, struct pt_regs *regs) | |||
437 | if (try_to_freeze()) | 428 | if (try_to_freeze()) |
438 | goto no_signal; | 429 | goto no_signal; |
439 | 430 | ||
440 | if (!oldset) | 431 | if (test_thread_flag(TIF_RESTORE_SIGMASK)) |
432 | oldset = ¤t->saved_sigmask; | ||
433 | else | ||
441 | oldset = ¤t->blocked; | 434 | oldset = ¤t->blocked; |
442 | 435 | ||
436 | |||
443 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); | 437 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); |
444 | if (signr > 0) | 438 | if (signr > 0) { |
445 | return handle_signal(signr, &info, &ka, oldset, regs); | 439 | /* Whee! Actually deliver the signal. */ |
440 | if (handle_signal(signr, &info, &ka, oldset, regs) == 0) { | ||
441 | /* | ||
442 | * A signal was successfully delivered; the saved | ||
443 | * sigmask will have been stored in the signal frame, | ||
444 | * and will be restored by sigreturn, so we can simply | ||
445 | * clear the TIF_RESTORE_SIGMASK flag. | ||
446 | */ | ||
447 | if (test_thread_flag(TIF_RESTORE_SIGMASK)) | ||
448 | clear_thread_flag(TIF_RESTORE_SIGMASK); | ||
449 | } | ||
450 | } | ||
446 | 451 | ||
447 | no_signal: | 452 | no_signal: |
448 | /* | 453 | /* |
@@ -463,18 +468,27 @@ no_signal: | |||
463 | regs->cp0_epc -= 4; | 468 | regs->cp0_epc -= 4; |
464 | } | 469 | } |
465 | } | 470 | } |
471 | |||
472 | /* | ||
473 | * If there's no signal to deliver, we just put the saved sigmask | ||
474 | * back | ||
475 | */ | ||
476 | if (test_thread_flag(TIF_RESTORE_SIGMASK)) { | ||
477 | clear_thread_flag(TIF_RESTORE_SIGMASK); | ||
478 | sigprocmask(SIG_SETMASK, ¤t->saved_sigmask, NULL); | ||
479 | } | ||
480 | |||
466 | return 0; | 481 | return 0; |
467 | } | 482 | } |
468 | 483 | ||
469 | /* | 484 | /* |
470 | * notification of userspace execution resumption | 485 | * notification of userspace execution resumption |
471 | * - triggered by current->work.notify_resume | 486 | * - triggered by the TIF_WORK_MASK flags |
472 | */ | 487 | */ |
473 | asmlinkage void do_notify_resume(struct pt_regs *regs, sigset_t *oldset, | 488 | asmlinkage void do_notify_resume(struct pt_regs *regs, void *unused, |
474 | __u32 thread_info_flags) | 489 | __u32 thread_info_flags) |
475 | { | 490 | { |
476 | /* deal with pending signal delivery */ | 491 | /* deal with pending signal delivery */ |
477 | if (thread_info_flags & _TIF_SIGPENDING) { | 492 | if (thread_info_flags & (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK)) |
478 | current->thread.abi->do_signal(oldset, regs); | 493 | current->thread.abi->do_signal(regs); |
479 | } | ||
480 | } | 494 | } |
diff --git a/arch/mips/kernel/signal32.c b/arch/mips/kernel/signal32.c index 136260c8f756..da3271e1fdac 100644 --- a/arch/mips/kernel/signal32.c +++ b/arch/mips/kernel/signal32.c | |||
@@ -694,11 +694,11 @@ int setup_frame_32(struct k_sigaction * ka, struct pt_regs *regs, | |||
694 | current->comm, current->pid, | 694 | current->comm, current->pid, |
695 | frame, regs->cp0_epc, frame->sf_code); | 695 | frame, regs->cp0_epc, frame->sf_code); |
696 | #endif | 696 | #endif |
697 | return 1; | 697 | return 0; |
698 | 698 | ||
699 | give_sigsegv: | 699 | give_sigsegv: |
700 | force_sigsegv(signr, current); | 700 | force_sigsegv(signr, current); |
701 | return 0; | 701 | return -EFAULT; |
702 | } | 702 | } |
703 | 703 | ||
704 | int setup_rt_frame_32(struct k_sigaction * ka, struct pt_regs *regs, | 704 | int setup_rt_frame_32(struct k_sigaction * ka, struct pt_regs *regs, |
@@ -765,11 +765,11 @@ int setup_rt_frame_32(struct k_sigaction * ka, struct pt_regs *regs, | |||
765 | current->comm, current->pid, | 765 | current->comm, current->pid, |
766 | frame, regs->cp0_epc, frame->rs_code); | 766 | frame, regs->cp0_epc, frame->rs_code); |
767 | #endif | 767 | #endif |
768 | return 1; | 768 | return 0; |
769 | 769 | ||
770 | give_sigsegv: | 770 | give_sigsegv: |
771 | force_sigsegv(signr, current); | 771 | force_sigsegv(signr, current); |
772 | return 0; | 772 | return -EFAULT; |
773 | } | 773 | } |
774 | 774 | ||
775 | static inline int handle_signal(unsigned long sig, siginfo_t *info, | 775 | static inline int handle_signal(unsigned long sig, siginfo_t *info, |
diff --git a/arch/mips/kernel/signal_n32.c b/arch/mips/kernel/signal_n32.c index 9156863c1a5d..384fc4a639a4 100644 --- a/arch/mips/kernel/signal_n32.c +++ b/arch/mips/kernel/signal_n32.c | |||
@@ -186,9 +186,9 @@ int setup_rt_frame_n32(struct k_sigaction * ka, | |||
186 | current->comm, current->pid, | 186 | current->comm, current->pid, |
187 | frame, regs->cp0_epc, regs->regs[31]); | 187 | frame, regs->cp0_epc, regs->regs[31]); |
188 | #endif | 188 | #endif |
189 | return 1; | 189 | return 0; |
190 | 190 | ||
191 | give_sigsegv: | 191 | give_sigsegv: |
192 | force_sigsegv(signr, current); | 192 | force_sigsegv(signr, current); |
193 | return 0; | 193 | return -EFAULT; |
194 | } | 194 | } |
diff --git a/include/asm-mips/abi.h b/include/asm-mips/abi.h index 2e7e651c3e3f..5edd69bf0f24 100644 --- a/include/asm-mips/abi.h +++ b/include/asm-mips/abi.h | |||
@@ -3,7 +3,7 @@ | |||
3 | * License. See the file "COPYING" in the main directory of this archive | 3 | * License. See the file "COPYING" in the main directory of this archive |
4 | * for more details. | 4 | * for more details. |
5 | * | 5 | * |
6 | * Copyright (C) 2005 by Ralf Baechle | 6 | * Copyright (C) 2005, 06 by Ralf Baechle (ralf@linux-mips.org) |
7 | * Copyright (C) 2005 MIPS Technologies, Inc. | 7 | * Copyright (C) 2005 MIPS Technologies, Inc. |
8 | */ | 8 | */ |
9 | #ifndef _ASM_ABI_H | 9 | #ifndef _ASM_ABI_H |
@@ -13,7 +13,7 @@ | |||
13 | #include <asm/siginfo.h> | 13 | #include <asm/siginfo.h> |
14 | 14 | ||
15 | struct mips_abi { | 15 | struct mips_abi { |
16 | int (* const do_signal)(sigset_t *oldset, struct pt_regs *regs); | 16 | int (* const do_signal)(struct pt_regs *regs); |
17 | int (* const setup_frame)(struct k_sigaction * ka, | 17 | int (* const setup_frame)(struct k_sigaction * ka, |
18 | struct pt_regs *regs, int signr, | 18 | struct pt_regs *regs, int signr, |
19 | sigset_t *set); | 19 | sigset_t *set); |
diff --git a/include/asm-mips/thread_info.h b/include/asm-mips/thread_info.h index 1612b3fe1080..fa193f861e71 100644 --- a/include/asm-mips/thread_info.h +++ b/include/asm-mips/thread_info.h | |||
@@ -114,6 +114,7 @@ register struct thread_info *__current_thread_info __asm__("$28"); | |||
114 | #define TIF_NEED_RESCHED 3 /* rescheduling necessary */ | 114 | #define TIF_NEED_RESCHED 3 /* rescheduling necessary */ |
115 | #define TIF_SYSCALL_AUDIT 4 /* syscall auditing active */ | 115 | #define TIF_SYSCALL_AUDIT 4 /* syscall auditing active */ |
116 | #define TIF_SECCOMP 5 /* secure computing */ | 116 | #define TIF_SECCOMP 5 /* secure computing */ |
117 | #define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal() */ | ||
117 | #define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */ | 118 | #define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */ |
118 | #define TIF_POLLING_NRFLAG 17 /* true if poll_idle() is polling TIF_NEED_RESCHED */ | 119 | #define TIF_POLLING_NRFLAG 17 /* true if poll_idle() is polling TIF_NEED_RESCHED */ |
119 | #define TIF_MEMDIE 18 | 120 | #define TIF_MEMDIE 18 |
@@ -125,6 +126,7 @@ register struct thread_info *__current_thread_info __asm__("$28"); | |||
125 | #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) | 126 | #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) |
126 | #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT) | 127 | #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT) |
127 | #define _TIF_SECCOMP (1<<TIF_SECCOMP) | 128 | #define _TIF_SECCOMP (1<<TIF_SECCOMP) |
129 | #define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK) | ||
128 | #define _TIF_USEDFPU (1<<TIF_USEDFPU) | 130 | #define _TIF_USEDFPU (1<<TIF_USEDFPU) |
129 | #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) | 131 | #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) |
130 | 132 | ||