TDX module sigstructs are limited to 4KB. Each update image carries a sigstruct, which is handed to P-SEAMLDR in 'struct seamldr_params' along with the module binary. The structure has room for the physical address of only one sigstruct page. TDX modules are moving to a post-quantum signature algorithm. Its signatures are far larger than the ones in use today, so the sigstruct no longer fits in 4KB. The P-SEAMLDR ABI was extended to take up to four sigstruct pages (16KB). Setting 'version' to 1 tells P-SEAMLDR to use this layout. Grow sigstruct_pages_pa_list[] to four entries to match. In anticipation of this change, the list is already filled in a loop, so filling the new entries needs no new code. Use version 1 only when the sigstruct spans more than one page. Old P-SEAMLDRs reject version 1, so this keeps today's modules working on them. Do not query P-SEAMLDR for version 1 support. Userspace selects the update image and is responsible for ensuring the module is compatible with P-SEAMLDR. Signed-off-by: Chao Gao --- v3: - Explain why sigstruct filling code is a loop already [Rick] - Drop the boilerplate AI usage note [Dave] v2: - drop macros for versions to keep the diff minimal - explain why the sigstruct filling code needs no change --- arch/x86/virt/vmx/tdx/seamldr.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/arch/x86/virt/vmx/tdx/seamldr.c b/arch/x86/virt/vmx/tdx/seamldr.c index 6b9657a28129..7c09c84df1aa 100644 --- a/arch/x86/virt/vmx/tdx/seamldr.c +++ b/arch/x86/virt/vmx/tdx/seamldr.c @@ -38,7 +38,7 @@ */ #define SEAMLDR_NR_MODULE_PA_ENTRIES ((SEAMLDR_PARAMS_NR_PAGES * PAGE_SIZE - 128) / sizeof(u64)) #define SEAMLDR_MAX_NR_MODULE_PAGES (SEAMLDR_NR_MODULE_PA_ENTRIES - SEAMLDR_PARAMS_NR_PAGES) -#define SEAMLDR_MAX_NR_SIG_PAGES 1 +#define SEAMLDR_MAX_NR_SIG_PAGES 4 /* * The seamldr_params "scenario" field specifies the operation mode: @@ -59,7 +59,7 @@ struct seamldr_params { u32 version; u32 scenario; u64 sigstruct_pages_pa_list[SEAMLDR_MAX_NR_SIG_PAGES]; - u8 reserved[104]; + u8 reserved[80]; u64 module_nr_pages; u64 module_pages_pa_list[SEAMLDR_NR_MODULE_PA_ENTRIES]; } __packed; @@ -173,6 +173,13 @@ static void populate_seamldr_params(struct seamldr_params *params, const u8 *mod, u32 mod_nr_pages) { params->version = 0; + /* + * Use version 1 only for multi-page sigstructs, to stay + * compatible with old P-SEAMLDRs that lack version 1 support. + */ + if (sig_nr_pages > 1) + params->version = 1; + params->scenario = SEAMLDR_SCENARIO_UPDATE; params->module_nr_pages = mod_nr_pages; -- 2.52.0