Skip to content

Commit 2e990e6

Browse files
brooniectmarinas
authored andcommitted
arm64/sme: Fix EFI save/restore
The EFI save/restore code is confused. When saving the check for saving FFR is inverted due to confusion with the streaming mode check, and when restoring we check if we need to restore FFR by checking the percpu efi_sm_state without the required wrapper rather than based on the combination of FA64 support and streaming mode. Fixes: e0838f6 ("arm64/sme: Save and restore streaming mode over EFI runtime calls") Reported-by: kernel test robot <[email protected]> Reviewed-by: Catalin Marinas <[email protected]> Signed-off-by: Mark Brown <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent bb31451 commit 2e990e6

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

arch/arm64/kernel/fpsimd.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1916,10 +1916,15 @@ void __efi_fpsimd_begin(void)
19161916
if (system_supports_sme()) {
19171917
svcr = read_sysreg_s(SYS_SVCR);
19181918

1919-
if (!system_supports_fa64())
1920-
ffr = svcr & SVCR_SM_MASK;
1919+
__this_cpu_write(efi_sm_state,
1920+
svcr & SVCR_SM_MASK);
19211921

1922-
__this_cpu_write(efi_sm_state, ffr);
1922+
/*
1923+
* Unless we have FA64 FFR does not
1924+
* exist in streaming mode.
1925+
*/
1926+
if (!system_supports_fa64())
1927+
ffr = !(svcr & SVCR_SM_MASK);
19231928
}
19241929

19251930
sve_save_state(sve_state + sve_ffr_offset(sve_max_vl()),
@@ -1964,8 +1969,13 @@ void __efi_fpsimd_end(void)
19641969
sysreg_clear_set_s(SYS_SVCR,
19651970
0,
19661971
SVCR_SM_MASK);
1972+
1973+
/*
1974+
* Unless we have FA64 FFR does not
1975+
* exist in streaming mode.
1976+
*/
19671977
if (!system_supports_fa64())
1968-
ffr = efi_sm_state;
1978+
ffr = false;
19691979
}
19701980
}
19711981

0 commit comments

Comments
 (0)