[PATCH 0/2] KVM: x86: Do runtime updates during KVM_SET_CPUID2

From: Sean Christopherson

Date: Mon Dec 01 2025 - 20:51:29 EST


Do runtime updates (if necessary) when userspace sets CPUID to fix a bug
where KVM drops a pending update (KVM will clear the dirty flag when doing
updates on the new/incoming CPUID). The bug most visibly manifests as an
-EINVAL failure on KVM_SET_CPUID{,2} due to the old/current CPUID not
matching the new/incoming CPUID, but if userspace were to continue running
past the failure, the vCPU would run with stale CPUID/caps.

Sean Christopherson (2):
KVM: x86: Apply runtime updates to current CPUID during
KVM_SET_CPUID{,2}
KVM: selftests: Add a CPUID testcase for KVM_SET_CPUID2 with runtime
updates

arch/x86/kvm/cpuid.c | 11 +++++++++--
tools/testing/selftests/kvm/x86/cpuid_test.c | 15 +++++++++++++++
2 files changed, 24 insertions(+), 2 deletions(-)


base-commit: 115d5de2eef32ac5cd488404b44b38789362dbe6
--
2.52.0.107.ga0afd4fd5b-goog