linux-stable/arch
Adamos Ttofari b61e3b7055 x86/fpu: Keep xfd_state in sync with MSR_IA32_XFD
[ Upstream commit 10e4b5166d ]

Commit 672365477a ("x86/fpu: Update XFD state where required") and
commit 8bf26758ca ("x86/fpu: Add XFD state to fpstate") introduced a
per CPU variable xfd_state to keep the MSR_IA32_XFD value cached, in
order to avoid unnecessary writes to the MSR.

On CPU hotplug MSR_IA32_XFD is reset to the init_fpstate.xfd, which
wipes out any stale state. But the per CPU cached xfd value is not
reset, which brings them out of sync.

As a consequence a subsequent xfd_update_state() might fail to update
the MSR which in turn can result in XRSTOR raising a #NM in kernel
space, which crashes the kernel.

To fix this, introduce xfd_set_state() to write xfd_state together
with MSR_IA32_XFD, and use it in all places that set MSR_IA32_XFD.

Fixes: 672365477a ("x86/fpu: Update XFD state where required")
Signed-off-by: Adamos Ttofari <attofari@amazon.de>
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20240322230439.456571-1-chang.seok.bae@intel.com

Closes: https://lore.kernel.org/lkml/20230511152818.13839-1-attofari@amazon.de
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-04-03 15:32:34 +02:00
..
alpha RTC for 6.8 2024-01-18 17:25:39 -08:00
arc work around gcc bugs with 'asm goto' with outputs 2024-02-09 15:57:48 -08:00
arm ARM: 9359/1: flush: check if the folio is reserved for no-mapping addresses 2024-04-03 15:32:33 +02:00
arm64 arm64: dts: qcom: sm8550-mtp: correct WCD9385 TX port mapping 2024-04-03 15:32:03 +02:00
csky work around gcc bugs with 'asm goto' with outputs 2024-02-09 15:57:48 -08:00
hexagon asm-generic cleanups for 6.8 2024-01-10 18:13:44 -08:00
loongarch LoongArch/crypto: Clean up useless assignment operations 2024-04-03 15:32:25 +02:00
m68k kbuild: use 4-space indentation when followed by conditionals 2024-02-15 06:05:44 +09:00
microblaze Microblaze patches for 6.8-rc1 2024-01-17 11:27:23 -08:00
mips mips: cm: Convert __mips_cm_l2sync_phys_base() to weak function 2024-03-26 18:17:21 -04:00
nios2 percpu: 2024-01-18 15:01:28 -08:00
openrisc
parisc parisc: Strip upper 32 bit of sum in csum_ipv6_magic for 64-bit builds 2024-04-03 15:32:08 +02:00
powerpc powerpc: xor_vmx: Add '-mhard-float' to CFLAGS 2024-04-03 15:32:14 +02:00
riscv riscv: Fix compilation error with FAST_GUP and rv32 2024-03-26 18:17:34 -04:00
s390 s390/vtime: fix average steal time calculation 2024-03-26 18:17:32 -04:00
sh sh updates for v6.8 2024-01-20 09:24:06 -08:00
sparc sparc32: Fix parport build with sparc32 2024-04-03 15:32:17 +02:00
um work around gcc bugs with 'asm goto' with outputs 2024-02-09 15:57:48 -08:00
x86 x86/fpu: Keep xfd_state in sync with MSR_IA32_XFD 2024-04-03 15:32:34 +02:00
xtensa work around gcc bugs with 'asm goto' with outputs 2024-02-09 15:57:48 -08:00
.gitignore
Kconfig scs: add CONFIG_MMU dependency for vfree_atomic() 2024-01-25 23:52:21 -08:00