[PATCH 02/17] KVM: x86/mmu: Propagate the return from kvm_zap_all_rmap_sptes() out of __rmap_add()

From: Paolo Bonzini

Date: Fri Dec 04 2026 - 12:59:57 EST


From: Sean Christopherson <seanjc@xxxxxxxxxx>

When recycling all rmaps, propagate the result of kvm_zap_all_rmap_sptes()
out of __rmap_add() instead of unconditionally returning "true", to make it
more obvious why a TLB flush is required. Barring a KVM bug elsewhere that
corrupts the rmaps (mmu_lock is held for write), it's impossible for
kvm_zap_all_rmap_sptes() to return "false". And if rmaps are corrupted,
KVM has far bigger problems then potentially leaving behind stale TLB
entries.

Assuming there are no egregious, fatals bug elsewhere in KVM, no functional
change intended.

Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
Link: https://patch.msgid.link/20261113155010.442816-3-seanjc@xxxxxxxxxx
Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>
---
arch/x86/kvm/mmu/mmu.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index 1fae6743aacd..d21bf4208714 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -1754,10 +1754,9 @@ static bool __rmap_add(struct kvm *kvm,

if (rmap_count > kvm->stat.max_mmu_rmap_size)
kvm->stat.max_mmu_rmap_size = rmap_count;
- if (rmap_count > RMAP_RECYCLE_THRESHOLD) {
- kvm_zap_all_rmap_sptes(kvm, rmap_head);
- return true;
- }
+ if (rmap_count > RMAP_RECYCLE_THRESHOLD)
+ return kvm_zap_all_rmap_sptes(kvm, rmap_head);
+
return false;
}

--
2.56.1