From: Paolo Bonzini <pbonzini@redhat.com>
To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: Kyle Zeng <kylebot@openai.com>,
stable@vger.kernel.org, Kevin Liu <kevin.liu@openai.com>,
Stefan Teodorescu <fane@google.com>,
Ulfar Erlingsson <ulfar@google.com>,
Sean Christopherson <seanjc@google.com>
Subject: [PATCH 6.18.y 07/17] KVM: x86/mmu: Flush all TLB entries, not a precise range, when yielding
Date: Fri, 4 Dec 2026 19:00:49 +0100 [thread overview]
Message-ID: <20261204180059.2165490-8-pbonzini@redhat.com> (raw)
In-Reply-To: <20261204180059.2165490-1-pbonzini@redhat.com>
From: Kyle Zeng <kylebot@openai.com>
[ Upstream commit dc3709f44c9617c9fa6d5d0e71dc5b82f47a57b7 ]
Flush *all* TLB entries, not just the currently visible range of GFNs, when
yielding and dropping mmu_lock the shadow MMU, as a pending flush may cover
a bigger range than what is currently in scope, e.g. from a different
memslot or from a different page-table level. Flushing only the range of
GFNs that are directly relevant to the current slot+level result in KVM
failing to TLB flush entries for previously-zapped SPTEs when running on
Hyper-V (the only time the range-based flushing is used).
Fixes: f285c633cb6d ("kvm: mmu: Used range based flushing in slot_handle_level_range")
Cc: stable@vger.kernel.org
Reported-by: Kevin Liu <kevin.liu@openai.com>
Reported-by: Stefan Teodorescu <fane@google.com>
Reported-by: Ulfar Erlingsson <ulfar@google.com>
Signed-off-by: Kyle Zeng <kylebot@openai.com>
[sean: split to separate patch, write changelog, rewrite comment, add more reporters]
Signed-off-by: Sean Christopherson <seanjc@google.com>
Link: https://patch.msgid.link/20261119172647.64295-4-seanjc@google.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
arch/x86/kvm/mmu/mmu.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index 8c9285779eac..c976f44f7c46 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -1598,8 +1598,12 @@ static __always_inline bool __walk_slot_rmaps(struct kvm *kvm,
if (need_resched() || rwlock_needbreak(&kvm->mmu_lock)) {
if (flush && flush_on_yield) {
- kvm_flush_remote_tlbs_range(kvm, start_gfn,
- iterator.gfn - start_gfn + 1);
+ /*
+ * DO NOT do a range-based flush, as the caller
+ * may be zapping a range greater than what is
+ * visible here!
+ */
+ kvm_flush_remote_tlbs(kvm);
flush = false;
}
cond_resched_rwlock_write(&kvm->mmu_lock);
--
2.56.1
next prev parent reply other threads:[~2026-12-04 18:01 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 18:00 [PATCH 6.18.y 00/17] Fixes for various (mostly x86) KVM vulnerabilities Paolo Bonzini
2026-12-04 18:00 ` [PATCH 6.18.y 01/17] KVM: x86: Grab lapic_timer in a local variable to cleanup periodic code Paolo Bonzini
2026-12-04 18:00 ` [PATCH 6.18.y 02/17] KVM: x86/mmu: Flush TLBs if child SPTE is zapped when splitting a huge SPTE Paolo Bonzini
2026-12-05 12:48 ` Sasha Levin
2026-12-04 18:00 ` [PATCH 6.18.y 03/17] KVM: x86/mmu: Propagate the return from kvm_zap_all_rmap_sptes() out of __rmap_add() Paolo Bonzini
2026-12-04 18:00 ` [PATCH 6.18.y 04/17] KVM: x86: Disable hypervisor (VMX Preemption) timer if TSC deadline wraps Paolo Bonzini
2026-12-04 18:00 ` [PATCH 6.18.y 05/17] KVM: x86: Reset local APIC timer metadata on RESET, INIT, and KVM_SET_LAPIC Paolo Bonzini
2026-12-04 18:00 ` [PATCH 6.18.y 06/17] LoongArch: KVM: Flush TLBs *before* dropping mmu_lock Paolo Bonzini
2026-12-04 18:00 ` Paolo Bonzini [this message]
2026-12-04 18:00 ` [PATCH 6.18.y 08/17] KVM: x86/mmu: Flush TLBs in kvm_unmap_gfn_range() if the unmap may block/yield Paolo Bonzini
2026-12-04 18:00 ` [PATCH 6.18.y 09/17] KVM: x86/xen: Pin kvm->mm prior to borrowing mm when setting event channel Paolo Bonzini
2026-12-04 18:00 ` [PATCH 6.18.y 10/17] KVM: Fold kvm_flush_shadow_all() into kvm_mmu_notifier_release() Paolo Bonzini
2026-12-04 18:00 ` [PATCH 6.18.y 11/17] KVM: WARN if there are in-flight memslot updates when a VM's process exits Paolo Bonzini
2026-12-04 18:00 ` [PATCH 6.18.y 12/17] KVM: Set mn_active_invalidate_count when the VM's mm is released Paolo Bonzini
2026-12-04 18:00 ` [PATCH 6.18.y 13/17] KVM: Invalidate all GFN=>PFN caches when VM and/or its process is dying Paolo Bonzini
2026-12-04 18:00 ` [PATCH 6.18.y 14/17] x86/fpu: Bail early from guest XFD update if XFD isn't supported Paolo Bonzini
2026-12-04 18:00 ` [PATCH 6.18.y 15/17] x86/fpu: Clear XSTATE_BV[i] in guest XSAVE state if guest FPU isn't in-use Paolo Bonzini
2026-12-04 18:00 ` [PATCH 6.18.y 16/17] x86/fpu: Ensure guest FPU is resident in hardware when updating actual XFD MSR Paolo Bonzini
2026-12-04 18:00 ` [PATCH 6.18.y 17/17] KVM: VMX: Ensure pCPU is valid before sending IPI to deliver posted IRQ Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261204180059.2165490-8-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=fane@google.com \
--cc=kevin.liu@openai.com \
--cc=kvm@vger.kernel.org \
--cc=kylebot@openai.com \
--cc=linux-kernel@vger.kernel.org \
--cc=seanjc@google.com \
--cc=stable@vger.kernel.org \
--cc=ulfar@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®