Skip to content

Commit c43ad19

Browse files
sean-jcbonzini
authored andcommitted
KVM: x86: Fully re-initialize supported_vm_types on vendor module load
Recompute the entire set of supported VM types when a vendor module is loaded, as preserving supported_vm_types across vendor module unload and reload can result in VM types being incorrectly treated as supported. E.g. if a vendor module is loaded with TDP enabled, unloaded, and then reloaded with TDP disabled, KVM_X86_SW_PROTECTED_VM will be incorrectly retained. Ditto for SEV_VM and SEV_ES_VM and their respective module params in kvm-amd.ko. Fixes: 2a955c4 ("KVM: x86: Add supported_vm_types to kvm_caps") Signed-off-by: Sean Christopherson <[email protected]> Reviewed-by: Xiaoyao Li <[email protected]> Message-ID: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent aa24865 commit c43ad19

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arch/x86/kvm/x86.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@
9494

9595
struct kvm_caps kvm_caps __read_mostly = {
9696
.supported_mce_cap = MCG_CTL_P | MCG_SER_P,
97-
.supported_vm_types = BIT(KVM_X86_DEFAULT_VM),
9897
};
9998
EXPORT_SYMBOL_GPL(kvm_caps);
10099

@@ -9776,6 +9775,8 @@ int kvm_x86_vendor_init(struct kvm_x86_init_ops *ops)
97769775
if (r)
97779776
goto out_free_percpu;
97789777

9778+
kvm_caps.supported_vm_types = BIT(KVM_X86_DEFAULT_VM);
9779+
97799780
if (boot_cpu_has(X86_FEATURE_XSAVE)) {
97809781
host_xcr0 = xgetbv(XCR_XFEATURE_ENABLED_MASK);
97819782
kvm_caps.supported_xcr0 = host_xcr0 & KVM_SUPPORTED_XCR0;

0 commit comments

Comments
 (0)