• Sean Christopherson's avatar
    KVM: x86/mmu: Ensure MMU pages are available when allocating roots · 6e6ec584
    Sean Christopherson authored
    Hold the mmu_lock for write for the entire duration of allocating and
    initializing an MMU's roots.  This ensures there are MMU pages available
    and thus prevents root allocations from failing.  That in turn fixes a
    bug where KVM would fail to free valid PAE roots if a one of the later
    roots failed to allocate.
    
    Add a comment to make_mmu_pages_available() to call out that the limit
    is a soft limit, e.g. KVM will temporarily exceed the threshold if a
    page fault allocates multiple shadow pages and there was only one page
    "available".
    
    Note, KVM _still_ leaks the PAE roots if the guest PDPTR checks fail.
    This will be addressed in a future commit.
    
    Cc: Ben Gardon <bgardon@google.com>
    Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
    Message-Id: <20210305011101.3597423-7-seanjc@google.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    6e6ec584
tdp_mmu.c 38.8 KB