From: Aristo Chen <jj251510319013@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: jens.wiklander@linaro.org, sumit.garg@kernel.org,
op-tee@lists.trustedfirmware.org, harshal.dev@oss.qualcomm.com,
mario.limonciello@amd.com, Rijo-john.Thomas@amd.com,
amirreza.zarrabi@oss.qualcomm.com,
Aristo Chen <aristo.chen@canonical.com>
Subject: [PATCH v5 1/2] tee: add revision sysfs attribute
Date: Wed, 7 Jan 2026 23:26:01 +0800 [thread overview]
Message-ID: <20260107152607.902735-1-aristo.chen@canonical.com> (raw)
In-Reply-To: <20251230051804.6230-1-aristo.chen@canonical.com>
Add a generic TEE revision sysfs attribute backed by a new
optional get_tee_revision() callback. The revision string is
diagnostic-only and must not be used to infer feature support.
Signed-off-by: Aristo Chen <aristo.chen@canonical.com>
---
Documentation/ABI/testing/sysfs-class-tee | 10 +++++
drivers/tee/tee_core.c | 51 ++++++++++++++++++++++-
include/linux/tee_core.h | 9 ++++
3 files changed, 69 insertions(+), 1 deletion(-)
diff --git a/Documentation/ABI/testing/sysfs-class-tee b/Documentation/ABI/testing/sysfs-class-tee
index c9144d16003e..6e783210104e 100644
--- a/Documentation/ABI/testing/sysfs-class-tee
+++ b/Documentation/ABI/testing/sysfs-class-tee
@@ -13,3 +13,13 @@ Description:
space if the variable is absent. The primary purpose
of this variable is to let systemd know whether
tee-supplicant is needed in the early boot with initramfs.
+
+What: /sys/class/tee/tee{,priv}X/revision
+Date: Dec 2025
+KernelVersion: 6.18
+Contact: op-tee@lists.trustedfirmware.org
+Description:
+ Read-only revision string reported by the TEE driver. This is
+ for diagnostics only and must not be used to infer feature
+ support. Use TEE_IOC_VERSION for capability and compatibility
+ checks.
diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c
index d65d47cc154e..0a00499811c1 100644
--- a/drivers/tee/tee_core.c
+++ b/drivers/tee/tee_core.c
@@ -1146,7 +1146,56 @@ static struct attribute *tee_dev_attrs[] = {
NULL
};
-ATTRIBUTE_GROUPS(tee_dev);
+static const struct attribute_group tee_dev_group = {
+ .attrs = tee_dev_attrs,
+};
+
+static ssize_t revision_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct tee_device *teedev = container_of(dev, struct tee_device, dev);
+ char version[TEE_REVISION_STR_SIZE];
+ int ret;
+
+ if (!teedev->desc->ops->get_tee_revision)
+ return -ENODEV;
+
+ ret = teedev->desc->ops->get_tee_revision(teedev, version,
+ sizeof(version));
+ if (ret)
+ return ret;
+
+ return sysfs_emit(buf, "%s\n", version);
+}
+static DEVICE_ATTR_RO(revision);
+
+static struct attribute *tee_revision_attrs[] = {
+ &dev_attr_revision.attr,
+ NULL
+};
+
+static umode_t tee_revision_attr_is_visible(struct kobject *kobj,
+ struct attribute *attr, int n)
+{
+ struct device *dev = kobj_to_dev(kobj);
+ struct tee_device *teedev = container_of(dev, struct tee_device, dev);
+
+ if (teedev->desc->ops->get_tee_revision)
+ return attr->mode;
+
+ return 0;
+}
+
+static const struct attribute_group tee_revision_group = {
+ .attrs = tee_revision_attrs,
+ .is_visible = tee_revision_attr_is_visible,
+};
+
+static const struct attribute_group *tee_dev_groups[] = {
+ &tee_dev_group,
+ &tee_revision_group,
+ NULL
+};
static const struct class tee_class = {
.name = "tee",
diff --git a/include/linux/tee_core.h b/include/linux/tee_core.h
index 1f3e5dad6d0d..ee5f0bd41f43 100644
--- a/include/linux/tee_core.h
+++ b/include/linux/tee_core.h
@@ -76,6 +76,9 @@ struct tee_device {
/**
* struct tee_driver_ops - driver operations vtable
* @get_version: returns version of driver
+ * @get_tee_revision: returns revision string (diagnostic only);
+ * do not infer feature support from this, use
+ * TEE_IOC_VERSION instead
* @open: called for a context when the device file is opened
* @close_context: called when the device file is closed
* @release: called to release the context
@@ -95,9 +98,12 @@ struct tee_device {
* client closes the device file, even if there are existing references to the
* context. The TEE driver can use @close_context to start cleaning up.
*/
+
struct tee_driver_ops {
void (*get_version)(struct tee_device *teedev,
struct tee_ioctl_version_data *vers);
+ int (*get_tee_revision)(struct tee_device *teedev,
+ char *buf, size_t len);
int (*open)(struct tee_context *ctx);
void (*close_context)(struct tee_context *ctx);
void (*release)(struct tee_context *ctx);
@@ -123,6 +129,9 @@ struct tee_driver_ops {
int (*shm_unregister)(struct tee_context *ctx, struct tee_shm *shm);
};
+/* Size for TEE revision string buffer used by get_tee_revision(). */
+#define TEE_REVISION_STR_SIZE 128
+
/**
* struct tee_desc - Describes the TEE driver to the subsystem
* @name: name of driver
--
2.43.0
next prev parent reply other threads:[~2026-01-07 15:26 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-21 14:12 [PATCH v1 1/1] tee: optee: expose OS revision via sysfs Wei Ming Chen
2025-11-22 7:36 ` Harshal Dev
2025-11-22 14:59 ` [PATCH v2 " Wei Ming Chen
2025-11-24 7:15 ` Jens Wiklander
2025-11-25 7:53 ` Sumit Garg
2025-11-25 7:55 ` Sumit Garg
2025-12-01 11:47 ` Aristo Chen
2025-12-01 13:06 ` Jens Wiklander
2025-12-02 9:54 ` Aristo Chen
2025-12-03 7:50 ` Jens Wiklander
2025-12-07 14:01 ` Aristo Chen
2025-12-09 8:30 ` Jens Wiklander
2025-12-19 15:38 ` Aristo Chen
2025-12-22 8:34 ` Jens Wiklander
2025-12-22 10:07 ` Sumit Garg
2025-12-26 13:19 ` [PATCH v3 " Aristo Chen
2025-12-29 4:59 ` Sumit Garg
2025-12-30 5:17 ` [PATCH v4 1/2] tee: add revision sysfs attribute Aristo Chen
2025-12-30 5:17 ` [PATCH v4 2/2] tee: optee: store OS revision for TEE core Aristo Chen
2026-01-05 5:20 ` Sumit Garg
2026-01-05 8:13 ` Aristo Chen
2026-01-05 8:48 ` Sumit Garg
2026-01-05 4:53 ` [PATCH v4 1/2] tee: add revision sysfs attribute Sumit Garg
2026-01-07 15:26 ` Aristo Chen [this message]
2026-01-07 15:26 ` [PATCH v5 2/2] tee: optee: store OS revision for TEE core Aristo Chen
2026-01-07 15:28 ` [PATCH v5 1/2] tee: add revision sysfs attribute Mario Limonciello
2026-01-08 2:55 ` Aristo Chen
2026-01-08 3:01 ` Mario Limonciello (AMD) (kernel.org)
2026-01-08 6:45 ` [PATCH v6 " Aristo Chen
2026-01-08 6:45 ` [PATCH v6 2/2] tee: optee: store OS revision for TEE core Aristo Chen
2026-01-09 11:50 ` Sumit Garg
2026-01-09 15:07 ` Aristo Chen
2026-01-12 11:22 ` Sumit Garg
2026-01-12 9:55 ` Jens Wiklander
2026-01-12 10:43 ` Aristo Chen
2026-01-09 11:48 ` [PATCH v6 1/2] tee: add revision sysfs attribute Sumit Garg
2026-01-12 9:50 ` Jens Wiklander
2026-01-12 15:48 ` [PATCH v7 " Aristo Chen
2026-01-12 15:48 ` [PATCH v7 2/2] tee: optee: store OS revision for TEE core Aristo Chen
2026-01-14 15:43 ` Jens Wiklander
2026-01-15 6:18 ` Sumit Garg
2026-01-14 15:42 ` [PATCH v7 1/2] tee: add revision sysfs attribute Jens Wiklander
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=20260107152607.902735-1-aristo.chen@canonical.com \
--to=jj251510319013@gmail.com \
--cc=Rijo-john.Thomas@amd.com \
--cc=amirreza.zarrabi@oss.qualcomm.com \
--cc=aristo.chen@canonical.com \
--cc=harshal.dev@oss.qualcomm.com \
--cc=jens.wiklander@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=op-tee@lists.trustedfirmware.org \
--cc=sumit.garg@kernel.org \
/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
all inboxes | Powered by JetHome®