Re: [PATCH v4 08/17] KVM: TDX: Adjust the topup count of DPAMT page pairs for splitting S-EPT

From: Edgecombe, Rick P

Date: Fri Oct 09 2026 - 18:12:38 EST


On Fri, 2026-10-09 at 17:08 +0800, Yan Zhao wrote:
> On Thu, Oct 08, 2026 at 09:16:12AM +0800, Edgecombe, Rick P wrote:
> > On Wed, 2026-10-07 at 15:47 -0700, Rick Edgecombe wrote:
> > > Another idea, change the op to be:
> > > int topup_external_cache(struct kvm_vcpu *vcpu, bool root, bool private_page,
> > > int min_nr_spts);
> > >
> > > Normal topup can set:
> > > root=true
> > > private_page=true
> > > min_nr_spts = PT64_ROOT_MAX_LEVEL - 1
> > >
> > > Then we can calculate exactly what we need. And even better, the existing code
> > > won't nee a comment to explain the weirdness.
> >
> > Actually since this gets a struct kvm arg later in the series, maybe we could
> > just have two ops. One for topping up from a fault and another for a split.
> Hmm, no? That would make the min_nr_spts arg meaningless.
> Reusing the topping up op for the fault also scales better, e.g., it could
> support splitting under the fault path in the future.

I don't see how min_nr_spts is meaningless. What do you mean?

Let me spell it out a bit more. For a fault it would have math like this:

int topup(bool root, bool private_page, int nr_extra_spts)
{
add_to_cache(private_page + nr_extra_spts)
}

For fault:
topup(true, true, PT64_ROOT_MAX_LEVEL - 1)

For split:
topup(false, false, 1)


Why have root as a separate arg even though it is never used? Because it makes
the logic make sense from code KVM.

>
> Besides, I actually introduced a separate cache and op for split in v3,
> https://lore.kernel.org/all/20260106102345.25261-1-yan.y.zhao@xxxxxxxxx.
> Sean merged the cache/op for split with the cache/op for fault in
> DPAMT+Hugepage v5.

Yea, but he didn't have any big assumptions in it like this. It was way simpler.