[PATCH 6.18.y 10/17] KVM: Fold kvm_flush_shadow_all() into kvm_mmu_notifier_release()
From: Paolo Bonzini
Date: Fri Dec 04 2026 - 13:02:09 EST
From: Sean Christopherson <seanjc@xxxxxxxxxx>
[ Upstream commit c9c6a91ce0371a7f951c3d2f2bad7bcead6a4840 ]
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>
Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>
---
virt/kvm/kvm_main.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 723463fe6038..eadd20efad5f 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -338,11 +338,13 @@ void kvm_flush_remote_tlbs_memslot(struct kvm *kvm,
kvm_flush_remote_tlbs_range(kvm, memslot->base_gfn, memslot->npages);
}
+#ifndef CONFIG_KVM_GENERIC_MMU_NOTIFIER
static void kvm_flush_shadow_all(struct kvm *kvm)
{
kvm_arch_flush_shadow_all(kvm);
kvm_arch_guest_memory_reclaimed(kvm);
}
+#endif
#ifdef KVM_ARCH_NR_OBJS_PER_MEMORY_CACHE
static inline void *mmu_memory_cache_alloc_obj(struct kvm_mmu_memory_cache *mc,
@@ -881,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