From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 9E7381E3DCD for ; Sat, 22 Nov 2025 07:36:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763796981; cv=none; b=Q5rP8oXIFLJebXTxcTYt5nOzbZIGFeYHuOXIwVnvFpneczG/8yQF58E9OLQNYXpBY+mAS/k+DGsbn+TQNrivYV6Il0iO28fwF9pdqOQrYjaQNgKBjCUgsgj2pIhtEslgqB7bzE0zuFcPlkqoNFiINA07z8JUzCgFAoutljOAuTU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763796981; c=relaxed/simple; bh=NjfENa1FrLwX1H8CRzUQmrrEDFdgdcTHfjYAF52TBv8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=qUbKFV4keg9IC94gBUwCok5k9lIuTqbQ7CuNzToWmfW9WfF5EGYoLf6uVrnWC6DQppyEEPlFiihmQ7Q9B1qoGCQPwy6pVKQopDFvy88IQNJE0PNJA/+U6KJ+J/ToXZxaAkS9JMLpTXl3zr3Toea1ASMNioU/tzPYdAaDRrZJCv4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=FayXtBby; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=QNQNshp7; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="FayXtBby"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="QNQNshp7" Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5AM5GatR1591930 for ; Sat, 22 Nov 2025 07:36:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= jqPmH2E5g3Oum7EG9ICeoiYXWxo+ajqE4bwyyao38Nk=; b=FayXtBbykfRtPwiq 586K2zD9KouB6vQy2cWHOHH+w/MylqYV5rju3wn2JDo8DAO4gWyFIm2YwCjbfU96 4zE1/w8BD6FiiSiZ5u/3ZS4i6fwfsOp907J23xPPgL8TyVn12KvS9HAUu7EjlTVu 0JKbTgKVhPrZwfjbXh64othHNogYlY9i3jt31D9y5iS4yk2PVXHIGQzEnTD5nD8w WyUMVoj9a4BK4feDaLjph+r5i1M40rz+ln/mdS0wM5p6ELXJI7elSlROHUGDJjNM 8qLF9oNYlNoDHLfCT1o0astSX4XjkkbKFeDI8wR0xuKYwilvL51w+g51oOpsRcqk XlIkpA== Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4ak68dr83k-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Sat, 22 Nov 2025 07:36:18 +0000 (GMT) Received: by mail-pf1-f199.google.com with SMTP id d2e1a72fcca58-7b89c1ce9cfso2961992b3a.2 for ; Fri, 21 Nov 2025 23:36:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1763796978; x=1764401778; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=jqPmH2E5g3Oum7EG9ICeoiYXWxo+ajqE4bwyyao38Nk=; b=QNQNshp7jCoAWFbmf10OgSNnrFod5804V++aicVKTV200s4Hp7jQovhkI5ciKbJdO4 hjuSMMZ3XlcNL5nrYw4ESmEp2RfFDxmHpLEsFg5sOLbhLXq8s0GXFF8myl8d+s29bRdi OldgwRB64l3e0xmtS6BZDMg6KpC9TsSeOfhlU31Kj076TlyfetqJzBzSZMVt2jnJqogH l/jK3t1pVDrC2uPhf28qaZy0/TXAOH/6kRh593E9ElAgRezmp/8f1eR4jsrzJ5w5KYII jNOJXrEQ0WOblptJ4ubWEOArTEv9FjW7CGUCKEqt9ohuI7gyGf3dKC2MSSPYiSUeZFz5 vTHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763796978; x=1764401778; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=jqPmH2E5g3Oum7EG9ICeoiYXWxo+ajqE4bwyyao38Nk=; b=OEyYo8IMQhrJnNPBYXf6NMlTo9doyullsJHzQuLnnwgNXtNW4rPaG7DzGCc7i2WpOF LWg2AkY+a9wTdcEEYbagbOTAXLDZuZTkoNKRee2DVMv691l8XykdZbls8/LG3cbHpIGi rGwhw+xibalQfAke5iH1Ur91U0OCo5cUyDNrl6uz9i5Vc2MSLgJGRSAbJiEGmv2w5QHE mREsOud7FbrU5kXwkbUSIlVomqmF4sB4QkKPqo+7G1vO1ZtmACQcPozE959g4CDXadpq IVnr+54Dbi8vpeNkT7pe5PXhadzLSQn9YtSPWJi+xMSP+af2EhwBJBsZJPw5Au+BttzA z3Aw== X-Forwarded-Encrypted: i=1; AJvYcCVWpDEqTXZekPiwRJis9tB/ki2DmkltyTSp2iReIKRFVQxzKLPJrxy/HrxhQqIo21RKkTyG1YmjIFNxIcI=@vger.kernel.org X-Gm-Message-State: AOJu0YyhTvOOjhZPXlnu8O0JeRRCvjbyHeUrI3vO2lq9F6y9zWfceKFY gebxw+OjwzewuJ561ZhF/RMA2a8OQfmF/PtXaKhzii3nJBF4d3CikV66hWDGlOqelDOs26abJSx 6HYfJBlzZNCbexA8p8AfRMND47JYMSOKIRMH7EsGfCvd4QdR+Z9NJ9WSnTXPXhlv5LyUz+dfclh M= X-Gm-Gg: ASbGncunYgNHo0F9TOngUF6jmsmr0B7/9Ah03nW5aStITzxoVw2wEc4CbNzhb90Pgxx rvLtZZIbWsbpdp8XBPmt4si00ihblC0H1yDB7Bhm9JofSttLweNRmVk8UVJ3K/Cl2WeBm/j603K nRXRM2L9EuQzcYJZ92ZXyIhULhz7F3bGuziGKcusBwqLK2uUpX3MjDk81lDQJCc887zuAhXbUDk g7dRbavqFBNhu5PCGMtiGew3kLUivtQ1Bcol8Yd2sRwSpYMR/SalMYioyaTDk83+KqAhQgVH+cV aEgEj8kN5LjvbMdvQJOJcvd0pfxltDpRWR8dgiQ4NnsZ/KW4ymfCcIBfWixoPNpAEY0OUOb431w MitH6db9uvHR23KmT6aJwmBWlV2St88zsxPMdO5Bm X-Received: by 2002:a05:6a00:a1d:b0:7ab:54ce:998d with SMTP id d2e1a72fcca58-7c58e606253mr4443317b3a.23.1763796977655; Fri, 21 Nov 2025 23:36:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IHBgKlpNhEjrKy6K6cML1N0QHg4O9Eyf247uGwqJTfejZyGR5nMoC2Pf0IZHb5GEViLuOaNEw== X-Received: by 2002:a05:6a00:a1d:b0:7ab:54ce:998d with SMTP id d2e1a72fcca58-7c58e606253mr4443305b3a.23.1763796977198; Fri, 21 Nov 2025 23:36:17 -0800 (PST) Received: from [192.168.29.116] ([49.37.148.233]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7c3f0d65682sm8257206b3a.56.2025.11.21.23.36.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 21 Nov 2025 23:36:16 -0800 (PST) Message-ID: Date: Sat, 22 Nov 2025 13:06:12 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 1/1] tee: optee: expose OS revision via sysfs To: Wei Ming Chen , linux-kernel@vger.kernel.org Cc: sumit.garg@kernel.org, op-tee@lists.trustedfirmware.org, Aristo Chen References: <20251121141230.489294-1-jj251510319013@gmail.com> Content-Language: en-US From: Harshal Dev In-Reply-To: <20251121141230.489294-1-jj251510319013@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTIyMDA1OSBTYWx0ZWRfX0Q1Noe/ihfDK YpNlslzH+BdFx+KYGfIPAgSggsE7pjWQEWxfWRCQVpS/kahuzsmsFQ+D22bcDU9/vWaOlYDXOSp Bu31MWcmC27xT4kPxa1eOTH3G9J6MTPAUG3gz43FkTINlssXoqTILBb4bF7/zy/2wN25Cxl/5kT 0W+mKtnsVWrriWz2s/fxRBBtqTKTphchlPqGCOn/jI7XRdA3aCDZafXZZrM1OERkkiELv3SgmwR 2+v91ypMSNCeZbOIMBRx7u1mjLY5Km/LtBD+oXo1fApw7Drl5zqs2nYHUcrYlS2GoxFIjqrDfyS O/A7VgutIcmPsxfqjf8nA2eDVtiC3RZDaDR52ZUSyEsQyvItY7koPAi0ou9A5Jyb3uySUqsbdjS YzkZn6USoL9ZO9t/X8fT3+TY+HhygQ== X-Proofpoint-GUID: 6r4vAb_eD3q17V-dqNNU9rxPGUBHuh7P X-Proofpoint-ORIG-GUID: 6r4vAb_eD3q17V-dqNNU9rxPGUBHuh7P X-Authority-Analysis: v=2.4 cv=UsBu9uwB c=1 sm=1 tr=0 ts=692167f2 cx=c_pps a=WW5sKcV1LcKqjgzy2JUPuA==:117 a=v+kbWGyw1T97G6+vs1uYIQ==:17 a=IkcTkHD0fZMA:10 a=6UeiqGixMTsA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=DfNHnWVPAAAA:8 a=iFz-G_-NId9Z4KFAPR0A:9 a=QEXdDO2ut3YA:10 a=OpyuDcXvxspvyRM73sMx:22 a=rjTVMONInIDnV1a_A2c_:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-11-22_02,2025-11-21_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 priorityscore=1501 impostorscore=0 phishscore=0 suspectscore=0 lowpriorityscore=0 clxscore=1011 malwarescore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2511220059 Hi Aristo, On 11/21/2025 7:42 PM, Wei Ming Chen wrote: > From: Aristo Chen > > Today the only way to read the OP-TEE OS version is from dmesg/journal > logs, which can be lost as buffers roll over. Add a minimal > optee_version_info (major/minor/build) and get_optee_revision hook, > collect the OS revision in both SMC and FF-A ABIs, and publish > /sys/class/tee/tee*/optee_os_revision for a stable userspace readout. > > Signed-off-by: Aristo Chen > --- > drivers/tee/optee/ffa_abi.c | 27 +++++++++++- > drivers/tee/optee/optee_private.h | 1 + > drivers/tee/optee/smc_abi.c | 27 +++++++++++- > drivers/tee/tee_core.c | 73 ++++++++++++++++++++++++++++++- > include/linux/tee_core.h | 2 + > include/linux/tee_drv.h | 12 +++++ > 6 files changed, 137 insertions(+), 5 deletions(-) [..] > diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c > index d65d47cc154e..dc23058e7be6 100644 > --- a/drivers/tee/tee_core.c > +++ b/drivers/tee/tee_core.c > @@ -1141,12 +1141,83 @@ static ssize_t implementation_id_show(struct device *dev, > } > static DEVICE_ATTR_RO(implementation_id); > > +static int tee_get_optee_revision(struct tee_device *teedev, > + struct optee_version_info *ver_info) > +{ > + if (!teedev->desc->ops->get_optee_revision) > + return -ENODEV; > + > + return teedev->desc->ops->get_optee_revision(teedev, ver_info); > +} > + I don't think implementing functions with a TEE back-end driver specific name and implementation is a good idea in TEE core. > +static bool tee_is_optee(struct tee_device *teedev) > +{ > + struct tee_ioctl_version_data vers; > + > + teedev->desc->ops->get_version(teedev, &vers); > + > + return vers.impl_id == TEE_IMPL_ID_OPTEE; > +} > + > +static ssize_t optee_os_revision_show(struct device *dev, > + struct device_attribute *attr, char *buf) > +{ > + struct tee_device *teedev = container_of(dev, struct tee_device, dev); > + struct optee_version_info ver_info; > + int ret; > + > + if (!tee_is_optee(teedev)) > + return -ENODEV; > + > + ret = tee_get_optee_revision(teedev, &ver_info); > + if (ret) > + return ret; > + > + if (ver_info.os_build_id) > + return sysfs_emit(buf, "%u.%u (%08x)\n", ver_info.os_major, > + ver_info.os_minor, ver_info.os_build_id); > + > + return sysfs_emit(buf, "%u.%u\n", ver_info.os_major, > + ver_info.os_minor); > +} [..] > diff --git a/include/linux/tee_core.h b/include/linux/tee_core.h > index 1f3e5dad6d0d..4bd9b6b191c9 100644 > --- a/include/linux/tee_core.h > +++ b/include/linux/tee_core.h > @@ -98,6 +98,8 @@ struct tee_device { > struct tee_driver_ops { > void (*get_version)(struct tee_device *teedev, > struct tee_ioctl_version_data *vers); > + int (*get_optee_revision)(struct tee_device *teedev, > + struct optee_version_info *vers); I think it would be better if this patchset could be made OPTEE agnostic. After-all, the callbacks defined in tee_driver_ops are supposed to be implemented by each TEE back-end driver as per their implementation. > int (*open)(struct tee_context *ctx); > void (*close_context)(struct tee_context *ctx); > void (*release)(struct tee_context *ctx); > diff --git a/include/linux/tee_drv.h b/include/linux/tee_drv.h > index 88a6f9697c89..64a2fea11cb9 100644 > --- a/include/linux/tee_drv.h > +++ b/include/linux/tee_drv.h > @@ -20,6 +20,18 @@ > > struct tee_device; > > +/** > + * struct optee_version_info - OP-TEE version information > + * @os_major: OS major version > + * @os_minor: OS minor version > + * @os_build_id: OS build identifier (0 if unspecified) > + */ > +struct optee_version_info { > + u32 os_major; > + u32 os_minor; > + u32 os_build_id; > +}; > + It is not entirely clear from the structure what kind of version information for OPTEE is being provided. I see from the implementation that when FFA is enabled, this provides FFA version implemented by OPTEE but when FFA is not used, it provides OPTEE OS version. This can be confusing for a user trying to report an OPTEE 'version'. > /** > * struct tee_context - driver specific context on file pointer data > * @teedev: pointer to this drivers struct tee_device Thanks Harshal