From: "Edgecombe, Rick P" <rick.p.edgecombe@intel.com>
To: "seanjc@google.com" <seanjc@google.com>
Cc: "Zhao, Yan Y" <yan.y.zhao@intel.com>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"pbonzini@redhat.com" <pbonzini@redhat.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"sashiko-bot@kernel.org" <sashiko-bot@kernel.org>,
"Huang, Kai" <kai.huang@intel.com>
Subject: Re: [PATCH 3/4] KVM: x86/mmu: Top-up memory caches when retrying "map private PFN"
Date: Mon, 10 Aug 2026 20:37:28 +0000 [thread overview]
Message-ID: <1fc757de50acfdfac5f734a3ad1eaed4123cfbf8.camel@intel.com> (raw)
In-Reply-To: <anZYib2bADjRmxvE@google.com>
On Fri, 2026-08-07 at 15:13 -0700, Sean Christopherson wrote:
> > I think it is the same for the other caches consumed by the fault. I guess
> > "e.g." covers it. But it's not new after DPAMT.
>
> I don't think so? Especially since as you point out below, nothing else can
> muck with the SPTEs. The TDP MMU only consumes an cache entry if it
> successfully creates a SPTE, and since nothing can muck with SPTEs, anything
> created on the first attempt will still be there on subsequent attempts. I.e.
> the TDP MMU might create SPTEs that are ultimately unused, but I don't think
> it can exhaust a cache.
Functionally we won't see multiple kvm_tdp_mmu_map() calls during
kvm_tdp_mmu_map_private_pfn() because of the locks as we discussed. But... if we
did, then I think we would have the same pattern of freeing but not topping up
before retrying:
kvm_tdp_mmu_map():
...
/*
* The SPTE is either non-present or points to a huge page that
* needs to be split.
*/
sp = tdp_mmu_alloc_sp(vcpu);
tdp_mmu_init_child_sp(sp, &iter); <- shrink mirror
if (is_mirror_sp(sp))
kvm_mmu_alloc_external_spt(vcpu, sp); <- shrink external
sp->nx_huge_page_disallowed = fault->huge_page_disallowed;
if (is_shadow_present_pte(iter.old_spte)) {
/* Don't support large page for mirrored roots (TDX) */
KVM_BUG_ON(is_mirror_sptep(iter.sptep), vcpu->kvm);
r = tdp_mmu_split_huge_page(kvm, &iter, sp, true);
} else {
r = tdp_mmu_link_sp(kvm, &iter, sp, true);<- TDX
error(BUSY,etc)
}
/*
* Force the guest to retry if installing an upper level SPTE
* failed, e.g. because a different task modified the SPTE.
*/
if (r) {
tdp_mmu_free_unused_sp(sp); <- free_page() external and mirror
goto retry; <- return to kvm_tdp_mmu_map_private_pfn()
}
...
Without the additional top up in kvm_tdp_mmu_map_private_pfn(), the retry
wouldn't have enough, right? The 'sp' goes back to the cache, but the
external_pt doesn't. Actually, hmm...
But that is why I thought: No functional issue with or without DPAMT. And the
brittleness is existing.
next prev parent reply other threads:[~2026-08-10 20:37 UTC|newest]
Thread overview: 21+ 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-10 20:01 ` Edgecombe, Rick P
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-10 20:37 ` Edgecombe, Rick P [this message]
2026-08-10 20:43 ` 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=1fc757de50acfdfac5f734a3ad1eaed4123cfbf8.camel@intel.com \
--to=rick.p.edgecombe@intel.com \
--cc=kai.huang@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=sashiko-bot@kernel.org \
--cc=seanjc@google.com \
--cc=yan.y.zhao@intel.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