Currently the kernel doesn't print any TDX module version information. In practice such information is useful, especially to the developers. For instance: 1) When something goes wrong around using TDX, the module version is normally the first information the users want to know [1]. 2) The users want to quickly know module version to see whether the loaded module is the expected one. Dump TDX module version. The actual dmesg will look like: virt/tdx: module version: 1.5.00.00.0481 (build_date 20230323). And dump right after reading global metadata, so that this information is printed no matter whether module initialization fails or not. Link: https://lore.kernel.org/lkml/4b3adb59-50ea-419e-ad02-e19e8ca20dee@xxxxxxxxx/ [1] Signed-off-by: Kai Huang <kai.huang@xxxxxxxxx> --- arch/x86/virt/vmx/tdx/tdx.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c index 9bc827a6cee8..6982e100536d 100644 --- a/arch/x86/virt/vmx/tdx/tdx.c +++ b/arch/x86/virt/vmx/tdx/tdx.c @@ -312,6 +312,23 @@ static void print_cmrs(struct tdx_sys_info_cmr *sysinfo_cmr) } } +static void print_module_version(struct tdx_sys_info_version *version) +{ + /* + * TDX module version encoding: + * + * <major>.<minor>.<update>.<internal>.<build_num> + * + * When printed as text, <major> and <minor> are 1-digit, + * <update> and <internal> are 2-digits and <build_num> + * is 4-digits. + */ + pr_info("module version: %u.%u.%02u.%02u.%04u (build_date %u).\n", + version->major_version, version->minor_version, + version->update_version, version->internal_version, + version->build_num, version->build_date); +} + static int init_tdx_sys_info(struct tdx_sys_info *sysinfo) { int ret; @@ -322,6 +339,7 @@ static int init_tdx_sys_info(struct tdx_sys_info *sysinfo) trim_null_tail_cmrs(&sysinfo->cmr); print_cmrs(&sysinfo->cmr); + print_module_version(&sysinfo->version); return 0; } -- 2.46.2