x86/virt/tdx: Remove the auto-generated global metadata reader All five TDX global metadata classes now have hand-maintained, table-driven readers in tdx.c. The only thing remaining in the auto-generated tdx_global_metadata.c was the get_tdx_sys_info() orchestrator that calls the per-class readers in order and prints the module version once it has been read. Move that orchestrator into tdx.c and delete the generated file along with the unusual `#include "tdx_global_metadata.c"` that spliced its contents into tdx.c at build time. Behavior is unchanged: the read order, the version print, and the error propagation are preserved verbatim. After this patch the entire TDX global metadata path -- the field IDs, the C structures they populate, the per-field tables, and the read code -- lives in tdx.h, asm/tdx_global_metadata.h, and tdx.c. Adding a new field is now: extend the struct, add a TD_SYSINFO_MAP entry naming the spec field next to the C member, done. No out-of-tree script and no regenerated source files. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c index 72503db..09af3f5 100644 --- a/arch/x86/virt/vmx/tdx/tdx.c +++ b/arch/x86/virt/vmx/tdx/tdx.c
@@ -528,7 +528,24 @@ static __init int get_tdx_sys_info_td_conf(struct tdx_sys_info_td_conf *td_conf) return 0; } -#include "tdx_global_metadata.c" +static __init int get_tdx_sys_info(struct tdx_sys_info *sysinfo) +{ + int ret = 0; + + ret = ret ?: get_tdx_sys_info_version(&sysinfo->version); + + pr_info("Module version: %u.%u.%02u\n", + sysinfo->version.major_version, + sysinfo->version.minor_version, + sysinfo->version.update_version); + + ret = ret ?: get_tdx_sys_info_features(&sysinfo->features); + ret = ret ?: get_tdx_sys_info_tdmr(&sysinfo->tdmr); + ret = ret ?: get_tdx_sys_info_td_ctrl(&sysinfo->td_ctrl); + ret = ret ?: get_tdx_sys_info_td_conf(&sysinfo->td_conf); + + return ret; +} static __init int check_features(struct tdx_sys_info *sysinfo) {
diff --git a/arch/x86/virt/vmx/tdx/tdx_global_metadata.c b/arch/x86/virt/vmx/tdx/tdx_global_metadata.c deleted file mode 100644 index 97d3100..0000000 --- a/arch/x86/virt/vmx/tdx/tdx_global_metadata.c +++ /dev/null
@@ -1,27 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Automatically generated functions to read TDX global metadata. - * - * This file doesn't compile on its own as it lacks of inclusion - * of SEAMCALL wrapper primitive which reads global metadata. - * Include this file to other C file instead. - */ - -static __init int get_tdx_sys_info(struct tdx_sys_info *sysinfo) -{ - int ret = 0; - - ret = ret ?: get_tdx_sys_info_version(&sysinfo->version); - - pr_info("Module version: %u.%u.%02u\n", - sysinfo->version.major_version, - sysinfo->version.minor_version, - sysinfo->version.update_version); - - ret = ret ?: get_tdx_sys_info_features(&sysinfo->features); - ret = ret ?: get_tdx_sys_info_tdmr(&sysinfo->tdmr); - ret = ret ?: get_tdx_sys_info_td_ctrl(&sysinfo->td_ctrl); - ret = ret ?: get_tdx_sys_info_td_conf(&sysinfo->td_conf); - - return ret; -}