Re: [PATCH 0/4] KVM: x86/mmu: Don't sync cached roots created for a different MMU context
From: Yosry Ahmed
Date: Fri Dec 04 2026 - 15:12:53 EST
On Fri, Dec 04, 2026 at 11:22:10AM -0800, Sean Christopherson wrote:
> On Thu, Dec 03, 2026, Yosry Ahmed wrote:
> > On Tue, Oct 13, 2026 at 4:17 PM Yosry Ahmed <yosry@xxxxxxxxxx> wrote:
> > >
> > > When invalidating an address, KVM walks and syncs cached roots using the
> > > current MMU context, but cached roots may have been created for a
> > > different context after a nested transition. With TDP disabled, this
> > > lets a guest trigger a BUG_ON() and crash the host (see patch 3 for
> > > details).
> > >
> > > Patch 1 downgrades the BUG_ON() to a WARN_ON_ONCE(), patch 2 is prep
> > > work, patch 3 is the fix, and patch 4 drops a TODO that isn't worth
> > > pursuing.
> > >
> > > Sashiko flagged the issue while reviewing the INVLPGA emulation patch in
> > > my nested SVM TLB series [1]. The host crash is easy to reproduce with an
> > > AI-generated repro (with TDP disabled), and no longer triggers with this
> > > series.
> > >
> > > [1] https://lore.kernel.org/kvm/sashiko-outbox-163479@xxxxxxxxxx/
> > >
> > > Yosry Ahmed (4):
> > > KVM: x86/mmu: WARN, don't BUG, when walking a cached root with a PAE
> > > MMU
> > > KVM: x86/mmu: Drop for_each_shadow_entry_using_root()
> > > KVM: x86/mmu: Don't sync cached roots created for a different MMU
> > > context
> > > KVM: nVMX: Drop the TODO to sync only the affected SPTEs for INVVPID
> >
> > Do I need to send a new version for this?
>
> No, just give me a comment for patch 1 I can squash.
This?
diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index 0b78c56f771b7..9289c7cd836b3 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -2576,10 +2576,7 @@ static void shadow_walk_init_using_root(struct kvm_shadow_walk_iterator *iterato
iterator->level = PT32E_ROOT_LEVEL;
if (iterator->level == PT32E_ROOT_LEVEL) {
- /*
- * prev_root is currently only used for 64-bit hosts. So only
- * the active root_hpa is valid here.
- */
+ /* PAE roots aren't cached, so only the active root is valid here */
if (WARN_ON_ONCE(root != vcpu->arch.mmu->root.hpa))
goto error;