• David Matlack's avatar
    KVM: nVMX: fix checks on CR{0,4} during virtual VMX operation · 3899152c
    David Matlack authored
    KVM emulates MSR_IA32_VMX_CR{0,4}_FIXED1 with the value -1ULL, meaning
    all CR0 and CR4 bits are allowed to be 1 during VMX operation.
    
    This does not match real hardware, which disallows the high 32 bits of
    CR0 to be 1, and disallows reserved bits of CR4 to be 1 (including bits
    which are defined in the SDM but missing according to CPUID). A guest
    can induce a VM-entry failure by setting these bits in GUEST_CR0 and
    GUEST_CR4, despite MSR_IA32_VMX_CR{0,4}_FIXED1 indicating they are
    valid.
    
    Since KVM has allowed all bits to be 1 in CR0 and CR4, the existing
    checks on these registers do not verify must-be-0 bits. Fix these checks
    to identify must-be-0 bits according to MSR_IA32_VMX_CR{0,4}_FIXED1.
    
    This patch should introduce no change in behavior in KVM, since these
    MSRs are still -1ULL.
    Signed-off-by: default avatarDavid Matlack <dmatlack@google.com>
    Signed-off-by: default avatarRadim Krčmář <rkrcmar@redhat.com>
    3899152c
vmx.c 326 KB