From: Sean Christopherson <seanjc@google.com>
To: sashiko-reviews@lists.linux.dev
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH 2/4] KVM: x86/mmu: Harden "map private PFN" against unexpected root invalidation
Date: Thu, 6 Aug 2026 15:21:50 -0700 [thread overview]
Message-ID: <anUI_nHNrxV044FY@google.com> (raw)
In-Reply-To: <20260806221418.B08551F000E9@smtp.kernel.org>
On Thu, Aug 06, 2026, sashiko-bot@kernel.org wrote:
> @@ -5184,10 +5184,6 @@ int kvm_tdp_mmu_map_private_pfn(struct kvm_vcpu *vcpu, gfn_t gfn, kvm_pfn_t pfn)
> > if (kvm_gfn_is_write_tracked(kvm, fault.slot, fault.gfn))
> > return -EPERM;
> >
> > - r = kvm_mmu_reload(vcpu);
> > - if (r)
> > - return r;
> > -
> > r = mmu_topup_memory_caches(vcpu, false);
> > if (r)
> > return r;
>
> [Severity: High]
> Since mmu_topup_memory_caches() is outside the loop, but kvm_mmu_reload()
> was moved inside, is it possible for the reload to consume cache items
> when allocating new roots?
>
> If the root is invalid and kvm_mmu_load() allocates new roots, this
> consumes items from mmu_page_header_cache and mmu_shadow_page_cache. When
> execution proceeds to kvm_tdp_mmu_map() expecting fully topped up
> caches, could this lead to a cache underflow and a host warning or panic?
Literally the next patch...
> > @@ -5199,10 +5195,21 @@ int kvm_tdp_mmu_map_private_pfn(struct kvm_vcpu *vcpu, gfn_t gfn, kvm_pfn_t pfn)
> > if (kvm_test_request(KVM_REQ_VM_DEAD, vcpu))
> > return -EIO;
> >
> > + r = kvm_mmu_reload(vcpu);
> > + if (r)
> > + return r;
> > +
> > cond_resched();
> >
> > guard(read_lock)(&kvm->mmu_lock);
> >
> > + /*
> > + * Because slots_lock is held, it should be impossible for roots
> > + * to be invalidated after the initial MMU reload. WARN, but
> > + * continue and re-reload the MMU to try and keep the VM alive.
> > + */
> > + WARN_ON_ONCE(kvm_test_request(KVM_REQ_MMU_FREE_OBSOLETE_ROOTS, vcpu));
> > +
>
> [Severity: Medium]
> The comment mentions "continue and re-reload the MMU", but does this actually
> fall through directly to kvm_tdp_mmu_map() with an obsolete root?
Yes, addressed two patches from now.
> If the mapping succeeds, it might return RET_PF_FIXED. This would exit the
> loop instead of forcing a retry. Should there be a continue statement after
> the WARN_ON_ONCE to enforce the retry behavior described in the comment?
Eh, I'd rather hedge in the changelog.
next prev parent reply other threads:[~2026-08-06 22:21 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 21:40 [PATCH 0/4] KVM: x86/mmu: Fix pre-fault and map private loops Sean Christopherson
2026-08-06 21:40 ` [PATCH 1/4] KVM: x86/mmu: Reload MMU on *every* page pre-fault attempt/iteration Sean Christopherson
2026-08-07 8:58 ` Huang, Kai
2026-08-07 19:04 ` Edgecombe, Rick P
2026-08-07 19:11 ` Sean Christopherson
2026-08-06 21:40 ` [PATCH 2/4] KVM: x86/mmu: Harden "map private PFN" against unexpected root invalidation Sean Christopherson
2026-08-06 22:14 ` sashiko-bot
2026-08-06 22:21 ` Sean Christopherson [this message]
2026-08-07 20:26 ` Edgecombe, Rick P
2026-08-07 22:18 ` Sean Christopherson
2026-08-06 21:40 ` [PATCH 3/4] KVM: x86/mmu: Top-up memory caches when retrying "map private PFN" Sean Christopherson
2026-08-06 21:56 ` sashiko-bot
2026-08-06 22:07 ` Sean Christopherson
2026-08-07 20:38 ` Edgecombe, Rick P
2026-08-07 22:13 ` Sean Christopherson
2026-08-06 21:40 ` [PATCH 4/4] KVM: x86/mmu: Add sanity check to detect stale page faults in " Sean Christopherson
2026-08-06 21:54 ` sashiko-bot
2026-08-06 22:12 ` Sean Christopherson
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=anUI_nHNrxV044FY@google.com \
--to=seanjc@google.com \
--cc=kvm@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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