Re: [PATCH v6 07/11] KVM: TDX: Allocate PAMT memory for TD and vCPU control structures

From: Yan Zhao

Date: Wed Jul 08 2026 - 23:18:27 EST


On Thu, Jul 09, 2026 at 09:12:31AM +0800, Edgecombe, Rick P wrote:
> On Wed, 2026-07-08 at 17:13 +0800, Yan Zhao wrote:
> > On Mon, May 25, 2026 at 07:35:11PM -0700, Rick Edgecombe wrote:
> > > From: "Kirill A. Shutemov" <kirill.shutemov@xxxxxxxxxxxxxxx>
> > >
> > > Use control page helpers for allocating and freeing TD control structures,
> > > such these operations can work for Dynamic PAMT.
> > >
> > > The TDX module tracks some state for each page of physical memory that it
> > > might use. It calls this state the PAMT. It includes separate state for
> > Nit: It records this state in the PAMT ?
>
> The text is trying to describe what PAMT is, so I'm not sure about this one.
Ok.
To me, PAMT stands for physical address metadata table, and the metadata the
table tracks is the "state" of a page.
Feel free to ignore the nit though :)

> > > each page size a physical page could be utilized at within the TDX module
> > > (1GB, 2MB, 4KB). In Dynamic PAMT, only the 4KB page size state is
> > > allocated dynamically. So the kernel must install PAMT backing for each 4KB
> > How about
> > "..., only the backend to hold the 4KB page size state is allocated
> > dynamically" ?
>
> How about:
> In Dynamic PAMT, only the 4KB page size backing is allocated dynamically.
LGTM.

> > > page before gifting it to the TDX module, and tear it down after the page
> > > is reclaimed.
> > How about
> > "So the kernel must check whether it is necessary to install/remove PAMT
> > backing for each 4KB page, and do so when necessary before gifting the page
> > to the TDX module or after it is reclaimed." ?
>
> The checking part is true, but is it needed to understand this patch? I think it
> just needs a background of what is happening. How about:
>
> So the kernel must install PAMT backing for any 4KB page being gifting to the
> TDX module, and tear down the backing when the associated gifted pages are
> reclaimed.
Hmm. I'm not sure if it would be confusing for people without sufficient
background, because the kernel only needs to install PAMT backing before the
gifting the first 4KB page.

How about:
So the kernel must ensure PAMT backing installed for any 4KB page being gifting
to the TDX module, and tear down the backing when all associated gifted pages
are reclaimed.