-
Notifications
You must be signed in to change notification settings - Fork 47
FROMLIST: Trusted Execution Environment (TEE) driver for Qualcomm TEE (QTEE) #121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FROMLIST: Trusted Execution Environment (TEE) driver for Qualcomm TEE (QTEE) #121
Conversation
Validated this driver on QLI0.0. |
Please add a prefix FROMLIST , FROMGIT or UPSTREAM as the case may apply to each change and a Link: tag to each commit log pointing to submitted lore link patch in community. Refer http://go/qcom-next-dev for details. |
Please follow patch commit guideline from below. Ideally patches should be applied seamlessly on topic branch using FROMLIST tag, in case doesn't patchup need to use FROMGIT tag. |
A TEE driver doesn't always need to provide a pool if it doesn't support memory sharing ioctls and can allocate memory for TEE messages in another way. Although this is mentioned in the documentation for tee_device_alloc(), it is not handled correctly. Reviewed-by: Sumit Garg <[email protected]> Signed-off-by: Amirreza Zarrabi <[email protected]> Link: https://lore.kernel.org/all/20250713-qcom-tee-using-tee-ss-without-mem-obj-v6-1-697fb7d41c36@oss.qualcomm.com/
The tee_context can be used to manage TEE user resources, including those allocated by the driver for the TEE on behalf of the user. The release() callback is invoked only when all resources, such as tee_shm, are released and there are no references to the tee_context. When a user closes the device file, the driver should notify the TEE to release any resources it may hold and drop the context references. To achieve this, a close_context() callback is introduced to initiate resource release in the TEE driver when the device file is closed. Relocate teedev_ctx_get, teedev_ctx_put, tee_device_get, and tee_device_get functions to tee_core.h to make them accessible outside the TEE subsystem. Reviewed-by: Sumit Garg <[email protected]> Tested-by: Neil Armstrong <[email protected]> Tested-by: Harshal Dev <[email protected]> Signed-off-by: Amirreza Zarrabi <[email protected]> Link: https://lore.kernel.org/all/20250713-qcom-tee-using-tee-ss-without-mem-obj-v6-2-697fb7d41c36@oss.qualcomm.com/
For drivers that can transfer data to the TEE without using shared memory from client, it is necessary to receive the user address directly, bypassing any processing by the TEE subsystem. Introduce TEE_IOCTL_PARAM_ATTR_TYPE_UBUF_INPUT/OUTPUT/INOUT to represent userspace buffers. Reviewed-by: Sumit Garg <[email protected]> Tested-by: Neil Armstrong <[email protected]> Tested-by: Harshal Dev <[email protected]> Signed-off-by: Amirreza Zarrabi <[email protected]> Link: https://lore.kernel.org/all/20250713-qcom-tee-using-tee-ss-without-mem-obj-v6-3-697fb7d41c36@oss.qualcomm.com/
The TEE subsystem allows session-based access to trusted services, requiring a session to be established to receive a service. This is not suitable for an environment that represents services as objects. An object supports various operations that a client can invoke, potentially generating a result or a new object that can be invoked independently of the original object. Add TEE_IOCTL_PARAM_ATTR_TYPE_OBJREF_INPUT/OUTPUT/INOUT to represent an object. Objects may reside in either TEE or userspace. To invoke an object in TEE, introduce a new ioctl. Use the existing SUPPL_RECV and SUPPL_SEND to invoke an object in userspace. Reviewed-by: Sumit Garg <[email protected]> Tested-by: Neil Armstrong <[email protected]> Tested-by: Harshal Dev <[email protected]> Signed-off-by: Amirreza Zarrabi <[email protected]> Link: https://lore.kernel.org/all/20250713-qcom-tee-using-tee-ss-without-mem-obj-v6-4-697fb7d41c36@oss.qualcomm.com/
Increase TEE_MAX_ARG_SIZE to accommodate worst-case scenarios where additional buffer space is required to pass all arguments to TEE. This change is necessary for upcoming support for Qualcomm TEE, which requires a larger buffer for argument marshaling. Reviewed-by: Sumit Garg <[email protected]> Tested-by: Harshal Dev <[email protected]> Signed-off-by: Amirreza Zarrabi <[email protected]> Link: https://lore.kernel.org/all/20250713-qcom-tee-using-tee-ss-without-mem-obj-v6-5-697fb7d41c36@oss.qualcomm.com/
Qualcomm TEE (QTEE) hosts Trusted Applications (TAs) and services in the secure world, accessed via objects. A QTEE client can invoke these objects to request services. Similarly, QTEE can request services from the nonsecure world using objects exported to the secure world. Add low-level primitives to facilitate the invocation of objects hosted in QTEE, as well as those hosted in the nonsecure world. If support for object invocation is available, the qcom_scm allocates a dedicated child platform device. The driver for this device communicates with QTEE using low-level primitives. Tested-by: Neil Armstrong <[email protected]> Tested-by: Harshal Dev <[email protected]> Signed-off-by: Amirreza Zarrabi <[email protected]> Link: https://lore.kernel.org/all/20250713-qcom-tee-using-tee-ss-without-mem-obj-v6-6-697fb7d41c36@oss.qualcomm.com/
shm_bridge create/delete functions always use the scm device. There is no need to pass it as an argument. Tested-by: Neil Armstrong <[email protected]> Tested-by: Harshal Dev <[email protected]> Signed-off-by: Amirreza Zarrabi <[email protected]> Link: https://lore.kernel.org/all/20250713-qcom-tee-using-tee-ss-without-mem-obj-v6-7-697fb7d41c36@oss.qualcomm.com/
Anyone with access to contiguous physical memory should be able to share memory with QTEE using shm_bridge. Tested-by: Neil Armstrong <[email protected]> Tested-by: Harshal Dev <[email protected]> Signed-off-by: Amirreza Zarrabi <[email protected]> Link: https://lore.kernel.org/all/20250713-qcom-tee-using-tee-ss-without-mem-obj-v6-8-697fb7d41c36@oss.qualcomm.com/
Introduce qcomtee_object, which represents an object in both QTEE and the kernel. QTEE clients can invoke an instance of qcomtee_object to access QTEE services. If this invocation produces a new object in QTEE, an instance of qcomtee_object will be returned. Similarly, QTEE can request services from by issuing a callback request, which invokes an instance of qcomtee_object. Implement initial support for exporting qcomtee_object to userspace and QTEE, enabling the invocation of objects hosted in QTEE and userspace through the TEE subsystem. Tested-by: Neil Armstrong <[email protected]> Tested-by: Harshal Dev <[email protected]> Signed-off-by: Amirreza Zarrabi <[email protected]> Link: https://lore.kernel.org/all/20250713-qcom-tee-using-tee-ss-without-mem-obj-v6-9-697fb7d41c36@oss.qualcomm.com/
After booting, the kernel provides a static object known as the primordial object. This object is utilized by QTEE for native kernel services such as yield or privileged operations. Acked-by: Sumit Garg <[email protected]> Tested-by: Neil Armstrong <[email protected]> Tested-by: Harshal Dev <[email protected]> Signed-off-by: Amirreza Zarrabi <[email protected]> Link: https://lore.kernel.org/all/20250713-qcom-tee-using-tee-ss-without-mem-obj-v6-10-697fb7d41c36@oss.qualcomm.com/
Enable userspace to allocate shared memory with QTEE. Since QTEE handles shared memory as object, a wrapper is implemented to represent tee_shm as an object. The shared memory identifier, obtained through TEE_IOC_SHM_ALLOC, is transferred to the driver using TEE_IOCTL_PARAM_ATTR_TYPE_OBJREF_INPUT/OUTPUT. Tested-by: Neil Armstrong <[email protected]> Acked-by: Sumit Garg <[email protected]> Tested-by: Harshal Dev <[email protected]> Signed-off-by: Amirreza Zarrabi <[email protected]> Link: https://lore.kernel.org/all/20250713-qcom-tee-using-tee-ss-without-mem-obj-v6-11-697fb7d41c36@oss.qualcomm.com/
Add documentation for the Qualcomm TEE driver. Signed-off-by: Amirreza Zarrabi <[email protected]> Link: https://lore.kernel.org/all/20250713-qcom-tee-using-tee-ss-without-mem-obj-v6-12-697fb7d41c36@oss.qualcomm.com/
5855722
to
cf4b871
Compare
Many thanks for your comments, @kuld-sing , @shashim-quic . |
LGTM. topic branch maintainer (@kuld-sing) can go ahead and merge |
573f3ba
into
qualcomm-linux:tech/security/firmware-smc
… for Qualcomm TEE (QTEE) We are planning to replace QPTEE with QCOMTEE on all QCOM-released kernel versions. QTEE allows Trusted Applications (TAs) and services to run securely and offers the same functionality as OPTEE. Signed-off-by: Jiaxing Li <[email protected]> Link: qualcomm-linux#121
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.
Link: https://lore.kernel.org/all/20250713-qcom-tee-using-tee-ss-without-mem-obj-v6-0-697fb7d41c36@oss.qualcomm.com/