Re: [PATCHv2 02/12] x86/virt/tdx: Allocate page bitmap for Dynamic PAMT
From: Dave Hansen
Date: Wed Jun 25 2025 - 14:07:42 EST
> /*
> * 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.