From: Chao Gao <chao.gao@intel.com>
To: Dave Hansen <dave.hansen@intel.com>
Cc: <linux-kernel@vger.kernel.org>, <linux-coco@lists.linux.dev>,
<kvm@vger.kernel.org>, <yilun.xu@intel.com>,
<arjan.van.de.ven@intel.com>, <binbin.wu@linux.intel.com>,
Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>, <x86@kernel.org>,
"H. Peter Anvin" <hpa@zytor.com>,
Kiryl Shutsemau <kas@kernel.org>,
Rick Edgecombe <rick.p.edgecombe@intel.com>
Subject: Re: [PATCH v3 1/2] x86/virt/seamldr: Support large TDX module binaries
Date: Fri, 20 Nov 2026 10:58:01 +0800 [thread overview]
Message-ID: <av-3OatHEGZXmWr0@intel.com> (raw)
In-Reply-To: <bed831ec-b4e8-4762-83e1-f4a72075fa9a@intel.com>
>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.
I tried to describe the ABI structure briefly in words, but that was not
clear enough. Here are the before and after data structures.
Before (one 4KB page): After (chained 4KB pages):
+-------- 4KB ---------+ +-------- 4KB ---------+
| version | | version |
| other fields | | other fields |
| module_nr_pages | | module_nr_pages |
| (128 bytes in total) | | (128 bytes in total) |
|......................| |......................|
| module page 0 PA | | module page 0 PA |
| ... | | ... |
| module page 494 PA | | module page 494 PA |
| module page 495 PA | | next page PA |--+
+----------------------+ +----------------------+ |
|
+-------- 4KB ---------+<-+
| 511 module page PAs |
| next page PA |--+
+----------------------+ |
|
+-------- 4KB ---------+<-+
| 511 module page PAs |
| next page PA |--> ...
+----------------------+
I will add this diagram to the end of the changelog, in a background
section.
>
>> +#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.
I tried offsetof() first, but module_pages_pa_list[] cannot be sized
from its own offset. The struct is still incomplete at that point, so
the compiler rejects it.
We can group the first 128 bytes into their own structure and size the
list from it:
#define SEAMLDR_NR_MODULE_PA_ENTRIES \
((SEAMLDR_PARAMS_NR_PAGES * PAGE_SIZE - \
sizeof(struct seamldr_params_fixed)) / sizeof(u64))
struct seamldr_params {
struct_group_tagged(seamldr_params_fixed, __fixed,
u32 version;
u32 scenario;
u64 sigstruct_pages_pa_list[SEAMLDR_MAX_NR_SIG_PAGES];
u8 reserved[104];
u64 module_nr_pages;
);
u64 module_pages_pa_list[SEAMLDR_NR_MODULE_PA_ENTRIES];
} __packed;
Note: struct_group_tagged() keeps the code that refers to those fields
unchanged.
I considered this but decided against it to keep the diff minimal. I will do
this in the next version unless you have something else in mind.
next prev parent reply other threads:[~2026-11-20 2:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 7:49 [PATCH v3 0/2] TDX: P-SEAMLDR: Support large TDX modules and sigstructs Chao Gao
2026-11-19 7:49 ` [PATCH v3 1/2] x86/virt/seamldr: Support large TDX module binaries Chao Gao
2026-11-19 18:10 ` Dave Hansen
2026-11-20 2:58 ` Chao Gao [this message]
2026-11-19 7:49 ` [PATCH v3 2/2] x86/virt/seamldr: Support multiple sigstruct pages Chao Gao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=av-3OatHEGZXmWr0@intel.com \
--to=chao.gao@intel.com \
--cc=arjan.van.de.ven@intel.com \
--cc=binbin.wu@linux.intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=kas@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rick.p.edgecombe@intel.com \
--cc=tglx@kernel.org \
--cc=x86@kernel.org \
--cc=yilun.xu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox