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

From: Xu Yilun

Date: Tue Sep 29 2026 - 05:37:46 EST


On Mon, Sep 28, 2026 at 09:06:15PM +0000, Edgecombe, Rick P wrote:
> On Tue, 2026-09-15 at 14:14 -0700, Rick Edgecombe wrote:
> > now that we don't need to do this on update
>
> Per an off-list discussion, we agreed to not have TDH.SYS.UPDATE do the
> TDH.EXT.INIT work internally so that another VMM can have more flexibility. So
> we now need to go back to something like we had in v1 where it is called after
> update. But given the change in error codes for TDH.EXT.INIT, I think we still
> don't need to save the ext_required metadata field? We can just call it
> unconditionally, right?

right.

> So it should still be a bit simpler than v1.

Another thing is about the addon_features0 argument for TDH.SYS.UPDATE.
In v1 -> v2, in order to meet the goal of "just restore everything that
was configured during boot", this bitmap argument is removed. I think
this argument removal is orthogonal to the TDH.EXT.INIT discussion and
still has merit.

TDH.SYS.UPDATE(v0): TDX module reconfigures same features as specified by
TDH.SYS.CONFIG, Linux would use this SEAMCALL version.

TDH.SYS.UPDATE(v1, addon_featues0): VMM can configure new features specified
by addon_features0 argument. For other VMM.

Then we can just add one patch based on v2 series:

----8<----

x86/virt/tdx: Re-initialize the extensions on runtime TDX module update

xxxxx

diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c
index c28e65f56532..8d737b86a1d6 100644
--- a/arch/x86/virt/vmx/tdx/tdx.c
+++ b/arch/x86/virt/vmx/tdx/tdx.c
@@ -1309,7 +1309,7 @@ static __init int tdx_ext_mem_setup(void)
return ret;
}

-static __init int tdx_ext_init(void)
+static int tdx_ext_init(void)
{
struct tdx_module_args args = {};
u64 ret;
@@ -1340,6 +1340,19 @@ static __init int init_tdx_module_extensions(void)
return tdx_ext_init();
}

+/*
+ * Don't update the memory requirement or try memory allocation in
+ * stop_machine(). If an incompatible update requires more memory, let the
+ * extensions re-initialization fail.
+ */
+static int reinit_tdx_module_extensions(void)
+{
+ if (!(tdx_sysinfo.features.tdx_features0 & TDX_FEATURES0_EXT))
+ return 0;
+
+ return tdx_ext_init();
+}
+
static __init int init_tdx_module(void)
{
int ret;
@@ -1517,6 +1530,10 @@ int tdx_module_run_update(void)
if (ret)
return ret;

+ ret = reinit_tdx_module_extensions();
+ if (ret)
+ return ret;
+
ret = get_tdx_sys_info_version(&tdx_sysinfo.version);
/*
* Only fails if there is something unexpected