Re: [PATCH v3 3/6] x86/virt/tdx: Add extra memory to TDX module for the extensions
From: Xu Yilun
Date: Fri Oct 09 2026 - 23:24:10 EST
On Fri, Oct 09, 2026 at 06:58:44PM +0000, Edgecombe, Rick P wrote:
> On Tue, 2026-10-06 at 01:41 +0800, Xu Yilun wrote:
> > +static __init int tdx_ext_mem_setup(void)
> > +{
> > + unsigned int required_pages, added_pages;
> > + struct tdx_sys_info_ext sysinfo_ext;
> > + struct tdx_hpa_list *hpa_list;
> > + struct page *page;
> > + int ret;
> > +
> > + ret = get_tdx_sys_info_ext(&sysinfo_ext);
> > + if (ret)
> > + return ret;
> > +
> > + required_pages = sysinfo_ext.memory_pool_required_pages;
> > +
> > + /*
> > + * Skip the memory setup if no memory is required. This may happen when
> > + * no add-on features requiring TDX module extensions are configured
> > + * via TDH.SYS.CONFIG.
> > + */
> > + if (!required_pages)
> > + return 0;
>
> Marshaling this through the struct just to get a set it to required_pages seems
> a bit silly. But I see required_pages is needed for line length.
>
> Two options:
>
> Make the get_tdx_sys_info_ext() just take an unsigned int pointer arg. When
> Chao's metadata reading stuff lands, we can keep the struct internal to the
> helper, to still re-use the macro struct mapper stuff.
struct tdx_sys_info_handoff is an existing example so I don't want to
make it different.
>
> Rename memory_pool_required_pages to required_pages to shorten the lines to
> something manageable and use it directly below.
I prefer the 2nd one. I also want to rename the sysinfo_ext to ext, to
make the field short enough for direct usage everywhere.
struct tdx_sys_info ext ext;
ret = get_tdx_sys_info_ext(&ext);
if (ret)
return ret;
if (!ext.required_pages)
return 0;
...