Commit 91b8ecd4 authored by Christophe Leroy's avatar Christophe Leroy Committed by Michael Ellerman

powerpc/signal32: Misc changes to make handle_[rt_]_signal32() more similar

Miscellaneous changes to clean and make handle_signal32() and
handle_rt_signal32() even more similar.
Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/df0bc8c3b8fa96390c46f611df79b2a94ac21844.1597770847.git.christophe.leroy@csgroup.eu
parent 8e91cf85
...@@ -764,8 +764,11 @@ int handle_rt_signal32(struct ksignal *ksig, sigset_t *oldset, ...@@ -764,8 +764,11 @@ int handle_rt_signal32(struct ksignal *ksig, sigset_t *oldset,
#endif #endif
/* Set up Signal Frame */ /* Set up Signal Frame */
/* Put a Real Time Context onto stack */
frame = get_sigframe(ksig, tsk, sizeof(*frame), 1); frame = get_sigframe(ksig, tsk, sizeof(*frame), 1);
mctx = &frame->uc.uc_mcontext;
#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
tm_mctx = &frame->uc_transact.uc_mcontext;
#endif
if (!access_ok(frame, sizeof(*frame))) if (!access_ok(frame, sizeof(*frame)))
goto badframe; goto badframe;
...@@ -778,7 +781,6 @@ int handle_rt_signal32(struct ksignal *ksig, sigset_t *oldset, ...@@ -778,7 +781,6 @@ int handle_rt_signal32(struct ksignal *ksig, sigset_t *oldset,
goto badframe; goto badframe;
/* Save user registers on the stack */ /* Save user registers on the stack */
mctx = &frame->uc.uc_mcontext;
if (vdso32_rt_sigtramp && tsk->mm->context.vdso_base) { if (vdso32_rt_sigtramp && tsk->mm->context.vdso_base) {
sigret = 0; sigret = 0;
tramp = tsk->mm->context.vdso_base + vdso32_rt_sigtramp; tramp = tsk->mm->context.vdso_base + vdso32_rt_sigtramp;
...@@ -788,7 +790,6 @@ int handle_rt_signal32(struct ksignal *ksig, sigset_t *oldset, ...@@ -788,7 +790,6 @@ int handle_rt_signal32(struct ksignal *ksig, sigset_t *oldset,
} }
#ifdef CONFIG_PPC_TRANSACTIONAL_MEM #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
tm_mctx = &frame->uc_transact.uc_mcontext;
if (MSR_TM_ACTIVE(msr)) { if (MSR_TM_ACTIVE(msr)) {
if (__put_user((unsigned long)&frame->uc_transact, if (__put_user((unsigned long)&frame->uc_transact,
&frame->uc.uc_link) || &frame->uc.uc_link) ||
...@@ -843,6 +844,7 @@ int handle_signal32(struct ksignal *ksig, sigset_t *oldset, ...@@ -843,6 +844,7 @@ int handle_signal32(struct ksignal *ksig, sigset_t *oldset,
{ {
struct sigcontext __user *sc; struct sigcontext __user *sc;
struct sigframe __user *frame; struct sigframe __user *frame;
struct mcontext __user *mctx;
struct mcontext __user *tm_mctx = NULL; struct mcontext __user *tm_mctx = NULL;
unsigned long newsp = 0; unsigned long newsp = 0;
int sigret; int sigret;
...@@ -855,6 +857,10 @@ int handle_signal32(struct ksignal *ksig, sigset_t *oldset, ...@@ -855,6 +857,10 @@ int handle_signal32(struct ksignal *ksig, sigset_t *oldset,
/* Set up Signal Frame */ /* Set up Signal Frame */
frame = get_sigframe(ksig, tsk, sizeof(*frame), 1); frame = get_sigframe(ksig, tsk, sizeof(*frame), 1);
mctx = &frame->mctx;
#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
tm_mctx = &frame->mctx_transact;
#endif
if (!access_ok(frame, sizeof(*frame))) if (!access_ok(frame, sizeof(*frame)))
goto badframe; goto badframe;
sc = (struct sigcontext __user *) &frame->sctx; sc = (struct sigcontext __user *) &frame->sctx;
...@@ -869,7 +875,7 @@ int handle_signal32(struct ksignal *ksig, sigset_t *oldset, ...@@ -869,7 +875,7 @@ int handle_signal32(struct ksignal *ksig, sigset_t *oldset,
#else #else
|| __put_user(oldset->sig[1], &sc->_unused[3]) || __put_user(oldset->sig[1], &sc->_unused[3])
#endif #endif
|| __put_user(to_user_ptr(&frame->mctx), &sc->regs) || __put_user(to_user_ptr(mctx), &sc->regs)
|| __put_user(ksig->sig, &sc->signal)) || __put_user(ksig->sig, &sc->signal))
goto badframe; goto badframe;
...@@ -878,20 +884,18 @@ int handle_signal32(struct ksignal *ksig, sigset_t *oldset, ...@@ -878,20 +884,18 @@ int handle_signal32(struct ksignal *ksig, sigset_t *oldset,
tramp = tsk->mm->context.vdso_base + vdso32_sigtramp; tramp = tsk->mm->context.vdso_base + vdso32_sigtramp;
} else { } else {
sigret = __NR_sigreturn; sigret = __NR_sigreturn;
tramp = (unsigned long) frame->mctx.tramp; tramp = (unsigned long)mctx->tramp;
} }
#ifdef CONFIG_PPC_TRANSACTIONAL_MEM #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
tm_mctx = &frame->mctx_transact;
if (MSR_TM_ACTIVE(msr)) { if (MSR_TM_ACTIVE(msr)) {
if (save_tm_user_regs(regs, &frame->mctx, &frame->mctx_transact, if (save_tm_user_regs(regs, mctx, tm_mctx, sigret, msr))
sigret, msr))
goto badframe; goto badframe;
} }
else else
#endif #endif
{ {
if (save_user_regs(regs, &frame->mctx, tm_mctx, sigret, 1)) if (save_user_regs(regs, mctx, tm_mctx, sigret, 1))
goto badframe; goto badframe;
} }
...@@ -909,7 +913,7 @@ int handle_signal32(struct ksignal *ksig, sigset_t *oldset, ...@@ -909,7 +913,7 @@ int handle_signal32(struct ksignal *ksig, sigset_t *oldset,
regs->gpr[1] = newsp; regs->gpr[1] = newsp;
regs->gpr[3] = ksig->sig; regs->gpr[3] = ksig->sig;
regs->gpr[4] = (unsigned long) sc; regs->gpr[4] = (unsigned long) sc;
regs->nip = (unsigned long) (unsigned long)ksig->ka.sa.sa_handler; regs->nip = (unsigned long)ksig->ka.sa.sa_handler;
/* enter the signal handler in big-endian mode */ /* enter the signal handler in big-endian mode */
regs->msr &= ~MSR_LE; regs->msr &= ~MSR_LE;
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