public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] x86, fpu/kvm: fix crash with AMX
@ 2025-12-24  0:12 Paolo Bonzini
  2025-12-24  0:12 ` [PATCH 1/5] x86, fpu: introduce fpu_load_guest_fpstate() Paolo Bonzini
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: Paolo Bonzini @ 2025-12-24  0:12 UTC (permalink / raw)
  To: linux-kernel, kvm; +Cc: seanjc, x86

Fix a possible host panic, due to an unexpected #NM, when a KVM guest
is using AMX features.

The guest's XFD value, which is stored in fpstate->xfd, is used for both
guest execution and host XSAVE operations.  However, the guest-configured
XFD setting can disable features that the host needs enabled to successfully
XRSTOR the guest FPU state.

The first patch replaces inline code in vcpu_enter_guest() with a new
function exported by kernel/fpu.  The new function is similar to
fpregs_lock_and_load() but operates with preemption disabled and
also restores the extra state (currently xfd_err) in struct guest_fpu.

The second patch then introduces a new xfd field in struct guest_fpu,
so that the guest's XFD setting can be swapped while leaving the host
value untouched in fpstate->xfd.

Patches 3 and 4 introduce a test.

Patch 5 makes KVM use fpregs_lock_and_load(), exporting it in place of
two lower-level functions whose other uses are now gone.

Reviews and acks are welcome (this could go in through either
the x86 or KVM trees).

Paolo


Paolo Bonzini (5):
  x86, fpu: introduce fpu_load_guest_fpstate()
  x86, fpu: separate fpstate->xfd and guest XFD
  selftests: kvm: renumber some sync points in amx_test
  selftests, kvm: try getting XFD and XSAVE state out of sync
  KVM: x86: kvm_fpu_get() is fpregs_lock_and_load()

 arch/x86/include/asm/fpu/api.h             |  7 ++--
 arch/x86/include/asm/fpu/types.h           |  7 ++++
 arch/x86/kernel/fpu/core.c                 | 38 ++++++++++-------
 arch/x86/kernel/fpu/xstate.h               | 18 ++++----
 arch/x86/kvm/fpu.h                         |  6 +--
 arch/x86/kvm/x86.c                         | 14 ++-----
 tools/testing/selftests/kvm/x86/amx_test.c | 49 +++++++++++++++-------
 7 files changed, 82 insertions(+), 57 deletions(-)

-- 
2.52.0


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2025-12-29 23:53 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-24  0:12 [PATCH 0/5] x86, fpu/kvm: fix crash with AMX Paolo Bonzini
2025-12-24  0:12 ` [PATCH 1/5] x86, fpu: introduce fpu_load_guest_fpstate() Paolo Bonzini
2025-12-26  6:51   ` Yao Yuan
2025-12-29 15:58     ` Sean Christopherson
2025-12-29 22:56       ` Paolo Bonzini
2025-12-24  0:12 ` [PATCH 2/5] x86, fpu: separate fpstate->xfd and guest XFD Paolo Bonzini
2025-12-25 22:52   ` Yao Yuan
2025-12-29 22:45   ` Sean Christopherson
2025-12-29 23:31     ` Paolo Bonzini
2025-12-29 23:46       ` Sean Christopherson
2025-12-24  0:12 ` [PATCH 3/5] selftests: kvm: renumber some sync points in amx_test Paolo Bonzini
2025-12-29 23:34   ` Sean Christopherson
2025-12-24  0:12 ` [PATCH 4/5] selftests, kvm: try getting XFD and XSAVE state out of sync Paolo Bonzini
2025-12-24  0:12 ` [PATCH 5/5] KVM: x86: kvm_fpu_get() is fpregs_lock_and_load() Paolo Bonzini
2025-12-29 23:53   ` Sean Christopherson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox