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

"Edgecombe, Rick P" <[email protected]> Wed, 22 Jul 2026 19:20:53 +0000
Newsgroups dev.linux.lists.linux-coco,org.kernel.vger.kvm,org.kernel.vger.linux-doc,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
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);