• Sean Christopherson's avatar
    KVM: x86/mmu: Don't freak out if pml5_root is NULL on 4-level host · a717a780
    Sean Christopherson authored
    Include pml5_root in the set of special roots if and only if the host,
    and thus NPT, is using 5-level paging.  mmu_alloc_special_roots() expects
    special roots to be allocated as a bundle, i.e. they're either all valid
    or all NULL.  But for pml5_root, that expectation only holds true if the
    host uses 5-level paging, which causes KVM to WARN about pml5_root being
    NULL when the other special roots are valid.
    
    The silver lining of 4-level vs. 5-level NPT being tied to the host
    kernel's paging level is that KVM's shadow root level is constant; unlike
    VMX's EPT, KVM can't choose 4-level NPT based on guest.MAXPHYADDR.  That
    means KVM can still expect pml5_root to be bundled with the other special
    roots, it just needs to be conditioned on the shadow root level.
    
    Fixes: cb0f722a ("KVM: x86/mmu: Support shadowing NPT when 5-level paging is enabled in host")
    Reported-by: default avatarMaxim Levitsky <mlevitsk@redhat.com>
    Reviewed-by: default avatarMaxim Levitsky <mlevitsk@redhat.com>
    Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
    Message-Id: <20210824005824.205536-1-seanjc@google.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    a717a780
mmu.c 167 KB