[POWERPC] Consolidate restore_sigmask
[powerpc.git] / arch / powerpc / kernel / signal_64.c
index 6e75d7a..7e9c4b7 100644 (file)
  *  2 of the License, or (at your option) any later version.
  */
 
-#include <linux/config.h>
 #include <linux/sched.h>
 #include <linux/mm.h>
 #include <linux/smp.h>
-#include <linux/smp_lock.h>
 #include <linux/kernel.h>
 #include <linux/signal.h>
 #include <linux/errno.h>
@@ -36,9 +34,9 @@
 #include <asm/syscalls.h>
 #include <asm/vdso.h>
 
-#define DEBUG_SIG 0
+#include "signal.h"
 
-#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
+#define DEBUG_SIG 0
 
 #define GP_REGS_SIZE   min(sizeof(elf_gregset_t), sizeof(struct pt_regs))
 #define FP_REGS_SIZE   sizeof(elf_fpregset_t)
@@ -66,14 +64,6 @@ struct rt_sigframe {
        char abigap[288];
 } __attribute__ ((aligned (16)));
 
-long sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss, unsigned long r5,
-                    unsigned long r6, unsigned long r7, unsigned long r8,
-                    struct pt_regs *regs)
-{
-       return do_sigaltstack(uss, uoss, regs->gpr[1]);
-}
-
-
 /*
  * Set up the sigcontext for the signal frame.
  */
@@ -250,19 +240,6 @@ static long setup_trampoline(unsigned int syscall, unsigned int __user *tramp)
        return err;
 }
 
-/*
- * Restore the user process's signal mask (also used by signal32.c)
- */
-void restore_sigmask(sigset_t *set)
-{
-       sigdelsetmask(set, ~_BLOCKABLE);
-       spin_lock_irq(&current->sighand->siglock);
-       current->blocked = *set;
-       recalc_sigpending();
-       spin_unlock_irq(&current->sighand->siglock);
-}
-
-
 /*
  * Handle {get,set,swap}_context operations
  */
@@ -465,41 +442,6 @@ static int handle_signal(unsigned long sig, struct k_sigaction *ka,
        return ret;
 }
 
-static inline void syscall_restart(struct pt_regs *regs, struct k_sigaction *ka)
-{
-       switch ((int)regs->result) {
-       case -ERESTART_RESTARTBLOCK:
-       case -ERESTARTNOHAND:
-               /* ERESTARTNOHAND means that the syscall should only be
-                * restarted if there was no handler for the signal, and since
-                * we only get here if there is a handler, we dont restart.
-                */
-               regs->result = -EINTR;
-               regs->gpr[3] = EINTR;
-               regs->ccr |= 0x10000000;
-               break;
-       case -ERESTARTSYS:
-               /* ERESTARTSYS means to restart the syscall if there is no
-                * handler or the handler was registered with SA_RESTART
-                */
-               if (!(ka->sa.sa_flags & SA_RESTART)) {
-                       regs->result = -EINTR;
-                       regs->gpr[3] = EINTR;
-                       regs->ccr |= 0x10000000;
-                       break;
-               }
-               /* fallthrough */
-       case -ERESTARTNOINTR:
-               /* ERESTARTNOINTR means that the syscall should be
-                * called again after the signal handler returns.
-                */
-               regs->gpr[3] = regs->orig_gpr3;
-               regs->nip -= 4;
-               regs->result = 0;
-               break;
-       }
-}
-
 /*
  * Note that 'init' is a special process: it doesn't get signals it doesn't
  * want to handle. Thus you cannot kill init even with a SIGKILL even by
@@ -524,13 +466,13 @@ int do_signal(sigset_t *oldset, struct pt_regs *regs)
                oldset = &current->blocked;
 
        signr = get_signal_to_deliver(&info, &ka, regs, NULL);
+
+       /* Is there any syscall restart business here ? */
+       check_syscall_restart(regs, &ka, signr > 0);
+
        if (signr > 0) {
                int ret;
 
-               /* Whee!  Actually deliver the signal.  */
-               if (TRAP(regs) == 0x0C00)
-                       syscall_restart(regs, &ka);
-
                /*
                 * Reenable the DABR before delivering the signal to
                 * user space. The DABR will have been cleared if it
@@ -539,6 +481,7 @@ int do_signal(sigset_t *oldset, struct pt_regs *regs)
                if (current->thread.dabr)
                        set_dabr(current->thread.dabr);
 
+               /* Whee!  Actually deliver the signal.  */
                ret = handle_signal(signr, &ka, &info, oldset, regs);
 
                /* If a signal was successfully delivered, the saved sigmask is in
@@ -549,19 +492,6 @@ int do_signal(sigset_t *oldset, struct pt_regs *regs)
                return ret;
        }
 
-       if (TRAP(regs) == 0x0C00) {     /* System Call! */
-               if ((int)regs->result == -ERESTARTNOHAND ||
-                   (int)regs->result == -ERESTARTSYS ||
-                   (int)regs->result == -ERESTARTNOINTR) {
-                       regs->gpr[3] = regs->orig_gpr3;
-                       regs->nip -= 4; /* Back up & retry system call */
-                       regs->result = 0;
-               } else if ((int)regs->result == -ERESTART_RESTARTBLOCK) {
-                       regs->gpr[0] = __NR_restart_syscall;
-                       regs->nip -= 4;
-                       regs->result = 0;
-               }
-       }
        /* No signal to deliver -- put the saved sigmask back */
        if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
                clear_thread_flag(TIF_RESTORE_SIGMASK);