From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DEF98192B75 for ; Mon, 12 Jan 2026 15:48:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.188.123 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768232936; cv=none; b=OQwxWGhi5P6N/Usfd8zxh9bmU1y2OVevCqTzDxIabvqDDSLN+6pGGhH74qE0Z/EbKZ2UjQErY6ON4kQSeHVS4T+KFNoVNdWV8a64HtHjikOis2eXN2Ya6RfL3sSZqUsPisnd3Ibs9pv82NfWoVzO4RBMJ8pFHqhgIB8N3vH1Da0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768232936; c=relaxed/simple; bh=w8Br0L/bvT0WYuEE5EQYLkiDsJ01wSvNIL/fKdsiaN8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OLPn+5mN3DhMb9FhlILZqP+q7ckKwO+lPxWKgfe7Uo7RKNneqU1ThOLNo3vWUinVyaR9MNmLYQL0ZIWx3Oizyeai7TgcmuEZCURfiORhf+jjmY/vcaT64kX5ZKk5bi/DUayJ3M12fOpU4zP62wGwDD+fYX2jvCCP2ALLZz8eIYo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=canonical.com; spf=pass smtp.mailfrom=canonical.com; dkim=pass (4096-bit key) header.d=canonical.com header.i=@canonical.com header.b=M4yBFLd9; arc=none smtp.client-ip=185.125.188.123 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=canonical.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=canonical.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (4096-bit key) header.d=canonical.com header.i=@canonical.com header.b="M4yBFLd9" Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 61D0D3F85D for ; Mon, 12 Jan 2026 15:48:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20251003; t=1768232925; bh=xi3tAFA0h0hr2WA+gvytumViirCUvRbeCoU37OBza2k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=M4yBFLd9vPeIucAaF+WK2RIdl9bEBTs+cZWkIN++sYqsknC+IqXs+UWXOx0D4yzx+ JuwjZLgM/KO3VKwZgJTOYsghzVIaK6PunjrXI4TJSVwVPahED1Gvwh3B3ozaUN6WiX h/+a/DHgsuU8JdywSVL/5iaYV/KZVS8gbMtTdJgEBju2Yde12DbCyTFMhMSX7z+W+I qf1njMlC02/gdNbkJ7tjsP7ESmkzrBXv6DJLuogxwnErbasidWEVTf3zZOvT795go5 Wg6KZ6nD6BQvOGYr1wshMPkOKE95fUMmz41cDmktPcsh1mCXN+fPxcDhX9/d/GT782 bSIed0gUamxxsT+RRcgU+Dc3D+gcl/C990JGLeqh+hvgV1obm7yIqCyC0Bnqn2ZSBI 1mnK6J1MY8S9Xz0sZe+a51B648lUMufDGdmIuj9myheKnU2f5pb+DrC8r0Nx+rVwxW Edz/qs4DnjS40iScAHMdFbPoaP0B5WAMoHzfJ3c0vvKIknO5xK51V+7/9i0r8z3kpO SMteaYLWucNSc+v4RL/FgIJWXv+MWCbygD9IPkbvFJgiSUnLwa4E34cQsLXvR0Hab/ vDJF9QDwLTGd1I0UK/S1AY1ta9awKVlsqGI4iB0/xLgu7A1ax3PWRUkVl+5suaU9wr POEPBc8ybDorEJqU5W5FF6n4= Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-29f13989cd3so153794115ad.1 for ; Mon, 12 Jan 2026 07:48:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768232923; x=1768837723; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=xi3tAFA0h0hr2WA+gvytumViirCUvRbeCoU37OBza2k=; b=mzfA6KgZkhV+GqrtAGzbr8u8akOJ0FbzO1auVkZsNnn6IHrCnqp1j5vP/kZxt1Sdu5 y31QD75GEnT8Ef2Qu95SlJ2hlhKafjUl+XtaVCvAAHvRxy23xASI6hQWRGtNR5hEfSeJ aGfbQsz8aeZc5KopdeVgEBMeKFG7eWxvElFOckCUpJvtGYJ/n0DUZ+Cf2D+FiwWIMS6G 1Sclcfh4i3aExNxzPS/3AvTAqJCwD3Fog842OloGgaVpd2gcEF+8FDvYzqFKefRl5DsE 524v9X4ySXDSJnD4cU+BHaLL8IPShKROAoi3txaaLKZWVdpsoDzwvHYgRaOb7wXDXWU4 YaIg== X-Gm-Message-State: AOJu0YwXVdFbQEDuoQW7GFCFyMIPZlpBnnCYGsFK4/RCmhDrA0DFeCI3 CGMz92QunDT9XtzhNMOBOBl2OB1afVROLgV1nWR6sh5wEQoTIctNcO+lpwGdc+hFTsWrEBS6gDX 6JOK9Dp4cLln5C0THafeX/REFwd52/MXmDzEAV975yhKYxlErYq8xjznrgPw9T4jvJiKkWqbi3b ZHEv/QUXVh1h1rPw== X-Gm-Gg: AY/fxX4a0PPLni24bCdC93lt69KfkySnsNRAM+JBNJbgVX6hLPr4MJwCDxPKrMZhk11 Nl3IbnWnj3kyvHNG2TqZadx6irSJ2NJ1GfAoAn2cdR6q/mh/u4JzdbZXoDua/4qYTPW99Y0Oxyy 7Y2INpMhP2JJTdWTBphRuDoqJMCapH3jEZffK/8fWrCAcKoq3zrzk79WMvkvH2H8Ngo74+CBcpe BfXTh2RVeN+f8tLxx+bDclSyTvd7htz9hrjulh1wrd4kXT5k1C/QOzjWoCB9mvajYW5lOt4hjJX szGt2KxdM7YoPKFXwnuOPOxLU6Q6RFX4gwFtZ7pv7SYt52nPJJK1X+EH/nRwAvDuMl1ojBV4eBo xfWbLIkoHz6GuZycJIPa4wxBQZ3MxvHPZMuhlg5RKmu3SG/Fq7To5S7Z4Keux1nZv/8Re32bYPv kL X-Received: by 2002:a17:903:2f92:b0:2a0:8be7:e3db with SMTP id d9443c01a7336-2a3ee42890dmr169947725ad.15.1768232923273; Mon, 12 Jan 2026 07:48:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IFG/Bdn9kh6d1Xbnfdr5evlOqrHZcbZ2VvlEKi2xSB4T5mW6NERFUM50hkryRjTdzpYjRmIIw== X-Received: by 2002:a17:903:2f92:b0:2a0:8be7:e3db with SMTP id d9443c01a7336-2a3ee42890dmr169947465ad.15.1768232922877; Mon, 12 Jan 2026 07:48:42 -0800 (PST) Received: from aristo-PC.tail872496.ts.net (124-218-37-86.cm.dynamic.apol.com.tw. [124.218.37.86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2a3e3cb2debsm180204745ad.65.2026.01.12.07.48.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jan 2026 07:48:42 -0800 (PST) From: Aristo Chen 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 , Sumit Garg Subject: [PATCH v7 1/2] tee: add revision sysfs attribute Date: Mon, 12 Jan 2026 23:48:29 +0800 Message-ID: <20260112154833.78546-1-aristo.chen@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260108064517.13854-1-aristo.chen@canonical.com> References: <20260108064517.13854-1-aristo.chen@canonical.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Sumit Garg --- 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..1a0a3050aaa9 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: Jan 2026 +KernelVersion: 6.19 +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