• Sean Christopherson's avatar
    KVM: nVMX: Query current VMCS when determining if MSR bitmaps are in use · 7dfbc624
    Sean Christopherson authored
    Check the current VMCS controls to determine if an MSR write will be
    intercepted due to MSR bitmaps being disabled.  In the nested VMX case,
    KVM will disable MSR bitmaps in vmcs02 if they're disabled in vmcs12 or
    if KVM can't map L1's bitmaps for whatever reason.
    
    Note, the bad behavior is relatively benign in the current code base as
    KVM sets all bits in vmcs02's MSR bitmap by default, clears bits if and
    only if L0 KVM also disables interception of an MSR, and only uses the
    buggy helper for MSR_IA32_SPEC_CTRL.  Because KVM explicitly tests WRMSR
    before disabling interception of MSR_IA32_SPEC_CTRL, the flawed check
    will only result in KVM reading MSR_IA32_SPEC_CTRL from hardware when it
    isn't strictly necessary.
    
    Tag the fix for stable in case a future fix wants to use
    msr_write_intercepted(), in which case a buggy implementation in older
    kernels could prove subtly problematic.
    
    Fixes: d28b387f ("KVM/VMX: Allow direct access to MSR_IA32_SPEC_CTRL")
    Cc: stable@vger.kernel.org
    Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
    Message-Id: <20211109013047.2041518-2-seanjc@google.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    7dfbc624
vmx.c 225 KB