aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2013-11-20 06:15:03 -0500
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2013-11-20 17:19:20 -0500
commitd606b92aedb0542e60965e9058ab37efcebfaec6 (patch)
tree6759af3889c447578dc5ee8ac90d3c0bf71d0e0d /arch/powerpc/kernel
parent94af3abf995b17f6a008b00152c94841242ec6c7 (diff)
powerpc: ELF2 binaries signal handling
For the ELFv2 ABI, the hander is the entry point, not a function descriptor. We also need to set up r12, and fortunately the fast_exception_return exit path restores r12 for us so nothing else is required. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Anton Blanchard <anton@samba.org> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/kernel')
-rw-r--r--arch/powerpc/kernel/signal_64.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
index b3c615764c9b..e66f67b8b9e6 100644
--- a/arch/powerpc/kernel/signal_64.c
+++ b/arch/powerpc/kernel/signal_64.c
@@ -701,12 +701,6 @@ badframe:
701int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info, 701int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
702 sigset_t *set, struct pt_regs *regs) 702 sigset_t *set, struct pt_regs *regs)
703{ 703{
704 /* Handler is *really* a pointer to the function descriptor for
705 * the signal routine. The first entry in the function
706 * descriptor is the entry address of signal and the second
707 * entry is the TOC value we need to use.
708 */
709 func_descr_t __user *funct_desc_ptr;
710 struct rt_sigframe __user *frame; 704 struct rt_sigframe __user *frame;
711 unsigned long newsp = 0; 705 unsigned long newsp = 0;
712 long err = 0; 706 long err = 0;
@@ -766,19 +760,32 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
766 goto badframe; 760 goto badframe;
767 regs->link = (unsigned long) &frame->tramp[0]; 761 regs->link = (unsigned long) &frame->tramp[0];
768 } 762 }
769 funct_desc_ptr = (func_descr_t __user *) ka->sa.sa_handler;
770 763
771 /* Allocate a dummy caller frame for the signal handler. */ 764 /* Allocate a dummy caller frame for the signal handler. */
772 newsp = ((unsigned long)frame) - __SIGNAL_FRAMESIZE; 765 newsp = ((unsigned long)frame) - __SIGNAL_FRAMESIZE;
773 err |= put_user(regs->gpr[1], (unsigned long __user *)newsp); 766 err |= put_user(regs->gpr[1], (unsigned long __user *)newsp);
774 767
775 /* Set up "regs" so we "return" to the signal handler. */ 768 /* Set up "regs" so we "return" to the signal handler. */
776 err |= get_user(regs->nip, &funct_desc_ptr->entry); 769 if (is_elf2_task()) {
770 regs->nip = (unsigned long) ka->sa.sa_handler;
771 regs->gpr[12] = regs->nip;
772 } else {
773 /* Handler is *really* a pointer to the function descriptor for
774 * the signal routine. The first entry in the function
775 * descriptor is the entry address of signal and the second
776 * entry is the TOC value we need to use.
777 */
778 func_descr_t __user *funct_desc_ptr =
779 (func_descr_t __user *) ka->sa.sa_handler;
780
781 err |= get_user(regs->nip, &funct_desc_ptr->entry);
782 err |= get_user(regs->gpr[2], &funct_desc_ptr->toc);
783 }
784
777 /* enter the signal handler in native-endian mode */ 785 /* enter the signal handler in native-endian mode */
778 regs->msr &= ~MSR_LE; 786 regs->msr &= ~MSR_LE;
779 regs->msr |= (MSR_KERNEL & MSR_LE); 787 regs->msr |= (MSR_KERNEL & MSR_LE);
780 regs->gpr[1] = newsp; 788 regs->gpr[1] = newsp;
781 err |= get_user(regs->gpr[2], &funct_desc_ptr->toc);
782 regs->gpr[3] = signr; 789 regs->gpr[3] = signr;
783 regs->result = 0; 790 regs->result = 0;
784 if (ka->sa.sa_flags & SA_SIGINFO) { 791 if (ka->sa.sa_flags & SA_SIGINFO) {