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

Xu Yilun <[email protected]> Mon, 27 Jul 2026 20:38:49 +0800
Newsgroups dev.linux.lists.linux-coco,org.kernel.vger.kvm,org.kernel.vger.linux-kernel
Message-ID <amdRWaoKa0k324JM@yilunxu-OptiPlex-7050>
On Fri, Jul 24, 2026 at 04:42:33PM +0800, Xiaoyao Li wrote:
> On 6/18/2026 4:13 PM, Xu Yilun wrote:
> > TDX module extensions support extension SEAMCALLs that are preemptible
> > and resumable, unlike normal SEAMCALLs that run to completion while
> > monopolizing the CPU.
> 
> This is not true. There are some normal (non-extension) SEAMCALLs also are
> preemptible and resumable. For example,
> 
> - TDH.PHYMEM.CACHE.WB
> - TDH.SYS.DISABLE
> - TDH.MEM.SEPT.ADD with version 1

No they are not preemptible and resumable. They just intentionally
yield and don't have a generic way to save/resume their context. You
can't rely on that to implement complex tasks in TDX module considering
the complexity. That's the main reason why TDX module extensions are
needed.

> 
> (There might be more. I didn't check all.)
> 
> > This allows for higher-level API constructions,
> > so better supports some add-on features that implement higher order
> > security protocols.
> 
> I think we don't need to explain this? Just that some add-on features
> require the functionalities of TDX module extensions is enough?

mm.. a big part of the series is to bring up the TDX module extensions,
and this is the first patch to start implementing TDX module extensions,
a comment [1] said we could explain the context a little bit in general.

[1]: https://lore.kernel.org/all/[email protected]/

[...]

> > +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;
> 
> There was the discussion around it in [1]. I agree with the point to make
> kernel code simple. But it requires change/clarification from TDX spec,

I got the answer from TDX module team, that there is no use case ext
memory is needed/the Extensions are enabled but TDH.EXT.INIT is not
required. IOW ext_required == false exactly means TDX module extensions
are not required and no extension SEAMCALLs should be invoked.

> right? So will TDX spec change?

No I didn't raise this nits to distract their main focus on blocking
changes. But yes I can raise a ticket for this.

> 
> If so, you would need to mention it somewhere.
> 
> [1] https://lore.kernel.org/all/[email protected]/