Re: [PATCH v3 04/16] x86/virt/tdx: Allocate page bitmap for Dynamic PAMT

Binbin Wu
2025-09-23T07:15:53Z

On 9/19/2025 7:22 AM, Rick Edgecombe wrote:
[...]
> diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c
> index 38dae825bbb9..4e4aa8927550 100644
> --- a/arch/x86/virt/vmx/tdx/tdx.c
> +++ b/arch/x86/virt/vmx/tdx/tdx.c
> @@ -440,6 +440,18 @@ static int fill_out_tdmrs(struct list_head *tmb_list,
> return 0;
> }
>
> +static unsigned long tdmr_get_pamt_bitmap_sz(struct tdmr_info *tdmr)
> +{
> + unsigned long pamt_sz, nr_pamt_entries;
> + int bits_per_entry;
> +
> + bits_per_entry = tdx_sysinfo.tdmr.pamt_page_bitmap_entry_bits;
> + nr_pamt_entries = tdmr->size >> PAGE_SHIFT;
> + pamt_sz = DIV_ROUND_UP(nr_pamt_entries * bits_per_entry, BITS_PER_BYTE);
> +
> + return ALIGN(pamt_sz, PAGE_SIZE);

Nit:
return PAGE_ALIGN(pamt_sz);