Re: [PATCH v2 05/31] x86/virt/tdx: Extend tdx_page_array to support IOMMU_MT

From: Xu Yilun

Date: Wed Apr 08 2026 - 02:38:32 EST


On Thu, Apr 02, 2026 at 12:05:43AM +0000, Huang, Kai wrote:
> On Sat, 2026-03-28 at 00:01 +0800, Xu Yilun wrote:
> > IOMMU_MT is another TDX Module defined structure similar to HPA_ARRAY_T
> > and HPA_LIST_INFO. The difference is it requires multi-order contiguous
> > pages for some entries. It adds an additional NUM_PAGES field for every
> > multi-order page entry.
> >
> > Add a dedicated allocation helper for IOMMU_MT. Fortunately put_page()
> > works well for both single pages and multi-order folios, simplifying the
> > cleanup logic for all allocation methods.
>
> Well I guess you can have a 'free_fn' to free the pages you allocated via
> 'alloc_fn'? Will this simplify the code and at least keep tdx_page_array
> implementation cleaner?

mm.. I think code would be simplified with less callbacks.

But anyway, the need for the alloc_fn becomes a sign for me to think
about separating the memory allocation and struct tdx_page_array
construction. Especially that the IOMMU_MT needs specialized memory
layout so better managed by the kernel driver who really uses IOMMU_MT.

>
> It's strange that you only have a 'alloc_fn' but doesn't have a 'free_fn'
> anyway.