Re: [PATCH v7 08/11] KVM: TDX: Get/put PAMT pages when (un)mapping private memory

From: Edgecombe, Rick P

Date: Wed Jul 22 2026 - 15:23:30 EST


On Wed, 2026-07-22 at 16:46 +0300, Nikolay Borisov wrote:
> > +static int tdx_topup_external_pamt_cache(struct kvm_vcpu *vcpu, int
> > min_nr_spts)
> > +{
> > + /*
> > + * Don't cover the root SPT, but cover a possible 4KB private
> > + * page in addition to the SPTs. So -1 to exclude the root
> > + * SPT, and +1 for the guest page cancel out.
> > + */
>
> That comment here doesn't seem to correspond to the code in anyway.
> There are no +-1 adjustments.

The +1 and -1 cancel each other out. Hmm, how about:
/*
* Don't cover the root SPT, but cover a possible 4KB private
* page in addition to the SPTs. The -1 to exclude the root
* SPT and +1 for the guest page cancel each other out. So
* make no adjustments.
*/

And thanks for the RB tags!

> > + return tdx_topup_pamt_cache(&to_tdx(vcpu)->pamt_cache,
> > min_nr_spts);