Skip to content

Commit 87b4e53

Browse files
mikeyozbenh
authored andcommitted
powerpc/tm: Fix return of active 64bit signals
Currently we only restore signals which are transactionally suspended but it's possible that the transaction can be restored even when it's active. Most likely this will result in a transactional rollback by the hardware as the transaction will have been doomed by an earlier treclaim. The current code is a legacy of earlier kernel implementations which did software rollback of active transactions in the kernel. That code has now gone but we didn't correctly fix up this part of the signals code which still makes assumptions based on having software rollback. This changes the signal return code to always restore both contexts on 64 bit signal return. It also ensures that the MSR TM bits are properly restored from the signal context which they are not currently. Signed-off-by: Michael Neuling <mikey@neuling.org> cc: stable@vger.kernel.org (v3.9+) Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
1 parent 55e4341 commit 87b4e53

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

arch/powerpc/kernel/signal_64.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,10 @@ static long restore_tm_sigcontexts(struct pt_regs *regs,
410410

411411
/* get MSR separately, transfer the LE bit if doing signal return */
412412
err |= __get_user(msr, &sc->gp_regs[PT_MSR]);
413+
/* pull in MSR TM from user context */
414+
regs->msr = (regs->msr & ~MSR_TS_MASK) | (msr & MSR_TS_MASK);
415+
416+
/* pull in MSR LE from user context */
413417
regs->msr = (regs->msr & ~MSR_LE) | (msr & MSR_LE);
414418

415419
/* The following non-GPR non-FPR non-VR state is also checkpointed: */
@@ -505,8 +509,6 @@ static long restore_tm_sigcontexts(struct pt_regs *regs,
505509
tm_enable();
506510
/* This loads the checkpointed FP/VEC state, if used */
507511
tm_recheckpoint(&current->thread, msr);
508-
/* The task has moved into TM state S, so ensure MSR reflects this: */
509-
regs->msr = (regs->msr & ~MSR_TS_MASK) | __MASK(33);
510512

511513
/* This loads the speculative FP/VEC state, if used */
512514
if (msr & MSR_FP) {
@@ -654,7 +656,7 @@ int sys_rt_sigreturn(unsigned long r3, unsigned long r4, unsigned long r5,
654656
#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
655657
if (__get_user(msr, &uc->uc_mcontext.gp_regs[PT_MSR]))
656658
goto badframe;
657-
if (MSR_TM_SUSPENDED(msr)) {
659+
if (MSR_TM_ACTIVE(msr)) {
658660
/* We recheckpoint on return. */
659661
struct ucontext __user *uc_transact;
660662
if (__get_user(uc_transact, &uc->uc_link))

0 commit comments

Comments
 (0)