[PATCH 10/17] KVM: Fold kvm_flush_shadow_all() into kvm_mmu_notifier_release()

From: Paolo Bonzini

Date: Fri Dec 04 2026 - 13:00:17 EST


From: Sean Christopherson <seanjc@xxxxxxxxxx>

Fold kvm_flush_shadow_all() into kvm_mmu_notifier_release() now that all
all architectures use the generic mmu_notifier, i.e. all flow through
.release() when the VM and/or process is dying. This will allow setting
mn_active_invalidate_count and _leaving_ it set when all SPTEs are zapped,
without having to worry about hypothetical scenarios where future KVM could
invoke kvm_flush_shadow_all() prior to the VM/process dying.

No functional change intended.

Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
Link: https://patch.msgid.link/20261120195742.55768-3-seanjc@xxxxxxxxxx
Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>
---
virt/kvm/kvm_main.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 83e727bf6452..4f62287d4dd9 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -346,12 +346,6 @@ void kvm_flush_remote_tlbs_memslot(struct kvm *kvm,
kvm_flush_remote_tlbs_range(kvm, memslot->base_gfn, memslot->npages);
}

-static void kvm_flush_shadow_all(struct kvm *kvm)
-{
- kvm_arch_flush_shadow_all(kvm);
- kvm_arch_guest_memory_reclaimed(kvm);
-}
-
#ifdef KVM_ARCH_NR_OBJS_PER_MEMORY_CACHE
static inline void *mmu_memory_cache_alloc_obj(struct kvm_mmu_memory_cache *mc,
gfp_t gfp_flags)
@@ -889,7 +883,8 @@ static void kvm_mmu_notifier_release(struct mmu_notifier *mn,
int idx;

idx = srcu_read_lock(&kvm->srcu);
- kvm_flush_shadow_all(kvm);
+ kvm_arch_flush_shadow_all(kvm);
+ kvm_arch_guest_memory_reclaimed(kvm);
srcu_read_unlock(&kvm->srcu, idx);
}

--
2.56.1