powerpc/8xx: Use SPRG2 and DAR registers to stash r11 and cr.
[safe/jmp/linux-2.6] / arch / powerpc / kernel / signal_32.c
index a6a4310..2666101 100644 (file)
@@ -836,7 +836,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
 
        /* Set up Signal Frame */
        /* Put a Real Time Context onto stack */
-       rt_sf = get_sigframe(ka, regs, sizeof(*rt_sf));
+       rt_sf = get_sigframe(ka, regs, sizeof(*rt_sf), 1);
        addr = rt_sf;
        if (unlikely(rt_sf == NULL))
                goto badframe;
@@ -941,9 +941,21 @@ long sys_swapcontext(struct ucontext __user *old_ctx,
 #ifdef CONFIG_PPC64
        unsigned long new_msr = 0;
 
-       if (new_ctx &&
-           get_user(new_msr, &new_ctx->uc_mcontext.mc_gregs[PT_MSR]))
-               return -EFAULT;
+       if (new_ctx) {
+               struct mcontext __user *mcp;
+               u32 cmcp;
+
+               /*
+                * Get pointer to the real mcontext.  No need for
+                * access_ok since we are dealing with compat
+                * pointers.
+                */
+               if (__get_user(cmcp, &new_ctx->uc_regs))
+                       return -EFAULT;
+               mcp = (struct mcontext __user *)(u64)cmcp;
+               if (__get_user(new_msr, &mcp->mc_gregs[PT_MSR]))
+                       return -EFAULT;
+       }
        /*
         * Check that the context is not smaller than the original
         * size (with VMX but without VSX)
@@ -1066,7 +1078,7 @@ int sys_debug_setcontext(struct ucontext __user *ctx,
        int i;
        unsigned char tmp;
        unsigned long new_msr = regs->msr;
-#if defined(CONFIG_4xx) || defined(CONFIG_BOOKE)
+#ifdef CONFIG_PPC_ADV_DEBUG_REGS
        unsigned long new_dbcr0 = current->thread.dbcr0;
 #endif
 
@@ -1075,13 +1087,17 @@ int sys_debug_setcontext(struct ucontext __user *ctx,
                        return -EFAULT;
                switch (op.dbg_type) {
                case SIG_DBG_SINGLE_STEPPING:
-#if defined(CONFIG_4xx) || defined(CONFIG_BOOKE)
+#ifdef CONFIG_PPC_ADV_DEBUG_REGS
                        if (op.dbg_value) {
                                new_msr |= MSR_DE;
                                new_dbcr0 |= (DBCR0_IDM | DBCR0_IC);
                        } else {
-                               new_msr &= ~MSR_DE;
-                               new_dbcr0 &= ~(DBCR0_IDM | DBCR0_IC);
+                               new_dbcr0 &= ~DBCR0_IC;
+                               if (!DBCR_ACTIVE_EVENTS(new_dbcr0,
+                                               current->thread.dbcr1)) {
+                                       new_msr &= ~MSR_DE;
+                                       new_dbcr0 &= ~DBCR0_IDM;
+                               }
                        }
 #else
                        if (op.dbg_value)
@@ -1091,7 +1107,7 @@ int sys_debug_setcontext(struct ucontext __user *ctx,
 #endif
                        break;
                case SIG_DBG_BRANCH_TRACING:
-#if defined(CONFIG_4xx) || defined(CONFIG_BOOKE)
+#ifdef CONFIG_PPC_ADV_DEBUG_REGS
                        return -EINVAL;
 #else
                        if (op.dbg_value)
@@ -1112,7 +1128,7 @@ int sys_debug_setcontext(struct ucontext __user *ctx,
           failure is a problem, anyway, and it's very unlikely unless
           the user is really doing something wrong. */
        regs->msr = new_msr;
-#if defined(CONFIG_4xx) || defined(CONFIG_BOOKE)
+#ifdef CONFIG_PPC_ADV_DEBUG_REGS
        current->thread.dbcr0 = new_dbcr0;
 #endif
 
@@ -1170,7 +1186,7 @@ int handle_signal32(unsigned long sig, struct k_sigaction *ka,
        unsigned long newsp = 0;
 
        /* Set up Signal Frame */
-       frame = get_sigframe(ka, regs, sizeof(*frame));
+       frame = get_sigframe(ka, regs, sizeof(*frame), 1);
        if (unlikely(frame == NULL))
                goto badframe;
        sc = (struct sigcontext __user *) &frame->sctx;