lkml.org 
[lkml]   [2022]   [Aug]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.15 026/779] KVM: nVMX: Account for KVM reserved CR4 bits in consistency checks
    Date
    From: Sean Christopherson <seanjc@google.com>

    commit ca58f3aa53d165afe4ab74c755bc2f6d168617ac upstream.

    Check that the guest (L2) and host (L1) CR4 values that would be loaded
    by nested VM-Enter and VM-Exit respectively are valid with respect to
    KVM's (L0 host) allowed CR4 bits. Failure to check KVM reserved bits
    would allow L1 to load an illegal CR4 (or trigger hardware VM-Fail or
    failed VM-Entry) by massaging guest CPUID to allow features that are not
    supported by KVM. Amusingly, KVM itself is an accomplice in its doom, as
    KVM adjusts L1's MSR_IA32_VMX_CR4_FIXED1 to allow L1 to enable bits for
    L2 based on L1's CPUID model.

    Note, although nested_{guest,host}_cr4_valid() are _currently_ used if
    and only if the vCPU is post-VMXON (nested.vmxon == true), that may not
    be true in the future, e.g. emulating VMXON has a bug where it doesn't
    check the allowed/required CR0/CR4 bits.

    Cc: stable@vger.kernel.org
    Fixes: 3899152ccbf4 ("KVM: nVMX: fix checks on CR{0,4} during virtual VMX operation")
    Signed-off-by: Sean Christopherson <seanjc@google.com>
    Message-Id: <20220607213604.3346000-3-seanjc@google.com>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    ---
    arch/x86/kvm/vmx/nested.h | 3 ++-
    1 file changed, 2 insertions(+), 1 deletion(-)

    --- a/arch/x86/kvm/vmx/nested.h
    +++ b/arch/x86/kvm/vmx/nested.h
    @@ -280,7 +280,8 @@ static inline bool nested_cr4_valid(stru
    u64 fixed0 = to_vmx(vcpu)->nested.msrs.cr4_fixed0;
    u64 fixed1 = to_vmx(vcpu)->nested.msrs.cr4_fixed1;

    - return fixed_bits_valid(val, fixed0, fixed1);
    + return fixed_bits_valid(val, fixed0, fixed1) &&
    + __kvm_is_valid_cr4(vcpu, val);
    }

    /* No difference in the restrictions on guest and host CR4 in VMX operation. */

    \
     
     \ /
      Last update: 2022-08-15 20:19    [W:4.034 / U:0.528 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site