Re: [PATCH v1 06/26] x86/virt/tdx: Add tdx_page_array helpers for new TDX Module objects

Tony Lindgren
2026-02-17T07:37:20Z

On Mon, Nov 17, 2025 at 10:22:50AM +0800, Xu Yilun wrote:
> @@ -296,6 +297,257 @@ static __init int build_tdx_memlist(struct list_head *tmb_list)
> return ret;
> }
>
> +#define TDX_PAGE_ARRAY_MAX_NENTS (PAGE_SIZE / sizeof(u64))
...

> +/*
> + * For holding less than TDX_PAGE_ARRAY_MAX_NENTS (512) pages.

The comment should be "For holding at most TDX_PAGE_ARRAY_MAX_NENTS.."

> + * If more pages are required, use tdx_page_array_alloc() and
> + * tdx_page_array_fill_root() to build tdx_page_array chunk by chunk.
> + */
> +struct tdx_page_array *tdx_page_array_create(unsigned int nr_pages)
> +{
> + int filled;
> +
> + if (nr_pages > TDX_PAGE_ARRAY_MAX_NENTS)
> + return NULL;

To match this check.

> + struct tdx_page_array *array __free(tdx_page_array_free) =
> + tdx_page_array_alloc(nr_pages);
> + if (!array)
> + return NULL;
> +
> + filled = tdx_page_array_fill_root(array, 0);
> + if (filled != nr_pages)
> + return NULL;
> +
> + return no_free_ptr(array);
> +}
> +EXPORT_SYMBOL_GPL(tdx_page_array_create);

Regards,

Tony