Re: [PATCH v2 03/17] x86/virt/tdx: Detect if the extensions initialization is required

Xu Yilun <[email protected]> Mon, 27 Jul 2026 20:43:01 +0800
Newsgroups dev.linux.lists.linux-coco,org.kernel.vger.kvm,org.kernel.vger.linux-kernel
Message-ID <amdSVcIL4AyMK1RA@yilunxu-OptiPlex-7050>
On Fri, Jul 24, 2026 at 04:44:15PM +0800, Xiaoyao Li wrote:
> On 6/30/2026 7:10 PM, Xu Yilun wrote:
> > On Mon, Jun 29, 2026 at 02:33:56PM +0800, Chao Gao wrote:
> > > > +static __init int init_tdx_module_extensions(void)
> > > > +{
> > > > +	struct tdx_sys_info_ext sysinfo_ext;
> > > > +	int ret;
> > > > +
> > > > +	if (!(tdx_sysinfo.features.tdx_features0 & TDX_FEATURES0_EXT))
> > > > +		return 0;
> > > > +
> > > > +	ret = get_tdx_sys_info_ext(&sysinfo_ext);
> > > > +	if (ret)
> > > > +		return ret;
> > > > +
> > > > +	/* Skip if no feature requires TDX module extensions. */
> > > > +	if (!sysinfo_ext.ext_required)
> > > > +		return 0;
> > > 
> > > What would happen if the kernel doesn't do this 'ext_required' check
> > > and always does the extension initialization?
> > > 
> > > If TDH.EXT.INIT returns success when no extension is configured, we
> > 
> > No, TDH.EXT.INIT fails when ext_required==false
> 
> What is the SEAMCALL return code in this case?

It will return TDX_EXT_MEMORY_POOL_NOT_READY, because TDX module's internal
state machine stays at the first step of extensions' initialization.

> 
> > > could drop this 'ext_required' from this series entirely.
>