Re: [PATCH v3 3/6] x86/virt/tdx: Add extra memory to TDX module for the extensions

From: Edgecombe, Rick P

Date: Fri Oct 09 2026 - 15:19:04 EST


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.

Rename memory_pool_required_pages to required_pages to shorten the lines to
something manageable and use it directly below.