• S
    KVM: x86/mmu: Add dedicated helper to zap TDP MMU root shadow page · e2b5b21d
    Sean Christopherson 提交于
    Add a dedicated helper for zapping a TDP MMU root, and use it in the three
    flows that do "zap_all" and intentionally do not do a TLB flush if SPTEs
    are zapped (zapping an entire root is safe if and only if it cannot be in
    use by any vCPU).  Because a TLB flush is never required, unconditionally
    pass "false" to tdp_mmu_iter_cond_resched() when potentially yielding.
    
    Opportunistically document why KVM must not yield when zapping roots that
    are being zapped by kvm_tdp_mmu_put_root(), i.e. roots whose refcount has
    reached zero, and further harden the flow to detect improper KVM behavior
    with respect to roots that are supposed to be unreachable.
    
    In addition to hardening zapping of roots, isolating zapping of roots
    will allow future simplification of zap_gfn_range() by having it zap only
    leaf SPTEs, and by removing its tricky "zap all" heuristic.  By having
    all paths that truly need to free _all_ SPs flow through the dedicated
    root zapper, the generic zapper can be freed of those concerns.
    Signed-off-by: NSean Christopherson <seanjc@google.com>
    Reviewed-by: NBen Gardon <bgardon@google.com>
    Message-Id: <20220226001546.360188-16-seanjc@google.com>
    Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
    e2b5b21d
tdp_mmu.c 54.6 KB