Re: [PATCH v7 08/11] KVM: TDX: Get/put PAMT pages when (un)mapping private memory
From: Sean Christopherson
Date: Wed Jul 22 2026 - 15:37:47 EST
On Wed, Jul 22, 2026, Rick P Edgecombe wrote:
> 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.
> */
Maybe put it in code? E.g.
/*
* Minus one page to exclude the root SPT, but plus one page for a
* possible 4KiB private mapping.
*/
min_nr_spts += -1 + 1;
return tdx_topup_pamt_cache(&to_tdx(vcpu)->pamt_cache, min_nr_spts);