]> www.infradead.org Git - users/dwmw2/linux.git/commit
KVM: x86/mmu: Add dedicated helper to zap TDP MMU root shadow page
authorSean Christopherson <seanjc@google.com>
Sat, 26 Feb 2022 00:15:33 +0000 (00:15 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 2 Mar 2022 18:00:28 +0000 (13:00 -0500)
commit75501314d47ec7839ce3d3ee701ee8b7533e12cd
treec0473b2b8836016f30ae67f9b8a6b04cfa887676
parent8df5415c02edce3cf0b1c22237c56ebe8d57de40
KVM: x86/mmu: Add dedicated helper to zap TDP MMU root shadow page

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: Sean Christopherson <seanjc@google.com>
Reviewed-by: Ben Gardon <bgardon@google.com>
Message-Id: <20220226001546.360188-16-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/mmu/tdp_mmu.c