Skip to content

Commit 2cf7ea9

Browse files
committed
KVM: VMX: hide flexpriority from guest when disabled at the module level
As of commit 8d860bb ("kvm: vmx: Basic APIC virtualization controls have three settings"), KVM will disable VIRTUALIZE_APIC_ACCESSES when a nested guest writes APIC_BASE MSR and kvm-intel.flexpriority=0, whereas previously KVM would allow a nested guest to enable VIRTUALIZE_APIC_ACCESSES so long as it's supported in hardware. That is, KVM now advertises VIRTUALIZE_APIC_ACCESSES to a guest but doesn't (always) allow setting it when kvm-intel.flexpriority=0, and may even initially allow the control and then clear it when the nested guest writes APIC_BASE MSR, which is decidedly odd even if it doesn't cause functional issues. Hide the control completely when the module parameter is cleared. reported-by: Sean Christopherson <sean.j.christopherson@intel.com> Fixes: 8d860bb ("kvm: vmx: Basic APIC virtualization controls have three settings") Cc: Jim Mattson <jmattson@google.com> Cc: stable@vger.kernel.org Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent fd6b6d9 commit 2cf7ea9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

arch/x86/kvm/vmx.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3589,12 +3589,12 @@ static void nested_vmx_setup_ctls_msrs(struct nested_vmx_msrs *msrs, bool apicv)
35893589
msrs->secondary_ctls_high);
35903590
msrs->secondary_ctls_low = 0;
35913591
msrs->secondary_ctls_high &=
3592-
SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES |
35933592
SECONDARY_EXEC_DESC |
35943593
SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE |
35953594
SECONDARY_EXEC_APIC_REGISTER_VIRT |
35963595
SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY |
35973596
SECONDARY_EXEC_WBINVD_EXITING;
3597+
35983598
/*
35993599
* We can emulate "VMCS shadowing," even if the hardware
36003600
* doesn't support it.
@@ -3651,6 +3651,10 @@ static void nested_vmx_setup_ctls_msrs(struct nested_vmx_msrs *msrs, bool apicv)
36513651
msrs->secondary_ctls_high |=
36523652
SECONDARY_EXEC_UNRESTRICTED_GUEST;
36533653

3654+
if (flexpriority_enabled)
3655+
msrs->secondary_ctls_high |=
3656+
SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES;
3657+
36543658
/* miscellaneous data */
36553659
rdmsr(MSR_IA32_VMX_MISC,
36563660
msrs->misc_low,

0 commit comments

Comments
 (0)