Re: [PATCH v9 05/23] coco/tdx-host: Expose TDX module version

From: Dave Hansen

Date: Fri May 15 2026 - 13:09:34 EST


On 5/13/26 08:09, Chao Gao wrote:
> For TDX module updates, userspace needs to select compatible update
> versions based on the current module version. This design delegates
> module selection complexity to userspace because TDX module update
> policies are complex and version series are platform-specific.

I'm not sure exactly what a "version series" is. Do you need to say more
than that the policy is complex?

> For example, the 1.5.x series is for certain platform generations, while
> the 2.0.x series is intended for others. And TDX module 1.5.x may be
> updated to 1.5.y but not to 1.5.y+1.

That's not much of an example, IMNHO. How about:

For example, the 1.5.x series runs on Sapphire Rapids but not
Granite Rapids, which needs 2.0.x. Updates are also constrained
by version distance, so a 1.5.6 module might permit updates to
1.5.7 but not to 1.5.20.

> Expose the TDX module version to userspace via sysfs to aid module
> selection. Since the TDX faux device will drive module updates, expose
> the version as its attribute.
>
> One bonus of exposing TDX module version via sysfs is: TDX module
> version information remains available even after dmesg logs are cleared.

I honestly wouldn't even mention this bit. You don't need a bonus.

> +++ b/Documentation/ABI/testing/sysfs-devices-faux-tdx-host
> @@ -0,0 +1,6 @@
> +What: /sys/devices/faux/tdx_host/version
> +Contact: linux-coco@xxxxxxxxxxxxxxx
> +Description: (RO) Report the version of the loaded TDX module. The TDX module
> + version is formatted as x.y.z, where "x" is the major version,
> + "y" is the minor version and "z" is the update version. Versions
> + are used for bug reporting, TDX module updates etc.

The "etc." is silly. Just zap it.

Description: (RO) Report the version of the loaded TDX module.
Formatted as "major.minor.update". Used by TDX module
update tooling. Example: "1.2.03"

That's at least a wee bit of warning to folks about the leading 0 so if
they are parsing it they are a wee bit careful with it.

> diff --git a/arch/x86/include/asm/tdx.h b/arch/x86/include/asm/tdx.h
> index 8b739ac01479..b7f4396b5cc5 100644
> --- a/arch/x86/include/asm/tdx.h
> +++ b/arch/x86/include/asm/tdx.h
> @@ -41,6 +41,12 @@
> #include <asm/tdx_global_metadata.h>
> #include <linux/pgtable.h>
>
> +/*
> + * TDX module and P-SEAMLDR version convention: "major.minor.update"
> + * (e.g., "1.5.08") with zero-padded two-digit update field.
> + */
> +#define TDX_VERSION_FMT "%u.%u.%02u"

I hate "e.g.". I'm not sure why, but maybe it it often misused, or that
it isn't allowed by the style guide I had to use in high school. Either
way, please stop using it.

You don't have to modify this patch for it, but please stop.

Second, this was an opportunity to peel out the creation of
"TDX_VERSION_FMT". It would have shrunk your series by ~10 lines and
made this patch more obvious.

Again, you don't have to go do it, but it was a missed opportunity.


With those updates:

Reviewed-by: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>