• Sean Christopherson's avatar
    KVM: x86/mmu: Zap only TDP MMU leafs in zap range and mmu_notifier unmap · f47e5bbb
    Sean Christopherson authored
    Re-introduce zapping only leaf SPTEs in kvm_zap_gfn_range() and
    kvm_tdp_mmu_unmap_gfn_range(), this time without losing a pending TLB
    flush when processing multiple roots (including nested TDP shadow roots).
    Dropping the TLB flush resulted in random crashes when running Hyper-V
    Server 2019 in a guest with KSM enabled in the host (or any source of
    mmu_notifier invalidations, KSM is just the easiest to force).
    
    This effectively revert commits 873dd122
    and fcb93eb6, and thus restores commit
    cf3e2642, plus this delta on top:
    
    bool kvm_tdp_mmu_zap_leafs(struct kvm *kvm, int as_id, gfn_t start, gfn_t end,
            struct kvm_mmu_page *root;
    
            for_each_tdp_mmu_root_yield_safe(kvm, root, as_id)
    -               flush = tdp_mmu_zap_leafs(kvm, root, start, end, can_yield, false);
    +               flush = tdp_mmu_zap_leafs(kvm, root, start, end, can_yield, flush);
    
            return flush;
     }
    
    Cc: Ben Gardon <bgardon@google.com>
    Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
    Tested-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
    Message-Id: <20220325230348.2587437-1-seanjc@google.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    f47e5bbb
tdp_mmu.h 3.16 KB