Re: [PATCH v2 04/31] x86/virt/tdx: Support allocating contiguous pages for tdx_page_array
From: Xu Yilun
Date: Tue Mar 31 2026 - 10:07:17 EST
> > static struct tdx_page_array *
> > -tdx_page_array_alloc(unsigned int nr_pages)
> > +tdx_page_array_alloc(unsigned int nr_pages,
> > + int (*alloc_fn)(unsigned int nr_pages,
> > + struct page **pages, void *data),
> > + void *data)
>
> This interface seems cumbersome, since you will always have separate
> allocation paths:
>
> Contig, Bulk and Iommu mt pages let's just keep them separate. I.e the flow
> should be:
>
> 1. Do common allocation by calling tdx_page_array_alloc (you aren't passing
> the alloc function) you just get a bare-bones tdx_page_array struct
>
> 2. Do the specific allocation in either :
>
> tdx_page_array_create - for the bulk case
> tdx_page_array_alloc_contig - for the contig case
> tdx_page_array_create_iommu_mt - for the iommu case. Here you can open code
> tdx_alloc_pages_iommu_mt.
>
> And keep the specific clearly separate in each function.
Thank for the suggestion. There are also other concerns in this thread,
but I'll take this into consideration.