From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.trustedfirmware.org (lists.trustedfirmware.org [18.214.241.189]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B159EC5AD49 for ; Tue, 27 May 2025 06:57:48 +0000 (UTC) Received: from lists.trustedfirmware.org (localhost [127.0.0.1]) by lists.trustedfirmware.org (Postfix) with ESMTP id D3A4B42FBD for ; Tue, 27 May 2025 06:57:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.trustedfirmware.org; s=2024; t=1748329067; bh=utl3UjzIhfO9pDpRJSg8RxvUjfVVuBH6Koxgz507w8Y=; h=Subject:Date:To:CC:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From:Reply-To:From; b=bC89j5QPZkUF/Ge2q4iBm1iX25r/z8vBQ/BSGZgRZ14tgvPGnjLsv1GglJssVEuq5 BauQxlCMe1xoze/eVGra63zaq5MWz1eYkOp57vetwstoFif7FCzlJNDYi2LD57Fz9h ICGPM6Ggiq6281KuRUSCALBKIkwafxHY/GAK7oqffycHImPTBg+rrXUv03rnvPeUjK y0snzDwrRENm/2P48EYKI0tMLuecsSaRnVOUY86i8DdN/CfIojQmQs7mGycaXw6vnK HX/W6Snk19m8WPTlZrnnbxG06F2WKJkKEcn19xIk29zez6rZbzp48oBnA1d5ZBJyfK qDu328QoC4HSA== Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lists.trustedfirmware.org (Postfix) with ESMTPS id 9787C3E979 for ; Tue, 27 May 2025 06:57:17 +0000 (UTC) Authentication-Results: lists.trustedfirmware.org; dkim=pass (2048-bit key; unprotected) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=MSfV867V; dkim-atps=neutral Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 54R3umOg003683 for ; Tue, 27 May 2025 06:57:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=qcppdkim1; bh=R/XXNjqqqmQQ2nBiWKgZ1m TILSavzSgd6ug36jOlfis=; b=MSfV867VdhsCNe0rGUbEtX/PvyT5LkhMrb4fZJ TuQ6t78H6Rz7c+O2LhlM3nuQKGzln9EHnlk3PfDmYddMLwRHoXurMwi/VEVQ+XS0 WpRAyv9+NM8FP+L/NBozkfIXOE8rOjvJn58jrKAk+n5gui/ByMNZ5FOkDo5U6HAb neC4+KJbIqdc0s2MxrJ+WMGnQwBk3WfBdHQAzspyVzukh5pIe+jHrHRdnGulpd8I MAFvAb4Ah7UucGXmGjTLL9RaMHFi3wcvpbnyVOahgJFB0UA8Pc7Odzg9Paj+g6VI jDijS8jPxozCeDdJTA3UjqrVmL9X1KcRFjQJRkVM3Tl/eibw== Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 46u5ejwx84-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 27 May 2025 06:57:16 +0000 (GMT) Received: by mail-pf1-f197.google.com with SMTP id d2e1a72fcca58-7425efba1a3so2509218b3a.0 for ; Mon, 26 May 2025 23:57:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748329035; x=1748933835; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=R/XXNjqqqmQQ2nBiWKgZ1mTILSavzSgd6ug36jOlfis=; b=ENHddqKPKRn8O1gwQrW0Hw5xgFFpwoEEKSUTrm/bNAnFfksDrGbjaiXi+w+XG2uyMi PiHxJr+anuOCT/xRoYtEteY0fTxP+6cl7SaDY05/9b8RuboCwpIfryIQic0hV7oVjIyQ tfuYgdVhP+rLrFNX96oHG2MBnYIYiMQNDit9eBeGJoyvlRtFTkj/hjcN7ApZKPtWwG+J 64keU7mOZ1JSx/yWK3rdIihvRq82r76oexifPZEavbZZowwnVOvzOGJ7o6nrCCt2Avbw 9s9HIGtoYlTlk84fLMysD2/h1OU587Qzjn+PPFhQC9riWEOzHXrg0WqI6Uv9wlObKN4P qdfg== X-Forwarded-Encrypted: i=1; AJvYcCX4ShATGFoeelil2W2MZbkE00qvs+SSPEyRId7RRoRC6PCg1sn5dHcCorRo0nNd5X5qfo9Xqck=@lists.trustedfirmware.org X-Gm-Message-State: AOJu0YzynvFwAKHZUWQu/MH414kVGQESHIr0UkPVuvvBeb8dEpw5JxQU ByZlr0btcpJOVY180wrQR+l0sWmfFDb7aK2uLpMmB7wekVvBMzhZHO3In6gsSvSPZTcdeptt13h pN+pPIXYSnZAStjH/lfm2d5GyL0hkWa25rXEdo+liVa+L5RLrNOZuj2jW99dGrvT9MWNJoyU= X-Gm-Gg: ASbGncsNwJCi/2cQh/b9Kt9O4c5mhcX7hR+VZb/du/zKWf0CJDOI9B3GYqoFlaW8y02 FTTi32PX1I+TSyCxkVYczNCOAO7smtXxfoH4IPw2apwSiBkXaAuwnpWqtyG9mJyhouW0yTWnLp9 XBeiRpj9j5tfuzQ82VzyoKNyPgMnA0ZB9gdoXCpi7ooAhvx4LpyMniFZ5pVrPwyKCJUDQ4Gabbe EDZ7Bhyqdu/+f7ZFJoVE8xwk+xJBPCQhFyVydcHLfKI4sLqLyooKwq+joiAlcmiy6sUD2ZvDqn+ 58twX32WfvVzvNkEyUS7nbI78J9JmZLouS2hvjzLtsNTINgtzZPLCoiip3oxnI0KTi7oiWA= X-Received: by 2002:a62:f24d:0:b0:746:2217:5863 with SMTP id d2e1a72fcca58-7462217598emr3300909b3a.6.1748329035359; Mon, 26 May 2025 23:57:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFZrfcH3Sb55ANTjm+eWz4bJbtObaXuc1t3YV5MjNkK73rAKu9ia6cV/91JxIDr6Urj8Gki2g== X-Received: by 2002:a62:f24d:0:b0:746:2217:5863 with SMTP id d2e1a72fcca58-7462217598emr3300873b3a.6.1748329034886; Mon, 26 May 2025 23:57:14 -0700 (PDT) Received: from hu-azarrabi-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-742a970954asm18037286b3a.46.2025.05.26.23.57.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 May 2025 23:57:14 -0700 (PDT) Subject: [PATCH v5 00/12] Trusted Execution Environment (TEE) driver for Qualcomm TEE (QTEE) Date: Mon, 26 May 2025 23:56:45 -0700 Message-Id: <20250526-qcom-tee-using-tee-ss-without-mem-obj-v5-0-024e3221b0b9@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAC1iNWgC/5XNwU7DMAwG4FeZcsZT4qTJ4LT3QByy1FmDaEObt oCmvjteJdQDHMrF8h/F338ThYZERTwdbmKgOZWUOw7Vw0GExndXglRzFijRKB7Qh9zCSARTSd1 13UqBjzQ2eRqhpRby5RW0xWCtNrJCJ9h6Hyimz7Xn+YVzk8qYh6+1dlb31/82zAokxEoiRalIK nvupxRSF458Lu4dM/64/Gu/i+zioyMfallrE3+7enM1ur2uZtdFUznpNJ6wPudSjv3k3/i83XC z4QZPe3HDuPXKaGukt+HyB74syzdaoFNc7gEAAA== To: Jens Wiklander , Sumit Garg , Bjorn Andersson , Konrad Dybcio , Bartosz Golaszewski , Apurupa Pattapu , Kees Cook , "Gustavo A. R. Silva" , Sumit Semwal , =?utf-8?q?Christian_K=C3=B6nig?= X-Mailer: b4 0.13.0 X-Authority-Analysis: v=2.4 cv=GIgIEvNK c=1 sm=1 tr=0 ts=6835624c cx=c_pps a=rEQLjTOiSrHUhVqRoksmgQ==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=dt9VzEwgFbYA:10 a=NEAV23lmAAAA:8 a=VwQbUJbxAAAA:8 a=EUspDBNiAAAA:8 a=COk6AnOGAAAA:8 a=wdamrMJRu_bT6IjY2ZgA:9 a=QEXdDO2ut3YA:10 a=2VI0MkxyNR6bbpdq8BZq:22 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-ORIG-GUID: 4gOy760tMJ4WDI2DKP6BP7Br4llF-000 X-Proofpoint-GUID: 4gOy760tMJ4WDI2DKP6BP7Br4llF-000 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTI3MDA1MyBTYWx0ZWRfX4woX96NjZ3Um yhx5gGonneRaYBHQy193RPlZ5GdcalBK0Oel6ZzEdltlzDRUW6nm7/hwvUUOLGfh0qguycHFt6x ld2kZCgHbPKtPnkEz08oNwQwfc359eAQg595UpPHVepEcLDVtrkN1jSSiPDj3Gw05QUuXMYbZSS FxRjWFuKPeKmZQOyVADniLgJ62VEVa/36pOaYC1RG9q1HNM35ie7WMdepmiJXDVYViqZi7A5qEx jCsN0sgdWTg+mM2Wa27+gAvw1CR4tt39vXdwviMPmLqMC0LwYP6yfq1Qb/B8V8zk1fA/u78nxpV mdKxdt8U/5LABXsVrmpf5+Ne00Y4EnriJ+bST3sjJaFobiSKDEN+wrpTwaHGy4EcCa48NOBl8Mt k9tUVAewft5xVvKOqTV5dMM94mXpMuY8L5SIgcL02PxU+dAHwY4jY7ZBnjykM16iPKD8YHJU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-27_03,2025-05-26_02,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 bulkscore=0 clxscore=1015 lowpriorityscore=0 adultscore=0 priorityscore=1501 mlxscore=0 phishscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505160000 definitions=main-2505270053 X-Spamd-Bar: ------ X-Spamd-Result: default: False [-6.80 / 15.00]; BAYES_HAM(-3.00)[100.00%]; DWL_DNSWL_MED(-2.00)[qualcomm.com:dkim]; DMARC_POLICY_ALLOW(-0.50)[qualcomm.com,reject]; RCVD_DKIM_ARC_DNSWL_MED(-0.50)[]; RCVD_IN_DNSWL_MED(-0.20)[129.46.96.20:received]; R_SPF_ALLOW(-0.20)[+ip4:205.220.180.131]; R_DKIM_ALLOW(-0.20)[qualcomm.com:s=qcppdkim1]; RCVD_IN_DNSWL_LOW(-0.10)[205.220.180.131:from]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_TWELVE(0.00)[21]; RCVD_IN_DNSWL_NONE(0.00)[209.85.210.197:received]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[]; ASN(0.00)[asn:22843, ipnet:205.220.180.0/24, country:US]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; NEURAL_HAM(-0.00)[-1.000]; RCVD_COUNT_THREE(0.00)[4]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_TLS_LAST(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[op-tee@lists.trustedfirmware.org]; DKIM_TRACE(0.00)[qualcomm.com:+] X-Rspamd-Action: no action X-Rspamd-Server: lists.trustedfirmware.org X-Rspamd-Queue-Id: 9787C3E979 Message-ID-Hash: PYM2JEMOYSA5ESGINRPKWVRY7E5QVOJX X-Message-ID-Hash: PYM2JEMOYSA5ESGINRPKWVRY7E5QVOJX X-MailFrom: amirreza.zarrabi@oss.qualcomm.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-op-tee.lists.trustedfirmware.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Harshal Dev , linux-arm-msm@vger.kernel.org, op-tee@lists.trustedfirmware.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-doc@vger.kernel.org, Amirreza Zarrabi , Sumit Garg , Neil Armstrong X-Mailman-Version: 3.3.5 Precedence: list List-Id: Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Amirreza Zarrabi via OP-TEE Reply-To: Amirreza Zarrabi This patch series introduces a Trusted Execution Environment (TEE) driver for Qualcomm TEE (QTEE). QTEE enables Trusted Applications (TAs) and services to run securely. It uses an object-based interface, where each service is an object with sets of operations. Clients can invoke these operations on objects, which can generate results, including other objects. For example, an object can load a TA and return another object that represents the loaded TA, allowing access to its services. Kernel and userspace services are also available to QTEE through a similar approach. QTEE makes callback requests that are converted into object invocations. These objects can represent services within the kernel or userspace process. Note: This patch series focuses on QTEE objects and userspace services. Linux already provides a TEE subsystem, which is described in [1]. The tee subsystem provides a generic ioctl interface, TEE_IOC_INVOKE, which can be used by userspace to talk to a TEE backend driver. We extend the Linux TEE subsystem to understand object parameters and an ioctl call so client can invoke objects in QTEE: - TEE_IOCTL_PARAM_ATTR_TYPE_OBJREF_* - TEE_IOC_OBJECT_INVOKE The existing ioctl calls TEE_IOC_SUPPL_RECV and TEE_IOC_SUPPL_SEND are used for invoking services in the userspace process by QTEE. The TEE backend driver uses the QTEE Transport Message to communicate with QTEE. Interactions through the object INVOKE interface are translated into QTEE messages. Likewise, object invocations from QTEE for userspace objects are converted into SEND/RECV ioctl calls to supplicants. The details of QTEE Transport Message to communicate with QTEE is available in [PATCH 12/12] Documentation: tee: Add Qualcomm TEE driver. You can run basic tests with following steps: git clone https://github.com/quic/quic-teec.git cd quic-teec mkdir build cmake .. -DCMAKE_TOOLCHAIN_FILE=CMakeToolchain.txt -DBUILD_UNITTEST=ON https://github.com/quic/quic-teec/blob/main/README.md lists dependencies needed to build the above. This series has been tested for basic QTEE object invocations and callback requests, including loading a TA and requesting services form the TA. Tested platforms: sm8650-mtp, sm8550-qrd, sm8650-qrd, sm8650-hdk [1] https://www.kernel.org/doc/Documentation/tee.txt Signed-off-by: Amirreza Zarrabi Changes in v5: - Remove references to kernel services and public APIs. - Support auto detection for failing devices (e.g., RB1, RB4). - Add helpers for obtaining client environment and service objects. - Query the QTEE version and print it. - Move remaining static variables, including the object table, to struct qcomtee. - Update TEE_MAX_ARG_SIZE to 4096. - Add a dependancy to QCOM_TZMEM_MODE_SHMBRIDGE in Kconfig - Reorganize code by removing release.c and qcom_scm.c. - Add more error messages and improve comments. - updated Tested-by:, Acked-by:, and Reviewed-by: tags - Link to v4: https://lore.kernel.org/r/20250428-qcom-tee-using-tee-ss-without-mem-obj-v4-0-6a143640a6cb@oss.qualcomm.com Changes in v4: - Move teedev_ctx_get/put and tee_device_get/put to tee_core.h. - Rename object to id in struct tee_ioctl_object_invoke_arg. - Replace spinlock with mutex for qtee_objects_idr. - Move qcomtee_object_get to qcomtee_user/memobj_param_to_object. - More code cleanup following the comments. - Cleanup documentations. - Update MAINTAINERS file. - Link to v3: https://lore.kernel.org/r/20250327-qcom-tee-using-tee-ss-without-mem-obj-v3-0-7f457073282d@oss.qualcomm.com Changes in v3: - Export shm_bridge create/delete APIs. - Enable support for QTEE memory objects. - Update the memory management code to use the TEE subsystem for all allocations using the pool. - Move all driver states into the driver's main service struct. - Add more documentations. - Link to v2: https://lore.kernel.org/r/20250202-qcom-tee-using-tee-ss-without-mem-obj-v2-0-297eacd0d34f@quicinc.com Changes in v2: - Clean up commit messages and comments. - Use better names such as ubuf instead of membuf or QCOMTEE prefix instead of QCOM_TEE, or names that are more consistent with other TEE-backend drivers such as qcomtee_context_data instead of qcom_tee_context. - Drop the DTS patch and instantiate the device from the scm driver. - Use a single structure for all driver's internal states. - Drop srcu primitives and use the existing mutex for synchronization between the supplicant and QTEE. - Directly use tee_context to track the lifetime of qcomtee_context_data. - Add close_context() to be called when the user closes the tee_context. - Link to v1: https://lore.kernel.org/r/20241202-qcom-tee-using-tee-ss-without-mem-obj-v1-0-f502ef01e016@quicinc.com Changes in v1: - It is a complete rewrite to utilize the TEE subsystem. - Link to RFC: https://lore.kernel.org/all/20240702-qcom-tee-object-and-ioctls-v1-0-633c3ddf57ee@quicinc.com --- Amirreza Zarrabi (12): tee: allow a driver to allocate a tee_device without a pool tee: add close_context to TEE driver operation tee: add TEE_IOCTL_PARAM_ATTR_TYPE_UBUF tee: add TEE_IOCTL_PARAM_ATTR_TYPE_OBJREF tee: increase TEE_MAX_ARG_SIZE to 4096 firmware: qcom: scm: add support for object invocation firmware: qcom: scm: remove unused arguments to the shm_brige firmware: qcom: tzmem: export shm_bridge create/delete tee: add Qualcomm TEE driver qcomtee: add primordial object qcomtee: enable TEE_IOC_SHM_ALLOC ioctl Documentation: tee: Add Qualcomm TEE driver Documentation/tee/index.rst | 1 + Documentation/tee/qtee.rst | 150 +++++ MAINTAINERS | 8 + drivers/firmware/qcom/qcom_scm.c | 132 ++++- drivers/firmware/qcom/qcom_scm.h | 7 + drivers/firmware/qcom/qcom_tzmem.c | 57 +- drivers/tee/Kconfig | 1 + drivers/tee/Makefile | 1 + drivers/tee/qcomtee/Kconfig | 11 + drivers/tee/qcomtee/Makefile | 9 + drivers/tee/qcomtee/async.c | 183 ++++++ drivers/tee/qcomtee/call.c | 833 +++++++++++++++++++++++++++ drivers/tee/qcomtee/core.c | 930 +++++++++++++++++++++++++++++++ drivers/tee/qcomtee/mem_obj.c | 172 ++++++ drivers/tee/qcomtee/primordial_obj.c | 116 ++++ drivers/tee/qcomtee/qcomtee.h | 266 +++++++++ drivers/tee/qcomtee/qcomtee_msg.h | 251 +++++++++ drivers/tee/qcomtee/qcomtee_object.h | 309 ++++++++++ drivers/tee/qcomtee/shm.c | 150 +++++ drivers/tee/qcomtee/user_obj.c | 694 +++++++++++++++++++++++ drivers/tee/tee_core.c | 127 ++++- drivers/tee/tee_private.h | 6 - include/linux/firmware/qcom/qcom_scm.h | 10 +- include/linux/firmware/qcom/qcom_tzmem.h | 15 + include/linux/tee_core.h | 54 +- include/linux/tee_drv.h | 12 + include/uapi/linux/tee.h | 56 +- 27 files changed, 4528 insertions(+), 33 deletions(-) --- base-commit: 3be1a7a31fbda82f3604b6c31e4f390110de1b46 change-id: 20241202-qcom-tee-using-tee-ss-without-mem-obj-362c66340527 Best regards, -- Amirreza Zarrabi