Skip to content

Commit ea64baa

Browse files
brooniewilldeacon
authored andcommitted
arm64/signal: Flush FPSIMD register state when disabling streaming mode
When handling a signal delivered to a context with streaming mode enabled we will disable streaming mode for the signal handler, when doing so we should also flush the saved FPSIMD register state like exiting streaming mode in the hardware would do so that if that state is reloaded we get the same behaviour. Without this we will reload whatever the last FPSIMD state that was saved for the task was. Fixes: 40a8e87 ("arm64/sme: Disable ZA and streaming mode when handling signals") Signed-off-by: Mark Brown <[email protected]> Reviewed-by: Catalin Marinas <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 7ddcaf7 commit ea64baa

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

arch/arm64/kernel/signal.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,16 @@ static void setup_return(struct pt_regs *regs, struct k_sigaction *ka,
926926

927927
/* Signal handlers are invoked with ZA and streaming mode disabled */
928928
if (system_supports_sme()) {
929+
/*
930+
* If we were in streaming mode the saved register
931+
* state was SVE but we will exit SM and use the
932+
* FPSIMD register state - flush the saved FPSIMD
933+
* register state in case it gets loaded.
934+
*/
935+
if (current->thread.svcr & SVCR_SM_MASK)
936+
memset(&current->thread.uw.fpsimd_state, 0,
937+
sizeof(current->thread.uw.fpsimd_state));
938+
929939
current->thread.svcr &= ~(SVCR_ZA_MASK |
930940
SVCR_SM_MASK);
931941
sme_smstop();

0 commit comments

Comments
 (0)