Re: [PATCH 01/15] x86/virt/tdx: Read global metadata for TDX Module Extensions

From: Xiaoyao Li

Date: Mon May 25 2026 - 02:59:11 EST


On 5/22/2026 11:41 AM, Xu Yilun wrote:
...
+static __init int get_tdx_sys_info_ext(struct tdx_sys_info_ext *sysinfo_ext)
+{
+ int ret = 0;
+ u64 val;
+
+ if (!ret && !(ret = read_sys_metadata_field(0x3100000100000000, &val)))
+ sysinfo_ext->memory_pool_required_pages = val;
+ if (!ret && !(ret = read_sys_metadata_field(0x3100000000000001, &val)))
+ sysinfo_ext->ext_required = val;
+
+ return ret;
+}
+
static __init int get_tdx_sys_info(struct tdx_sys_info *sysinfo)
{
int ret = 0;
@@ -116,5 +129,8 @@ static __init int get_tdx_sys_info(struct tdx_sys_info *sysinfo)
ret = ret ?: get_tdx_sys_info_td_ctrl(&sysinfo->td_ctrl);
ret = ret ?: get_tdx_sys_info_td_conf(&sysinfo->td_conf);
+ if (sysinfo->features.tdx_features0 & TDX_FEATURES0_EXT)
+ ret = ret ?: get_tdx_sys_info_ext(&sysinfo->ext);

Is it correct to read "memory_pool_required_pages" and "ext_required" so early in get_tdx_sys_info()? get_tdx_sys_info() is called before config_tdx_module() which calls TDH.SYS.CONFIG.

If I read the TDX module base spec correctly, the amount of memory for extensions and EXT_REQUIRED field depends on the enabled features, which is determined by TDH.SYS.CONFIG/TDH.SYS.UPDATE ?

return ret;
}