Skip to content

Commit ae7aaec

Browse files
npigginmpe
authored andcommitted
powerpc/64s: system call rfscv workaround for TM bugs
The rfscv instruction does not work correctly with the fake-suspend mode in POWER9, which can end up with the hypervisor restoring an incorrect checkpoint. Work around this by setting the _TIF_RESTOREALL flag if a system call returns to a transaction active state, causing rfid to be used instead of rfscv to return, which will do the right thing. The contents of the registers are irrelevant because they will be overwritten in this case anyway. Fixes: 7fa95f9 ("powerpc/64s: system call support for scv/rfscv instructions") Reported-by: Eirik Fuller <[email protected]> Signed-off-by: Nicholas Piggin <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 5379ef2 commit ae7aaec

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

arch/powerpc/kernel/interrupt.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,19 @@ notrace long system_call_exception(long r3, long r4, long r5,
137137
*/
138138
irq_soft_mask_regs_set_state(regs, IRQS_ENABLED);
139139

140+
/*
141+
* If system call is called with TM active, set _TIF_RESTOREALL to
142+
* prevent RFSCV being used to return to userspace, because POWER9
143+
* TM implementation has problems with this instruction returning to
144+
* transactional state. Final register values are not relevant because
145+
* the transaction will be aborted upon return anyway. Or in the case
146+
* of unsupported_scv SIGILL fault, the return state does not much
147+
* matter because it's an edge case.
148+
*/
149+
if (IS_ENABLED(CONFIG_PPC_TRANSACTIONAL_MEM) &&
150+
unlikely(MSR_TM_TRANSACTIONAL(regs->msr)))
151+
current_thread_info()->flags |= _TIF_RESTOREALL;
152+
140153
/*
141154
* If the system call was made with a transaction active, doom it and
142155
* return without performing the system call. Unless it was an

0 commit comments

Comments
 (0)