Skip to content

Commit 99560c9

Browse files
mrutland-armwilldeacon
authored andcommitted
arm64/fpsimd: signal: Use SMSTOP behaviour in setup_return()
Historically the behaviour of setup_return() was nondeterministic, depending on whether the task's FSIMD/SVE/SME state happened to be live. We fixed most of that in commit: 929fa99 ("arm64/fpsimd: signal: Always save+flush state early") ... but we didn't decide on how clearing PSTATE.SM should behave, and left a TODO comment to that effect. Use the new task_smstop_sm() helper to make this behave as if an SMSTOP instruction was used to exit streaming mode. This would have been the most common behaviour prior to the commit above. Fixes: 40a8e87 ("arm64/sme: Disable ZA and streaming mode when handling signals") Signed-off-by: Mark Rutland <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Marc Zyngier <[email protected]> Cc: Mark Brown <[email protected]> Cc: Will Deacon <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 6ef1d77 commit 99560c9

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

arch/arm64/kernel/signal.c

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,22 +1476,8 @@ static int setup_return(struct pt_regs *regs, struct ksignal *ksig,
14761476

14771477
/* Signal handlers are invoked with ZA and streaming mode disabled */
14781478
if (system_supports_sme()) {
1479-
/*
1480-
* If we were in streaming mode the saved register
1481-
* state was SVE but we will exit SM and use the
1482-
* FPSIMD register state.
1483-
*
1484-
* TODO: decide if this should behave as SMSTOP (e.g. reset
1485-
* FPSR + FPMR), or whether this should only clear the scalable
1486-
* registers + ZA state.
1487-
*/
1488-
if (current->thread.svcr & SVCR_SM_MASK) {
1489-
memset(&current->thread.uw.fpsimd_state, 0,
1490-
sizeof(current->thread.uw.fpsimd_state));
1491-
current->thread.fp_type = FP_STATE_FPSIMD;
1492-
}
1493-
1494-
current->thread.svcr &= ~(SVCR_ZA_MASK | SVCR_SM_MASK);
1479+
task_smstop_sm(current);
1480+
current->thread.svcr &= ~SVCR_ZA_MASK;
14951481
write_sysreg_s(0, SYS_TPIDR2_EL0);
14961482
}
14971483

0 commit comments

Comments
 (0)