Skip to content

Commit a0860d6

Browse files
sean-jcbonzini
authored andcommitted
KVM: nVMX: Don't stuff secondary execution control if it's not supported
When stuffing the allowed secondary execution controls for nested VMX in response to CPUID updates, don't set the allowed-1 bit for a feature that isn't supported by KVM, i.e. isn't allowed by the canonical vmcs_config. WARN if KVM attempts to manipulate a feature that isn't supported. All features that are currently stuffed are always advertised to L1 for nested VMX if they are supported in KVM's base configuration, and no additional features should ever be added to the CPUID-induced stuffing (updating VMX MSRs in response to CPUID updates is a long-standing KVM flaw that is slowly being fixed). Signed-off-by: Sean Christopherson <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 31de69f commit a0860d6

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

arch/x86/kvm/vmx/vmx.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4459,6 +4459,13 @@ vmx_adjust_secondary_exec_control(struct vcpu_vmx *vmx, u32 *exec_control,
44594459
* controls for features that are/aren't exposed to the guest.
44604460
*/
44614461
if (nested) {
4462+
/*
4463+
* All features that can be added or removed to VMX MSRs must
4464+
* be supported in the first place for nested virtualization.
4465+
*/
4466+
if (WARN_ON_ONCE(!(vmcs_config.nested.secondary_ctls_high & control)))
4467+
enabled = false;
4468+
44624469
if (enabled)
44634470
vmx->nested.msrs.secondary_ctls_high |= control;
44644471
else

0 commit comments

Comments
 (0)