Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sean Christopherson" <seanjc@google.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH 3/4] KVM: x86/mmu: Top-up memory caches when retrying "map private PFN"
Date: Thu, 06 Aug 2026 21:56:13 +0000	[thread overview]
Message-ID: <20260806215614.36B4F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260806214050.78058-4-seanjc@google.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The WARN_ON_ONCE check for obsolete roots in kvm_tdp_mmu_map_private_pfn is largely ineffective due to being placed after kvm_mmu_reload, which clears the request bit.
--

--- Patch [3]: [PATCH 3/4] KVM: x86/mmu: Top-up memory caches when retrying "map private PFN" ---
commit 7a1e8c6872a95084f82e79ad3438f87300a97a91
Author: Sean Christopherson <seanjc@google.com>

KVM: x86/mmu: Top-up memory caches when retrying "map private PFN"

This commit moves the top-up of memory caches into the retry loop in
kvm_tdp_mmu_map_private_pfn(). This ensures that the caches are replenished
on every attempt to map the PFN, hardening KVM against potential cache
consumption issues during TDX post-populate callbacks.

Closes: https://lore.kernel.org/all/20260718061050.E17B01F000E9@smtp.kernel.org

> diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
> index c6cac893cbad8..379f570ef04f8 100644
> --- a/arch/x86/kvm/mmu/mmu.c
> +++ b/arch/x86/kvm/mmu/mmu.c
> @@ -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 = mmu_topup_memory_caches(vcpu, false);
> -	if (r)
> -		return r;
> -
>  	do {
>  		if (signal_pending(current))
>  			return -EINTR;

[ ... ]

> @@ -5199,6 +5195,10 @@ int kvm_tdp_mmu_map_private_pfn(struct kvm_vcpu *vcpu, gfn_t gfn, kvm_pfn_t pfn)
>  		if (r)
>  			return r;
>  
> +		r = mmu_topup_memory_caches(vcpu, false);
> +		if (r)
> +			return r;
> +
>  		cond_resched();
>  
>  		guard(read_lock)(&kvm->mmu_lock);

[Severity: Medium]
In kvm_tdp_mmu_map_private_pfn(), is the WARN_ON_ONCE() check for
obsolete roots still effective here?

Just a few lines down from this chunk:

    WARN_ON_ONCE(kvm_test_request(KVM_REQ_MMU_FREE_OBSOLETE_ROOTS, vcpu));

Because kvm_mmu_reload() is called higher up in the loop, which internally
invokes kvm_check_request(KVM_REQ_MMU_FREE_OBSOLETE_ROOTS, vcpu), it will
clear the request bit.

If an invalidation occurs during the kvm_tdp_mmu_map() execution, the loop
correctly retries, but the next iteration's kvm_mmu_reload() will silently
clear the request bit before execution reaches the WARN_ON_ONCE() statement.

This seems to leave the assertion only covering the small window between the
reload and the WARN itself, masking potential regressions where roots are
unexpectedly invalidated during the map operation.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260806214050.78058-1-seanjc@google.com?part=3

  reply	other threads:[~2026-08-06 21:56 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
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 [this message]
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=20260806215614.36B4F1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=seanjc@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