linux-stable/arch/x86
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
..
boot x86/efistub: Call mixed mode boot services on the firmware's stack 2024-04-03 15:32:32 +02:00
coco x86/sev: Fix position dependent variable references in startup code 2024-04-03 15:32:32 +02:00
configs hardening updates for v6.7-rc1 2023-10-30 19:09:55 -10:00
crypto This update includes the following changes: 2024-01-10 12:23:43 -08:00
entry x86/entry_32: Add VERW just before userspace transition 2024-02-19 16:31:46 -08:00
events perf/x86/amd/core: Avoid register reset when CPU is dead 2024-03-26 18:17:27 -04:00
hyperv x86/hyperv: Use per cpu initial stack for vtl context 2024-03-26 18:17:30 -04:00
ia32
include x86/sev: Fix position dependent variable references in startup code 2024-04-03 15:32:32 +02:00
kernel x86/fpu: Keep xfd_state in sync with MSR_IA32_XFD 2024-04-03 15:32:34 +02:00
kvm KVM: x86/xen: inject vCPU upcall vector when local APIC is enabled 2024-04-03 15:32:11 +02:00
lib x86/lib: Revert to _ASM_EXTABLE_UA() for {get,put}_user() fixups 2024-01-29 11:40:41 +01:00
math-emu
mm x86/sev: Fix position dependent variable references in startup code 2024-04-03 15:32:32 +02:00
net Networking changes for 6.8. 2024-01-11 10:07:29 -08:00
pci pci-v6.8-changes 2024-01-17 16:23:17 -08:00
platform x86/cleanups changes for v6.8: 2024-01-08 17:23:32 -08:00
power
purgatory x86/purgatory: Remove LTO flags 2023-09-17 09:49:03 +02:00
ras
realmode x86/cleanups changes for v6.8: 2024-01-08 17:23:32 -08:00
tools x86, relocs: Ignore relocations in .notes section 2024-03-26 18:16:51 -04:00
um This pull request contains the following changes for UML: 2024-01-17 10:44:34 -08:00
video fbdev: Replace fb_pgprotect() with pgprot_framebuffer() 2023-10-12 09:20:46 +02:00
virt x86/mce: Differentiate real hardware #MCs from TDX erratum ones 2023-12-12 08:46:46 -08:00
xen x86/xen: Add some null pointer checking to smp.c 2024-02-12 20:14:52 +01:00
.gitignore
Kbuild
Kconfig x86/Kconfig: Remove CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT 2024-04-03 15:32:32 +02:00
Kconfig.assembler
Kconfig.cpu x86/Kconfig: Transmeta Crusoe is CPU family 5, not 6 2024-02-09 16:28:19 +01:00
Kconfig.debug
Makefile kbuild: use 4-space indentation when followed by conditionals 2024-02-15 06:05:44 +09:00
Makefile.postlink kbuild: remove ARCH_POSTLINK from module builds 2023-10-28 21:10:08 +09:00
Makefile.um
Makefile_32.cpu