Re: [PATCH v4 08/17] KVM: TDX: Adjust the topup count of DPAMT page pairs for splitting S-EPT
From: Yan Zhao
Date: Sun Oct 18 2026 - 22:01:01 EST
On Fri, Oct 16, 2026 at 01:21:14AM +0800, Edgecombe, Rick P wrote:
> On Thu, 2026-10-15 at 12:47 +0800, Yan Zhao wrote:
> > > The point of spelling it all out was to make the contact clear and the
> > > implementation doesn't have to assume anything about the callers.
> > Hmm, but it's hard for the caller to know if private_page is true.
> > We should avoid leaking TDX specific knowledge to KVM MMU, right?
>
> Wait, why won't the caller won't know if it might map a new private page? This
> is basically to cover the +1 part of the "+ 1 -1" in the calculation. I was
> thinking to set it to true for normal ept violation (like an accept) and false
> for split.
In TDX's .topup_external_cache() hook, tdx_topup_external_pamt_cache() always
needs to allocate DPAMT pages for guest private pages, even for the split case.
However, from KVM MMU's perspective, it is unnatural to specify "private_page"
as true when tdp_mmu_alloc_sp_for_split() is preparing the mid-level page table
page.
So, I think we should keep the current convention of just specifying
min_nr_spts, and let the TDX-specific tdx_topup_external_pamt_cache() account
for the +1 part for guest private pages, which is invisible and should not be
exposed to KVM MMU.
So, what about
topup(bool with_root_spt, int min_nr_spts) ?