Skip to contentSkip to conversation

arm64/sme: Fix EFI save/restore

PATCH Applied Mark Brown 2 participants 4 messages Jun 2, 2022 – Jun 10, 2022 arm64

lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH v2 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")

---

Still not tested, that won't happen till next week.

v2:
- Add comments saying when we need to save/restore FFR.

 arch/arm64/kernel/fpsimd.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
arch/arm64/kernel/fpsimd.c +14 -4
index 819979398127..b93985a33bed 100644
@@ -1916,10 +1916,15 @@ 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);
+				/*
+				 * Unless we have FA64 FFR does not
+				 * exist in streaming mode.
+				 */
+				if (!system_supports_fa64())
+					ffr = !(svcr & SVCR_SM_MASK);
 			}
 
 			sve_save_state(sve_state + sve_ffr_offset(sve_max_vl()),
@@ -1964,8 +1969,13 @@ void __efi_fpsimd_end(void)
 					sysreg_clear_set_s(SYS_SVCR,
 							   0,
 							   SVCR_SM_MASK);
+
+					/*
+					 * Unless we have FA64 FFR does not
+					 * exist in streaming mode.
+					 */
 					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
#1 lore raw
Quoted 6 lines · Mark Brown

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.

Quoted 7 lines
Fixes e0838f6373e5 ("arm64/sme: Save and restore streaming mode over EFI runtime calls")

---

Still not tested, that won't happen till next week.

Did you get a chance to test this patch?

Signature · 6 lines
Catalin

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
author
#2 lore raw
Quoted 8 lines · Catalin Marinas
Quoted 4 lines · Mark Brown

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

Still not tested, that won't happen till next week.

Did you get a chance to test this patch?

I'm fairly sure it's fine.

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

maintainer Applied
#3 lore raw
In reply to Mark Brown
Quoted 8 lines · Mark Brown

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.

[...]

Applied to arm64 (for-next/fixes), thanks!

[1/1] arm64/sme: Fix EFI save/restore

      https://git.kernel.org/arm64/c/2e990e63220b
Signature · 7 lines
Catalin


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