[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251224001249.1041934-1-pbonzini@redhat.com>
Date: Wed, 24 Dec 2025 01:12:44 +0100
From: Paolo Bonzini <pbonzini@...hat.com>
To: linux-kernel@...r.kernel.org,
kvm@...r.kernel.org
Cc: seanjc@...gle.com,
x86@...nel.org
Subject: [PATCH 0/5] x86, fpu/kvm: fix crash with AMX
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
Powered by blists - more mailing lists