Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tee: add revision sysfs attribute

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>
Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>

authored by

Aristo Chen and committed by
Jens Wiklander
241bdf72 8f0b4cce

+69 -1
+10
Documentation/ABI/testing/sysfs-class-tee
··· 13 13 space if the variable is absent. The primary purpose 14 14 of this variable is to let systemd know whether 15 15 tee-supplicant is needed in the early boot with initramfs. 16 + 17 + What: /sys/class/tee/tee{,priv}X/revision 18 + Date: Jan 2026 19 + KernelVersion: 6.19 20 + Contact: op-tee@lists.trustedfirmware.org 21 + Description: 22 + Read-only revision string reported by the TEE driver. This is 23 + for diagnostics only and must not be used to infer feature 24 + support. Use TEE_IOC_VERSION for capability and compatibility 25 + checks.
+50 -1
drivers/tee/tee_core.c
··· 1146 1146 NULL 1147 1147 }; 1148 1148 1149 - ATTRIBUTE_GROUPS(tee_dev); 1149 + static const struct attribute_group tee_dev_group = { 1150 + .attrs = tee_dev_attrs, 1151 + }; 1152 + 1153 + static ssize_t revision_show(struct device *dev, 1154 + struct device_attribute *attr, char *buf) 1155 + { 1156 + struct tee_device *teedev = container_of(dev, struct tee_device, dev); 1157 + char version[TEE_REVISION_STR_SIZE]; 1158 + int ret; 1159 + 1160 + if (!teedev->desc->ops->get_tee_revision) 1161 + return -ENODEV; 1162 + 1163 + ret = teedev->desc->ops->get_tee_revision(teedev, version, 1164 + sizeof(version)); 1165 + if (ret) 1166 + return ret; 1167 + 1168 + return sysfs_emit(buf, "%s\n", version); 1169 + } 1170 + static DEVICE_ATTR_RO(revision); 1171 + 1172 + static struct attribute *tee_revision_attrs[] = { 1173 + &dev_attr_revision.attr, 1174 + NULL 1175 + }; 1176 + 1177 + static umode_t tee_revision_attr_is_visible(struct kobject *kobj, 1178 + struct attribute *attr, int n) 1179 + { 1180 + struct device *dev = kobj_to_dev(kobj); 1181 + struct tee_device *teedev = container_of(dev, struct tee_device, dev); 1182 + 1183 + if (teedev->desc->ops->get_tee_revision) 1184 + return attr->mode; 1185 + 1186 + return 0; 1187 + } 1188 + 1189 + static const struct attribute_group tee_revision_group = { 1190 + .attrs = tee_revision_attrs, 1191 + .is_visible = tee_revision_attr_is_visible, 1192 + }; 1193 + 1194 + static const struct attribute_group *tee_dev_groups[] = { 1195 + &tee_dev_group, 1196 + &tee_revision_group, 1197 + NULL 1198 + }; 1150 1199 1151 1200 static const struct class tee_class = { 1152 1201 .name = "tee",
+9
include/linux/tee_core.h
··· 76 76 /** 77 77 * struct tee_driver_ops - driver operations vtable 78 78 * @get_version: returns version of driver 79 + * @get_tee_revision: returns revision string (diagnostic only); 80 + * do not infer feature support from this, use 81 + * TEE_IOC_VERSION instead 79 82 * @open: called for a context when the device file is opened 80 83 * @close_context: called when the device file is closed 81 84 * @release: called to release the context ··· 98 95 * client closes the device file, even if there are existing references to the 99 96 * context. The TEE driver can use @close_context to start cleaning up. 100 97 */ 98 + 101 99 struct tee_driver_ops { 102 100 void (*get_version)(struct tee_device *teedev, 103 101 struct tee_ioctl_version_data *vers); 102 + int (*get_tee_revision)(struct tee_device *teedev, 103 + char *buf, size_t len); 104 104 int (*open)(struct tee_context *ctx); 105 105 void (*close_context)(struct tee_context *ctx); 106 106 void (*release)(struct tee_context *ctx); ··· 128 122 unsigned long start); 129 123 int (*shm_unregister)(struct tee_context *ctx, struct tee_shm *shm); 130 124 }; 125 + 126 + /* Size for TEE revision string buffer used by get_tee_revision(). */ 127 + #define TEE_REVISION_STR_SIZE 128 131 128 132 129 /** 133 130 * struct tee_desc - Describes the TEE driver to the subsystem