提交 81802f29 编写于 作者: M Mark Brown 提交者: Wang ShaoBo

arm64/sme: Fix EFI save/restore

mainline inclusion
from mainline-v5.19-rc2
commit 2e990e63
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I5ITJT
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=2e990e63220bb01e2755b55b93878ce7c8cbe747

-------------------------------------------------

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: e0838f63 ("arm64/sme: Save and restore streaming mode over EFI runtime calls")
Reported-by: Nkernel test robot <lkp@intel.com>
Reviewed-by: NCatalin Marinas <catalin.marinas@arm.com>
Signed-off-by: NMark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20220602124132.3528951-1-broonie@kernel.orgSigned-off-by: NCatalin Marinas <catalin.marinas@arm.com>
Signed-off-by: NWang ShaoBo <bobo.shaobowang@huawei.com>
上级 449de05f
...@@ -1877,10 +1877,15 @@ void __efi_fpsimd_begin(void) ...@@ -1877,10 +1877,15 @@ void __efi_fpsimd_begin(void)
if (system_supports_sme()) { if (system_supports_sme()) {
svcr = read_sysreg_s(SYS_SVCR); svcr = read_sysreg_s(SYS_SVCR);
if (!system_supports_fa64()) __this_cpu_write(efi_sm_state,
ffr = svcr & SVCR_SM_MASK; 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()), sve_save_state(sve_state + sve_ffr_offset(sve_max_vl()),
...@@ -1925,8 +1930,13 @@ void __efi_fpsimd_end(void) ...@@ -1925,8 +1930,13 @@ void __efi_fpsimd_end(void)
sysreg_clear_set_s(SYS_SVCR, sysreg_clear_set_s(SYS_SVCR,
0, 0,
SVCR_SM_MASK); SVCR_SM_MASK);
/*
* Unless we have FA64 FFR does not
* exist in streaming mode.
*/
if (!system_supports_fa64()) if (!system_supports_fa64())
ffr = efi_sm_state; ffr = false;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册