Re: [PATCH 01/15] x86/virt/tdx: Read global metadata for TDX Module Extensions
From: Xu Yilun
Date: Thu May 28 2026 - 00:50:16 EST
On Wed, May 27, 2026 at 04:35:36PM +0100, Kiryl Shutsemau wrote:
> On Mon, May 25, 2026 at 02:54:40PM +0800, Xiaoyao Li wrote:
> > 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 ?
Yes.
>
> This is my read too. Looks like we need a separate step after
> config_tdx_module() to readout config-dependatant metadata.
The timing for when metadata becomes valid is now variable, e.g., the
TDX QUOTING metadata is only valid after TDH.QUOTE.INIT [1].
Based on recent discussion, I think we should introduce runtime metadata
reading interfaces for specific metadata sets as needed, rather than
another catch-all step right after config_tdx_module(). See [2] for the
proposed approach for Extensions metadata.
[1]: https://lore.kernel.org/all/20260522034128.3144354-7-yilun.xu@xxxxxxxxxxxxxxx/
[2]: https://lore.kernel.org/all/ahXAL41ZmIDHmgfu@yilunxu-OptiPlex-7050/