Re: [PATCH v3 1/2] x86/virt/seamldr: Support large TDX module binaries

From: Dave Hansen

Date: Thu Nov 19 2026 - 13:10:36 EST


On 11/18/26 23:49, Chao Gao wrote:
> TDX module binaries are limited to just under 2MB. The binary is handed
> to P-SEAMLDR as a list of page physical addresses in
> 'struct seamldr_params', and the list must fit in a single 4KB page
> along with a few other fields.
>
> TDX modules are gaining features and are about to outgrow that limit.
>
> The P-SEAMLDR ABI was extended to let the list continue onto more 4KB
> pages. The last u64 of each page holds the physical address of the next
> page, chaining the pages together.
>
> Grow module_pages_pa_list[] so that 'struct seamldr_params' spans 16
> pages, and chain the pages together in populate_pa_list().
>
> Each page uses its last entry for chaining, so the maximum module page
> count is the array size minus one entry per page. The user-supplied
> image is checked against this count.
>
> The 16-page size is somewhat arbitrary. It fits modules of up to about
> 32MB, far above the roughly 2MB of current modules. It wastes 60KB for
> today's modules, which is fine because the memory is freed right after
> the update.
>
> Do not query P-SEAMLDR for chaining support. Userspace selects the
> update image and is responsible for ensuring the module is compatible
> with P-SEAMLDR.
>
> A 496-page module (the old maximum) used to fit in a single page. Now
> the last entry of that page is used for chaining, so the final address
> moves to a second page and the module requires chaining support. Do not
> special-case this size to make it work with a P-SEAMLDR without
> chaining support. No released module has exactly 496 pages, so nothing
> breaks. Leave it to userspace to ensure any future 496-page module is
> paired with a P-SEAMLDR that supports chaining, as with larger modules.

This seems to be getting worse, not better.

Maybe I'm being dense, but I *still* don't have a clear picture in my
head of what the before and after data structures look like.

> +#define SEAMLDR_NR_MODULE_PA_ENTRIES ((SEAMLDR_PARAMS_NR_PAGES * PAGE_SIZE - 128) / sizeof(u64))

The "128" is a hard-coded struct offset. To me, that's a big
anti-pattern. Use the structs themselves.

I'd suggest a way to do it if I had a clear picture of the data
structures in my head, which I don't at this point.