Commit d16952a6 authored by Christophe Leroy's avatar Christophe Leroy Committed by Michael Ellerman

powerpc/signal: Use code patching instead of hardcoding

Instead of hardcoding code modifications, use code patching functions.
Signed-off-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 002cdfc2
...@@ -257,6 +257,7 @@ ...@@ -257,6 +257,7 @@
#define PPC_INST_MTSPR_DSCR_USER_MASK 0xfc1ffffe #define PPC_INST_MTSPR_DSCR_USER_MASK 0xfc1ffffe
#define PPC_INST_MFVSRD 0x7c000066 #define PPC_INST_MFVSRD 0x7c000066
#define PPC_INST_MTVSRD 0x7c000166 #define PPC_INST_MTVSRD 0x7c000166
#define PPC_INST_SC 0x44000002
#define PPC_INST_SLBFEE 0x7c0007a7 #define PPC_INST_SLBFEE 0x7c0007a7
#define PPC_INST_SLBIA 0x7c0003e4 #define PPC_INST_SLBIA 0x7c0003e4
......
...@@ -470,9 +470,9 @@ static int save_user_regs(struct pt_regs *regs, struct mcontext __user *frame, ...@@ -470,9 +470,9 @@ static int save_user_regs(struct pt_regs *regs, struct mcontext __user *frame,
return 1; return 1;
if (sigret) { if (sigret) {
/* Set up the sigreturn trampoline: li r0,sigret; sc */ /* Set up the sigreturn trampoline: li 0,sigret; sc */
if (__put_user(0x38000000UL + sigret, &frame->tramp[0]) if (__put_user(PPC_INST_ADDI + sigret, &frame->tramp[0])
|| __put_user(0x44000002UL, &frame->tramp[1])) || __put_user(PPC_INST_SC, &frame->tramp[1]))
return 1; return 1;
flush_icache_range((unsigned long) &frame->tramp[0], flush_icache_range((unsigned long) &frame->tramp[0],
(unsigned long) &frame->tramp[2]); (unsigned long) &frame->tramp[2]);
...@@ -619,9 +619,9 @@ static int save_tm_user_regs(struct pt_regs *regs, ...@@ -619,9 +619,9 @@ static int save_tm_user_regs(struct pt_regs *regs,
if (__put_user(msr, &frame->mc_gregs[PT_MSR])) if (__put_user(msr, &frame->mc_gregs[PT_MSR]))
return 1; return 1;
if (sigret) { if (sigret) {
/* Set up the sigreturn trampoline: li r0,sigret; sc */ /* Set up the sigreturn trampoline: li 0,sigret; sc */
if (__put_user(0x38000000UL + sigret, &frame->tramp[0]) if (__put_user(PPC_INST_ADDI + sigret, &frame->tramp[0])
|| __put_user(0x44000002UL, &frame->tramp[1])) || __put_user(PPC_INST_SC, &frame->tramp[1]))
return 1; return 1;
flush_icache_range((unsigned long) &frame->tramp[0], flush_icache_range((unsigned long) &frame->tramp[0],
(unsigned long) &frame->tramp[2]); (unsigned long) &frame->tramp[2]);
......
...@@ -598,11 +598,12 @@ static long setup_trampoline(unsigned int syscall, unsigned int __user *tramp) ...@@ -598,11 +598,12 @@ static long setup_trampoline(unsigned int syscall, unsigned int __user *tramp)
long err = 0; long err = 0;
/* addi r1, r1, __SIGNAL_FRAMESIZE # Pop the dummy stackframe */ /* addi r1, r1, __SIGNAL_FRAMESIZE # Pop the dummy stackframe */
err |= __put_user(0x38210000UL | (__SIGNAL_FRAMESIZE & 0xffff), &tramp[0]); err |= __put_user(PPC_INST_ADDI | __PPC_RT(R1) | __PPC_RA(R1) |
(__SIGNAL_FRAMESIZE & 0xffff), &tramp[0]);
/* li r0, __NR_[rt_]sigreturn| */ /* li r0, __NR_[rt_]sigreturn| */
err |= __put_user(0x38000000UL | (syscall & 0xffff), &tramp[1]); err |= __put_user(PPC_INST_ADDI | (syscall & 0xffff), &tramp[1]);
/* sc */ /* sc */
err |= __put_user(0x44000002UL, &tramp[2]); err |= __put_user(PPC_INST_SC, &tramp[2]);
/* Minimal traceback info */ /* Minimal traceback info */
for (i=TRAMP_TRACEBACK; i < TRAMP_SIZE ;i++) for (i=TRAMP_TRACEBACK; i < TRAMP_SIZE ;i++)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment