From: Sean Christopherson <seanjc@google.com>
To: sashiko-reviews@lists.linux.dev
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v2 2/4] KVM: x86/mmu: Harden "map private PFN" against unexpected root invalidation
Date: Wed, 26 Aug 2026 10:08:34 -0700 [thread overview]
Message-ID: <ao8dkl_JLNLpzSEf@google.com> (raw)
In-Reply-To: <20260826165948.31EBA1F000E9@smtp.kernel.org>
On Wed, Aug 26, 2026, sashiko-bot@kernel.org wrote:
> > diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
> > index 3220f05387b58..1969c26861e5a 100644
> > --- a/arch/x86/kvm/mmu/mmu.c
> > +++ b/arch/x86/kvm/mmu/mmu.c
> [ ... ]
> > @@ -5224,10 +5220,22 @@ 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 *any*
> > + * roots to be invalidated after the initial MMU reload. WARN,
> > + * but continue on; the above MMU reload will do the right thing
> > + * if the current root is actually invalid.
> > + */
> > + WARN_ON_ONCE(kvm_test_request(KVM_REQ_MMU_FREE_OBSOLETE_ROOTS, vcpu));
>
> [Severity: Medium]
> Will this WARN_ON_ONCE ever trigger?
>
> Looking at kvm_mmu_reload(), it calls kvm_check_request() which consumes and
> clears the request bit:
>
> static inline int kvm_mmu_reload(struct kvm_vcpu *vcpu)
> {
> if (kvm_check_request(KVM_REQ_MMU_FREE_OBSOLETE_ROOTS, vcpu))
> kvm_mmu_free_obsolete_roots(vcpu);
> ...
>
> Since kvm_mmu_reload() is called unconditionally just above in the same loop,
> won't the KVM_REQ_MMU_FREE_OBSOLETE_ROOTS bit always be cleared by the time
> execution reaches this check in kvm_tdp_mmu_map_private_pfn()?
More than likely, but not always since it's a cross-vCPU request. As stated in
v1, the goal is more about documentation than about finding bugs.
next prev parent reply other threads:[~2026-08-26 17:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-26 16:42 [PATCH v2 0/4] KVM: x86/mmu: Fix pre-fault and map private loops Sean Christopherson
2026-08-26 16:42 ` [PATCH v2 1/4] KVM: x86/mmu: Reload MMU on *every* page pre-fault attempt/iteration Sean Christopherson
2026-08-26 16:42 ` [PATCH v2 2/4] KVM: x86/mmu: Harden "map private PFN" against unexpected root invalidation Sean Christopherson
2026-08-26 16:59 ` sashiko-bot
2026-08-26 17:08 ` Sean Christopherson [this message]
2026-08-26 16:42 ` [PATCH v2 3/4] KVM: x86/mmu: Top-up memory caches when retrying "map private PFN" Sean Christopherson
2026-08-26 16:42 ` [PATCH v2 4/4] KVM: x86/mmu: Add sanity check to detect stale page faults in " Sean Christopherson
2026-08-26 16:55 ` sashiko-bot
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=ao8dkl_JLNLpzSEf@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