aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/signal_64.c
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2007-06-04 01:15:49 -0400
committerPaul Mackerras <paulus@samba.org>2007-06-14 08:29:57 -0400
commit22e38f29328296d9d4cc33e46fd32a63e807abaf (patch)
tree4cfea90671815ce87d5d0e896bb9f818565132c8 /arch/powerpc/kernel/signal_64.c
parent791cc501d422be96d6e3098faf6471ba29f4dd33 (diff)
[POWERPC] Make syscall restart code more common
This patch moves the code in signal_32.c and signal_64.c for handling syscall restart into a common signal.c file and converge around a single implementation that is based on the 32 bits one, using trap, ccr and r3 rather than the special "result" field for deciding what to do. The "result" field is now pretty much deprecated. We still set it for the sake of whatever might rely on it in userland but we no longer use it's content. This, along with a previous patch that enables ptracers to write to "trap" and "orig_r3" should allow gdb to properly handle syscall restarting. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/kernel/signal_64.c')
-rw-r--r--arch/powerpc/kernel/signal_64.c59
1 files changed, 7 insertions, 52 deletions
diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
index 1ce0ae3f6ffc..5d2faf0fbf05 100644
--- a/arch/powerpc/kernel/signal_64.c
+++ b/arch/powerpc/kernel/signal_64.c
@@ -34,6 +34,8 @@
34#include <asm/syscalls.h> 34#include <asm/syscalls.h>
35#include <asm/vdso.h> 35#include <asm/vdso.h>
36 36
37#include "signal.h"
38
37#define DEBUG_SIG 0 39#define DEBUG_SIG 0
38 40
39#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) 41#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
@@ -463,41 +465,6 @@ static int handle_signal(unsigned long sig, struct k_sigaction *ka,
463 return ret; 465 return ret;
464} 466}
465 467
466static inline void syscall_restart(struct pt_regs *regs, struct k_sigaction *ka)
467{
468 switch ((int)regs->result) {
469 case -ERESTART_RESTARTBLOCK:
470 case -ERESTARTNOHAND:
471 /* ERESTARTNOHAND means that the syscall should only be
472 * restarted if there was no handler for the signal, and since
473 * we only get here if there is a handler, we dont restart.
474 */
475 regs->result = -EINTR;
476 regs->gpr[3] = EINTR;
477 regs->ccr |= 0x10000000;
478 break;
479 case -ERESTARTSYS:
480 /* ERESTARTSYS means to restart the syscall if there is no
481 * handler or the handler was registered with SA_RESTART
482 */
483 if (!(ka->sa.sa_flags & SA_RESTART)) {
484 regs->result = -EINTR;
485 regs->gpr[3] = EINTR;
486 regs->ccr |= 0x10000000;
487 break;
488 }
489 /* fallthrough */
490 case -ERESTARTNOINTR:
491 /* ERESTARTNOINTR means that the syscall should be
492 * called again after the signal handler returns.
493 */
494 regs->gpr[3] = regs->orig_gpr3;
495 regs->nip -= 4;
496 regs->result = 0;
497 break;
498 }
499}
500
501/* 468/*
502 * Note that 'init' is a special process: it doesn't get signals it doesn't 469 * Note that 'init' is a special process: it doesn't get signals it doesn't
503 * want to handle. Thus you cannot kill init even with a SIGKILL even by 470 * want to handle. Thus you cannot kill init even with a SIGKILL even by
@@ -522,13 +489,13 @@ int do_signal(sigset_t *oldset, struct pt_regs *regs)
522 oldset = &current->blocked; 489 oldset = &current->blocked;
523 490
524 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 491 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
492
493 /* Is there any syscall restart business here ? */
494 check_syscall_restart(regs, &ka, signr > 0);
495
525 if (signr > 0) { 496 if (signr > 0) {
526 int ret; 497 int ret;
527 498
528 /* Whee! Actually deliver the signal. */
529 if (TRAP(regs) == 0x0C00)
530 syscall_restart(regs, &ka);
531
532 /* 499 /*
533 * Reenable the DABR before delivering the signal to 500 * Reenable the DABR before delivering the signal to
534 * user space. The DABR will have been cleared if it 501 * user space. The DABR will have been cleared if it
@@ -537,6 +504,7 @@ int do_signal(sigset_t *oldset, struct pt_regs *regs)
537 if (current->thread.dabr) 504 if (current->thread.dabr)
538 set_dabr(current->thread.dabr); 505 set_dabr(current->thread.dabr);
539 506
507 /* Whee! Actually deliver the signal. */
540 ret = handle_signal(signr, &ka, &info, oldset, regs); 508 ret = handle_signal(signr, &ka, &info, oldset, regs);
541 509
542 /* If a signal was successfully delivered, the saved sigmask is in 510 /* If a signal was successfully delivered, the saved sigmask is in
@@ -547,19 +515,6 @@ int do_signal(sigset_t *oldset, struct pt_regs *regs)
547 return ret; 515 return ret;
548 } 516 }
549 517
550 if (TRAP(regs) == 0x0C00) { /* System Call! */
551 if ((int)regs->result == -ERESTARTNOHAND ||
552 (int)regs->result == -ERESTARTSYS ||
553 (int)regs->result == -ERESTARTNOINTR) {
554 regs->gpr[3] = regs->orig_gpr3;
555 regs->nip -= 4; /* Back up & retry system call */
556 regs->result = 0;
557 } else if ((int)regs->result == -ERESTART_RESTARTBLOCK) {
558 regs->gpr[0] = __NR_restart_syscall;
559 regs->nip -= 4;
560 regs->result = 0;
561 }
562 }
563 /* No signal to deliver -- put the saved sigmask back */ 518 /* No signal to deliver -- put the saved sigmask back */
564 if (test_thread_flag(TIF_RESTORE_SIGMASK)) { 519 if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
565 clear_thread_flag(TIF_RESTORE_SIGMASK); 520 clear_thread_flag(TIF_RESTORE_SIGMASK);