Skip to contentSkip to conversation

arm64/sme: Fix EFI save/restore

PATCH Superseded Mark Brown 2 participants 2 messages Jun 2, 2022 arm64

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH 1/1 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 e0838f6373e5 ("arm64/sme: Save and restore streaming mode over EFI runtime calls")

---

Compile tested only at this point.

 arch/arm64/kernel/fpsimd.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
arch/arm64/kernel/fpsimd.c +5 -4
index 819979398127..3c66a061ff6f 100644
@@ -1916,10 +1916,11 @@ void __efi_fpsimd_begin(void)
 			if (system_supports_sme()) {
 				svcr = read_sysreg_s(SYS_SVCR);
 
-				if (!system_supports_fa64())
-					ffr = svcr & SVCR_SM_MASK;
+				__this_cpu_write(efi_sm_state,
+						 svcr & SVCR_SM_MASK);
 
-				__this_cpu_write(efi_sm_state, ffr);
+				if (!system_supports_fa64())
+					ffr = !(svcr & SVCR_SM_MASK);
 			}
 
 			sve_save_state(sve_state + sve_ffr_offset(sve_max_vl()),
@@ -1965,7 +1966,7 @@ void __efi_fpsimd_end(void)
 							   0,
 							   SVCR_SM_MASK);
 					if (!system_supports_fa64())
-						ffr = efi_sm_state;
+						ffr = false;
 				}
 			}
 
Signature · 7 lines
2.30.2


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 20 lines · Mark Brown
arch/arm64/kernel/fpsimd.c +4 -3
index 819979398127..3c66a061ff6f 100644
@@ -1916,10 +1916,11 @@ void __efi_fpsimd_begin(void)
 			if (system_supports_sme()) {
 				svcr = read_sysreg_s(SYS_SVCR);
 
-				if (!system_supports_fa64())
-					ffr = svcr & SVCR_SM_MASK;
+				__this_cpu_write(efi_sm_state,
+						 svcr & SVCR_SM_MASK);
 
-				__this_cpu_write(efi_sm_state, ffr);
+				if (!system_supports_fa64())
+					ffr = !(svcr & SVCR_SM_MASK);
 			}
 
 			sve_save_state(sve_state + sve_ffr_offset(sve_max_vl()),

arch/arm64/kernel/fpsimd.c void __efi_fpsimd_end(void) · line 1971

Quoted 7 lines
arch/arm64/kernel/fpsimd.c +1 -1
@@ -1965,7 +1966,7 @@ void __efi_fpsimd_end(void)
 							   0,
 							   SVCR_SM_MASK);
 					if (!system_supports_fa64())
-						ffr = efi_sm_state;
+						ffr = false;
 				}
 			}

This looks fine to me:

Please add some comments to the code for when we need to save/restore the FFR state and let me know when you got a chance to test it so that I can send it upstream.

Thanks.

Signature · 6 lines
Catalin

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel