[PATCH] KVM: x86/mmu: Skip MMIO SPTE invalidation if enable_mmio_caching=0

Dmytro Maluka posted 1 patch 4 months, 2 weeks ago
arch/x86/kvm/mmu/mmu.c | 3 +++
1 file changed, 3 insertions(+)
[PATCH] KVM: x86/mmu: Skip MMIO SPTE invalidation if enable_mmio_caching=0
Posted by Dmytro Maluka 4 months, 2 weeks ago
If MMIO caching is disabled, there are no MMIO SPTEs to invalidate, so
the costly zapping of all pages is unnecessary even in the unlikely case
when the MMIO generation number has wrapped.

Signed-off-by: Dmytro Maluka <dmaluka@chromium.org>
---
 arch/x86/kvm/mmu/mmu.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index 6e838cb6c9e1..bad613e8fa95 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -7339,6 +7339,9 @@ void kvm_mmu_invalidate_mmio_sptes(struct kvm *kvm, u64 gen)
 {
 	WARN_ON_ONCE(gen & KVM_MEMSLOT_GEN_UPDATE_IN_PROGRESS);
 
+	if (!enable_mmio_caching)
+		return;
+
 	gen &= MMIO_SPTE_GEN_MASK;
 
 	/*
-- 
2.51.0.536.g15c5d4f767-goog
Re: [PATCH] KVM: x86/mmu: Skip MMIO SPTE invalidation if enable_mmio_caching=0
Posted by Sean Christopherson 3 months, 3 weeks ago
On Fri, 26 Sep 2025 15:51:39 +0200, Dmytro Maluka wrote:
> If MMIO caching is disabled, there are no MMIO SPTEs to invalidate, so
> the costly zapping of all pages is unnecessary even in the unlikely case
> when the MMIO generation number has wrapped.

Applied to kvm-x86 mmu, thanks!

[1/1] KVM: x86/mmu: Skip MMIO SPTE invalidation if enable_mmio_caching=0
      https://github.com/kvm-x86/linux/commit/b850841a53c5

--
https://github.com/kvm-x86/linux/tree/next