Re: [PATCH v5 2/6] x86/virt/tdx: Configure add-on features on TDX module init

From: Xu Yilun

Date: Mon Nov 23 2026 - 02:47:42 EST


On Sun, Nov 22, 2026 at 05:50:41AM +0200, Artem Bityutskiy wrote:
> Hi Yilun,
>
> The patch looks good, but its framing can be improved.
>
> Remove references to enabling all add-ons to improve it. This patch adds
> plumbing, it should not dictate/discuss whether all or only some add-ons
> should be enabled. See comments below.

The get_tdx_usable_addon_features0() in this patch is enabling all
add-ons that *the kernel supports*. And this policy definitely needs
explanation.

The current kernel code highly depends on tdx_sysinfo.features.tdx_features0
to decide if a feature is available. So if we enable *some* add-ons, the
contract no longer holds. So I do think we need clear words on the
policy.

But yes, maybe the word "all" reads like we enable all add-ons that the TDX
module supports. I'll see how to avoid that.

>
> On Wed, 2026-11-11 at 11:48 +0800, Xu Yilun wrote:
> > The TDX architecture identifies some features that are off by default.
> > They are classified as add-on features because enabling them affects
> > existing TDX systems: they may change existing feature behavior, or
> > reserve more memory.
> >
> > However, the impact of the first add-on features will be low enough to
> > pursue a simple approach - the kernel just enables them when supported.
> > If a feature with a very high overhead appears in the future, this can
> > be revisited.
>
> This sounds like all supported add-ons will be enabled for simplicity.

Maybe the first sentence is not clear. I want to say we enable add-on
features when *the kernel* supports them. I'll change it.

>
> The reviewer keeps this in mind now.
>
> ... snip ...
>
> > Pass the bitmap of features that are supported by both kernel & TDX
> > module to TDH.SYS.CONFIG. Initially, the bitmap is 0. It will be updated
> > to contain specific feature bits as full kernel support lands.
>
> But this says that it enables no add-ons. Now reviewer needs to spend
> brain cycles to process the contradiction, unnecessarily.

I see the concern. There is actually no contradiction, we enable all
kernel-supported add-ons, but for now kernel supports no add-ons, so
nothing is enabled.

v4 explains this point in one paragraph, I split it in v5 which may
causes the disconnection. I'd like to roll back:

Although add-on features can introduce overhead to TDX runtime, the
impact of the first features will be low enough to pursue a simple
approach - just enable them when kernel support lands. Pass the bitmap
of features that are supported by both kernel & TDX module to
TDH.SYS.CONFIG. Initially, the bitmap is 0; it will be updated to
contain specific feature bits as subsequent kernel changes support them.
If a feature with high overhead appears in the future, this can be
revisited.

>
> ... snip ...
>
> > arch/x86/virt/vmx/tdx/tdx.c | 19 +++++++++++++++++++
> > 1 file changed, 19 insertions(+)
> >
> > diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c
> > index c7bd0b01786d..3bfe78b4b538 100644
> > --- a/arch/x86/virt/vmx/tdx/tdx.c
> > +++ b/arch/x86/virt/vmx/tdx/tdx.c
> > @@ -1033,9 +1033,19 @@ static __init int construct_tdmrs(struct list_head *tmb_list,
> >
> > #define TDX_SYS_CONFIG_DYNAMIC_PAMT BIT(16)
> >
> > +/* List all kernel-supported add-on features0 bits here */
> > +#define TDX_KERNEL_SUPPORTED_ADDON_FEATURES0 (0)
>
> Suggested comment:
>
> /* Specify add-on feature bits to enable” instead */
>
> I think that this patch should not dictate "all" vs "some", no need.

Yes, will do.

>
> ... snip ...
>
> > + /*
> > + * Use SEAMCALL version 1 that supports add-on features if any are
> > + * requested. Otherwise use version 0 for backward compatibility.
> > + */
> > + if (addon_features0) {
> > + args.r9 = addon_features0;
> > + args.version = 1;
> > + }
>
> Separate nitpick for the comment.
>
> Suggested comment:
>
> /*
> * Avoid unnecessarily requiring version 1 when no add-on features to
> * request.
> */
>
> I was confused by "for backward compatibility”, which sounds like the
> kernel or the seamcall falls back to version 0 if version 1 is not
> supported.

It is for backward compatibility, but we don't try v1 then fallback to v0.

How about the following. I want to keep the compatibility statement but
still fit in 2 lines.

/*
* Avoid unnecessarily using version 1 when no add-ons to request. This
* retains compatibility with older modules that don't recognize v1.
*/

>
> Thanks, Artem.