From: Chao Gao <chao.gao@intel.com>
To: linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, x86@kernel.org
Cc: Chao Gao <chao.gao@intel.com>,
"Kirill A. Shutemov" <kas@kernel.org>,
Dave Hansen <dave.hansen@linux.intel.com>,
Dan Williams <dan.j.williams@intel.com>,
Xu Yilun <yilun.xu@linux.intel.com>
Subject: [PATCH 2/2] coco/tdx-host: Expose TDX module version
Date: Tue, 30 Sep 2025 19:22:45 -0700 [thread overview]
Message-ID: <20251001022309.277238-3-chao.gao@intel.com> (raw)
In-Reply-To: <20251001022309.277238-1-chao.gao@intel.com>
Currently these is no way to know the TDX module version from the
userspace. such information is helpful for bug reporting or
debugging.
With the tdx-host device in place, expose the TDX module version as
a device attribute via sysfs.
Signed-off-by: Chao Gao <chao.gao@intel.com>
---
.../ABI/testing/sysfs-devices-faux-tdx-host | 6 +++++
MAINTAINERS | 1 +
drivers/virt/coco/tdx-host/tdx-host.c | 25 ++++++++++++++++++-
3 files changed, 31 insertions(+), 1 deletion(-)
create mode 100644 Documentation/ABI/testing/sysfs-devices-faux-tdx-host
diff --git a/Documentation/ABI/testing/sysfs-devices-faux-tdx-host b/Documentation/ABI/testing/sysfs-devices-faux-tdx-host
new file mode 100644
index 000000000000..18d4a4a71b80
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-devices-faux-tdx-host
@@ -0,0 +1,6 @@
+What: /sys/devices/faux/tdx_host/version
+Contact: linux-coco@lists.linux.dev
+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, TD-Preserving updates and etc.
diff --git a/MAINTAINERS b/MAINTAINERS
index c1ad1294560c..7560dcf8a53d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -27333,6 +27333,7 @@ L: x86@kernel.org
L: linux-coco@lists.linux.dev
S: Supported
T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86/tdx
+F: Documentation/ABI/testing/sysfs-devices-faux-tdx-host
F: Documentation/ABI/testing/sysfs-devices-virtual-misc-tdx_guest
F: arch/x86/boot/compressed/tdx*
F: arch/x86/coco/tdx/
diff --git a/drivers/virt/coco/tdx-host/tdx-host.c b/drivers/virt/coco/tdx-host/tdx-host.c
index 49c205913ef6..968a19f4e01a 100644
--- a/drivers/virt/coco/tdx-host/tdx-host.c
+++ b/drivers/virt/coco/tdx-host/tdx-host.c
@@ -22,6 +22,29 @@ MODULE_DEVICE_TABLE(x86cpu, tdx_host_ids);
static struct faux_device *fdev;
+static ssize_t version_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ const struct tdx_sys_info *tdx_sysinfo = tdx_get_sysinfo();
+ const struct tdx_sys_info_version *ver;
+
+ if (!tdx_sysinfo)
+ return -ENXIO;
+
+ ver = &tdx_sysinfo->version;
+
+ return sysfs_emit(buf, "%u.%u.%02u\n", ver->major_version,
+ ver->minor_version,
+ ver->update_version);
+}
+static DEVICE_ATTR_RO(version);
+
+static struct attribute *tdx_host_attrs[] = {
+ &dev_attr_version.attr,
+ NULL,
+};
+ATTRIBUTE_GROUPS(tdx_host);
+
static int __init tdx_host_init(void)
{
int r;
@@ -34,7 +57,7 @@ static int __init tdx_host_init(void)
if (r)
return r;
- fdev = faux_device_create(KBUILD_MODNAME, NULL, NULL);
+ fdev = faux_device_create_with_groups(KBUILD_MODNAME, NULL, NULL, tdx_host_groups);
if (!fdev)
return -ENODEV;
--
2.47.3
next prev parent reply other threads:[~2025-10-01 2:23 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-01 2:22 [PATCH 0/2] Expose TDX Module version Chao Gao
2025-10-01 2:22 ` [PATCH 1/2] x86/virt/tdx: Retrieve TDX module version Chao Gao
2025-10-01 15:15 ` Dave Hansen
2025-10-22 7:54 ` Chao Gao
2025-10-22 10:26 ` Kiryl Shutsemau
2025-10-24 6:33 ` Chao Gao
2025-10-24 9:35 ` Kiryl Shutsemau
2025-10-24 10:04 ` Chao Gao
2025-11-13 1:24 ` Chao Gao
2025-10-24 14:20 ` Vishal Annapurve
2025-10-01 2:22 ` Chao Gao [this message]
2025-10-01 4:12 ` [PATCH 2/2] coco/tdx-host: Expose " Huang, Kai
2025-10-01 11:27 ` Kiryl Shutsemau
2025-10-01 21:41 ` Huang, Kai
2025-10-01 11:30 ` Kiryl Shutsemau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251001022309.277238-3-chao.gao@intel.com \
--to=chao.gao@intel.com \
--cc=dan.j.williams@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=kas@kernel.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=x86@kernel.org \
--cc=yilun.xu@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).