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

From: Edgecombe, Rick P

Date: Mon Nov 23 2026 - 14:22:12 EST


On Mon, 2026-11-23 at 21:10 +0800, Chao Gao wrote:
> > Why don't the data structures look like this disagram?
>
> I started with data structures that look like the diagram. Three
> simplifications got from there to the current code.
>
> First, make the pages in the diagram contiguous. The diagram shows
> them apart, as the ABI allows, but we don't need to allocate them
> separately. It can be just a single large structure, and the existing
> allocation code is reused as is.
>
> Second, use a fixed number of pages. The ABI allows any number of
> them, to support a module of any size. But modules are about 2MB
> today, so the structure is just 16 pages, which is enough for a module
> of about 32MB. The number can be raised if modules outgrow it.
>
> Third, don't define the entries that point to the next page
> explicitly. They are always the last u64 of a page. So the code that
> fills in the structure can locate them as it goes.
>
> Defining those entries explicitly would match the diagram. But then
> those entries split the list of module page addresses into multiple
> lists, one per page, and the first one is shorter than the others.
> The code that fills them in has to keep track of which list it is in
> and how long that list is. That is more code.

How does it look if you just have two versions of the struct and cast? Did you
try it? How many more lines? We don't want to fight to save a few lines of code
if we end up needing lots of explanation to justify it.