[PATCH 1/2] KVM: VMX: Fix x2APIC MSR intercept handling on !APICV platforms

From: Sean Christopherson
Date: Mon Oct 05 2020 - 15:55:54 EST


From: Peter Xu <peterx@xxxxxxxxxx>

Fix an inverted flag for intercepting x2APIC MSRs and intercept writes
by default, even when APICV is enabled.

Fixes: 3eb900173c71 ("KVM: x86: VMX: Prevent MSR passthrough when MSR access is denied")
Not-signed-off-by: Peter Xu <peterx@xxxxxxxxxx>
[sean: added changelog]
Signed-off-by: Sean Christopherson <sean.j.christopherson@xxxxxxxxx>
---
arch/x86/kvm/vmx/vmx.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 4551a7e80ebc..25ef0b22ac9e 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -3787,9 +3787,10 @@ static void vmx_update_msr_bitmap_x2apic(struct kvm_vcpu *vcpu, u8 mode)
int msr;

for (msr = 0x800; msr <= 0x8ff; msr++) {
- bool intercepted = !!(mode & MSR_BITMAP_MODE_X2APIC_APICV);
+ bool apicv = !!(mode & MSR_BITMAP_MODE_X2APIC_APICV);

- vmx_set_intercept_for_msr(vcpu, msr, MSR_TYPE_RW, intercepted);
+ vmx_set_intercept_for_msr(vcpu, msr, MSR_TYPE_R, !apicv);
+ vmx_set_intercept_for_msr(vcpu, msr, MSR_TYPE_W, true);
}

if (mode & MSR_BITMAP_MODE_X2APIC) {
--
2.28.0