Re: [PATCHv2 02/12] x86/virt/tdx: Allocate page bitmap for Dynamic PAMT
From: Kirill A. Shutemov
Date: Thu Jun 26 2025 - 05:26:32 EST
On Wed, Jun 25, 2025 at 11:06:16AM -0700, Dave Hansen wrote:
> > /*
> > * Locate a NUMA node which should hold the allocation of the @tdmr
> > * PAMT. This node will have some memory covered by the TDMR. The
> > @@ -522,7 +534,16 @@ static int tdmr_set_up_pamt(struct tdmr_info *tdmr,
> > * and the total PAMT size.
> > */
> > tdmr_pamt_size = 0;
> > - for (pgsz = TDX_PS_4K; pgsz < TDX_PS_NR; pgsz++) {
> > + pgsz = TDX_PS_4K;
> > +
> > + /* With Dynamic PAMT, PAMT_4K is replaced with a bitmap */
> > + if (tdx_supports_dynamic_pamt(&tdx_sysinfo)) {
> > + pamt_size[pgsz] = tdmr_get_pamt_bitmap_sz(tdmr);
> > + tdmr_pamt_size += pamt_size[pgsz];
> > + pgsz++;
> > + }
>
> This is the wrong place to do this.
>
> Hide it in tdmr_get_pamt_sz(). Don't inject it in the main code flow
> here and complicate the for loop.
Okay, makes sense.
--
Kiryl Shutsemau / Kirill A. Shutemov