]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
KVM: x86: Harden against unexpected adjustments to kvm_cpu_caps
authorSean Christopherson <seanjc@google.com>
Wed, 28 Jan 2026 01:43:09 +0000 (17:43 -0800)
committerSean Christopherson <seanjc@google.com>
Fri, 30 Jan 2026 21:28:29 +0000 (13:28 -0800)
commit3f2757dbf32a31cef738a983bde6ecd2641484c0
treeaa572f9fa2da7a7306e2a5e0216923ff188b38fd
parent95d848dc7e639988dbb385a8cba9b484607cf98c
KVM: x86: Harden against unexpected adjustments to kvm_cpu_caps

Add a flag to track when KVM is actively configuring its CPU caps, and
WARN if a cap is set or cleared if KVM isn't in its configuration stage.
Modifying CPU caps after {svm,vmx}_set_cpu_caps() can be fatal to KVM, as
vendor setup code expects the CPU caps to be frozen at that point, e.g.
will do additional configuration based on the caps.

Rename kvm_set_cpu_caps() to kvm_initialize_cpu_caps() to pair with the
new "finalize", and to make it more obvious that KVM's CPU caps aren't
fully configured within the function.

Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@linux.intel.com>
Link: https://patch.msgid.link/20260128014310.3255561-3-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/cpuid.c
arch/x86/kvm/cpuid.h
arch/x86/kvm/svm/svm.c
arch/x86/kvm/vmx/vmx.c