Commit 020c4831 authored by Christophe Leroy's avatar Christophe Leroy Committed by Michael Ellerman

powerpc/signal_32: Simplify loop in PPC64 save_general_regs()

save_general_regs() which does special handling when i == PT_SOFTE.

Rewrite it to minimise the specific part, especially the __put_user()
and associated error handling is the same so make it common.
Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
[mpe: Use a regular if rather than ternary operator]
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/47a38df46cae5a5a88a558a64d71f75e9c4d9950.1594125164.git.christophe.leroy@csgroup.eu
parent 667e3c41
...@@ -102,20 +102,18 @@ static inline int save_general_regs(struct pt_regs *regs, ...@@ -102,20 +102,18 @@ static inline int save_general_regs(struct pt_regs *regs,
struct mcontext __user *frame) struct mcontext __user *frame)
{ {
elf_greg_t64 *gregs = (elf_greg_t64 *)regs; elf_greg_t64 *gregs = (elf_greg_t64 *)regs;
int i; int val, i;
/* Force usr to alway see softe as 1 (interrupts enabled) */
elf_greg_t64 softe = 0x1;
WARN_ON(!FULL_REGS(regs)); WARN_ON(!FULL_REGS(regs));
for (i = 0; i <= PT_RESULT; i ++) { for (i = 0; i <= PT_RESULT; i ++) {
if ( i == PT_SOFTE) { /* Force usr to alway see softe as 1 (interrupts enabled) */
if(__put_user((unsigned int)softe, &frame->mc_gregs[i])) if (i == PT_SOFTE)
return -EFAULT; val = 1;
else else
continue; val = gregs[i];
}
if (__put_user((unsigned int)gregs[i], &frame->mc_gregs[i])) if (__put_user(val, &frame->mc_gregs[i]))
return -EFAULT; return -EFAULT;
} }
return 0; return 0;
......
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