Skip to contentSkip to conversation

TEE driver for Trusted Services

PATCH In review Balint Dobszay 4 participants 11 messages Mar 25, 2024 – Apr 3, 2024

Subsystems (4)
lore
Share & tools
lore

Balint Dobszay

author maintainer
#0 lore raw

v4 cover TEE driver for Trusted Services

This series introduces a TEE driver for Trusted Services [1].

Trusted Services is a TrustedFirmware.org project that provides a framework for developing and deploying device Root of Trust services in FF-A [2] Secure Partitions. The project hosts the reference implementation of Arm Platform Security Architecture [3] for Arm A-profile devices.

The FF-A Secure Partitions are accessible through the FF-A driver in Linux. However, the FF-A driver doesn't have a user space interface so user space clients currently cannot access Trusted Services. The goal of this TEE driver is to bridge this gap and make Trusted Services functionality accessible from user space.

Changelog:
v3[7] -> v4:
- Remove unnecessary callbacks from tstee_ops
- Add maintainers entry for the new driver

v2[6] -> v3:
- Add patch "tee: Refactor TEE subsystem header files" from Sumit
- Remove unnecessary includes from core.c
- Remove the mutex from "struct ts_context_data" since the same mechanism could be implemented by reusing the XArray's internal lock
- Rename tee_shm_pool_op_*_helper functions as suggested by Sumit
- Replace pr_* with dev_* as previously suggested by Krzysztof

v1[5] -> v2:
- Refactor session handling to use XArray instead of IDR and linked list (the linked list was redundant as pointed out by Jens, and IDR is now deprecated in favor of XArray)
- Refactor tstee_probe() to not call tee_device_unregister() before calling tee_device_register()
- Address comments from Krzysztof and Jens
- Address documentation comments from Randy
- Use module_ffa_driver() macro instead of separate module init / exit functions
- Reformat max line length 100 -> 80

RFC[4] -> v1:
- Add patch for moving pool_op helper functions to the TEE subsystem, as suggested by Jens
- Address comments from Sumit, add patch for documentation

[1] https://www.trustedfirmware.org/projects/trusted-services/
[2] https://developer.arm.com/documentation/den0077/
[3] https://www.arm.com/architecture/security-features/platform-security
[4] https://lore.kernel.org/linux-arm-kernel/20230927152145.111777-1-balint.dobszay(a)arm.com/
[5] https://lore.kernel.org/lkml/20240213145239.379875-1-balint.dobszay(a)arm.com/
[6] https://lore.kernel.org/lkml/20240223095133.109046-1-balint.dobszay(a)arm.com/
[7] https://lore.kernel.org/lkml/20240305101745.213933-1-balint.dobszay(a)arm.com/

Balint Dobszay (4):
tee: optee: Move pool_op helper functions
tee: tstee: Add Trusted Services TEE driver
Documentation: tee: Add TS-TEE driver
MAINTAINERS: tee: tstee: Add entry

Sumit Garg (1):
tee: Refactor TEE subsystem header files

 Documentation/tee/index.rst         |   1 +
 Documentation/tee/ts-tee.rst        |  71 ++++
 MAINTAINERS                         |  10 +
 drivers/tee/Kconfig                 |   1 +
 drivers/tee/Makefile                |   1 +
 drivers/tee/amdtee/amdtee_private.h |   2 +-
 drivers/tee/amdtee/call.c           |   2 +-
 drivers/tee/amdtee/core.c           |   3 +-
 drivers/tee/amdtee/shm_pool.c       |   2 +-
 drivers/tee/optee/call.c            |   2 +-
 drivers/tee/optee/core.c            |  66 +---
 drivers/tee/optee/device.c          |   2 +-
 drivers/tee/optee/ffa_abi.c         |   8 +-
 drivers/tee/optee/notif.c           |   2 +-
 drivers/tee/optee/optee_private.h   |  14 +-
 drivers/tee/optee/rpc.c             |   2 +-
 drivers/tee/optee/smc_abi.c         |  11 +-
 drivers/tee/tee_core.c              |   2 +-
 drivers/tee/tee_private.h           |  35 --
 drivers/tee/tee_shm.c               |  66 +++-
 drivers/tee/tee_shm_pool.c          |   2 +-
 drivers/tee/tstee/Kconfig           |  11 +
 drivers/tee/tstee/Makefile          |   3 +
 drivers/tee/tstee/core.c            | 480 ++++++++++++++++++++++++++++
 drivers/tee/tstee/tstee_private.h   |  92 ++++++
 include/linux/tee_core.h            | 306 ++++++++++++++++++
 include/linux/tee_drv.h             | 285 ++---------------
 include/uapi/linux/tee.h            |   1 +
 28 files changed, 1094 insertions(+), 389 deletions(-)
 create mode 100644 Documentation/tee/ts-tee.rst
 create mode 100644 drivers/tee/tstee/Kconfig
 create mode 100644 drivers/tee/tstee/Makefile
 create mode 100644 drivers/tee/tstee/core.c
 create mode 100644 drivers/tee/tstee/tstee_private.h
 create mode 100644 include/linux/tee_core.h
Signature · 1 line
2.34.1
author maintainer
#1 lore raw

PATCH v4 1/5 tee: Refactor TEE subsystem header files

From: Sumit Garg <[email protected]>

Since commit 25559c22cef8 ("tee: add kernel internal client interface"), it has been a common include/linux/tee_drv.h header file which is shared to hold TEE subsystem internal bits along with the APIs exposed to the TEE client drivers. However, this practice is prone to TEE subsystem internal APIs abuse and especially so with the new TEE implementation drivers being added to reuse existing functionality.

In order to address this split TEE subsystem internal bits as a separate header file: include/linux/tee_core.h which should be the one used by TEE implementation drivers. With that include/linux/tee_drv.h lists only APIs exposed by TEE subsystem to the TEE client drivers.

---
 MAINTAINERS                         |   1 +
 drivers/tee/amdtee/amdtee_private.h |   2 +-
 drivers/tee/amdtee/call.c           |   2 +-
 drivers/tee/amdtee/core.c           |   3 +-
 drivers/tee/amdtee/shm_pool.c       |   2 +-
 drivers/tee/optee/call.c            |   2 +-
 drivers/tee/optee/core.c            |   2 +-
 drivers/tee/optee/device.c          |   2 +-
 drivers/tee/optee/ffa_abi.c         |   2 +-
 drivers/tee/optee/notif.c           |   2 +-
 drivers/tee/optee/optee_private.h   |   2 +-
 drivers/tee/optee/rpc.c             |   2 +-
 drivers/tee/optee/smc_abi.c         |   2 +-
 drivers/tee/tee_core.c              |   2 +-
 drivers/tee/tee_private.h           |  35 ----
 drivers/tee/tee_shm.c               |   2 +-
 drivers/tee/tee_shm_pool.c          |   2 +-
 include/linux/tee_core.h            | 296 ++++++++++++++++++++++++++++
 include/linux/tee_drv.h             | 285 +++-----------------------
 19 files changed, 343 insertions(+), 305 deletions(-)
 create mode 100644 include/linux/tee_core.h
MAINTAINERS +1 -0
index aa3b947fb080..fd221a7d4d1c 100644
@@ -21684,6 +21684,7 @@ F:	Documentation/driver-api/tee.rst
 F:	Documentation/tee/
 F:	Documentation/userspace-api/tee.rst
 F:	drivers/tee/
+F:	include/linux/tee_core.h
 F:	include/linux/tee_drv.h
 F:	include/uapi/linux/tee.h
 
drivers/tee/amdtee/amdtee_private.h +1 -1
index 6d0f7062bb87..d87050033894 100644
@@ -9,7 +9,7 @@
 
 #include <linux/mutex.h>
 #include <linux/spinlock.h>
-#include <linux/tee_drv.h>
+#include <linux/tee_core.h>
 #include <linux/kref.h>
 #include <linux/types.h>
 #include "amdtee_if.h"
drivers/tee/amdtee/call.c +1 -1
index e9b63dcb3194..4c21b02be4af 100644
@@ -5,7 +5,7 @@
 
 #include <linux/device.h>
 #include <linux/tee.h>
-#include <linux/tee_drv.h>
+#include <linux/tee_core.h>
 #include <linux/psp-tee.h>
 #include <linux/slab.h>
 #include <linux/psp.h>
drivers/tee/amdtee/core.c +1 -2
index 3c15f6a9e91c..e487231d25dc 100644
@@ -9,13 +9,12 @@
 #include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/device.h>
-#include <linux/tee_drv.h>
+#include <linux/tee_core.h>
 #include <linux/types.h>
 #include <linux/mm.h>
 #include <linux/uaccess.h>
 #include <linux/firmware.h>
 #include "amdtee_private.h"
-#include "../tee_private.h"
 #include <linux/psp-tee.h>
 
 static struct amdtee_driver_data *drv_data;
drivers/tee/amdtee/shm_pool.c +1 -1
index f0303126f199..6346e0bc8a64 100644
@@ -4,7 +4,7 @@
  */
 
 #include <linux/slab.h>
-#include <linux/tee_drv.h>
+#include <linux/tee_core.h>
 #include <linux/psp.h>
 #include "amdtee_private.h"
 
drivers/tee/optee/call.c +1 -1
index a91e50be11be..16eb953e14bb 100644
@@ -7,7 +7,7 @@
 #include <linux/errno.h>
 #include <linux/mm.h>
 #include <linux/slab.h>
-#include <linux/tee_drv.h>
+#include <linux/tee_core.h>
 #include <linux/types.h>
 #include "optee_private.h"
 
drivers/tee/optee/core.c +1 -1
index 3aed554bc8d8..f762e3a25119 100644
@@ -13,7 +13,7 @@
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/string.h>
-#include <linux/tee_drv.h>
+#include <linux/tee_core.h>
 #include <linux/types.h>
 #include "optee_private.h"
 
drivers/tee/optee/device.c +1 -1
index 1892e49a8e6a..d296c70ddfdc 100644
@@ -7,7 +7,7 @@
 
 #include <linux/kernel.h>
 #include <linux/slab.h>
-#include <linux/tee_drv.h>
+#include <linux/tee_core.h>
 #include <linux/uuid.h>
 #include "optee_private.h"
 
drivers/tee/optee/ffa_abi.c +1 -1
index ecb5eb079408..cee8ccb84cb8 100644
@@ -11,7 +11,7 @@
 #include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/string.h>
-#include <linux/tee_drv.h>
+#include <linux/tee_core.h>
 #include <linux/types.h>
 #include "optee_private.h"
 #include "optee_ffa.h"
drivers/tee/optee/notif.c +1 -1
index 05212842b0a5..0d7878e770cd 100644
@@ -9,7 +9,7 @@
 #include <linux/errno.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
-#include <linux/tee_drv.h>
+#include <linux/tee_core.h>
 #include "optee_private.h"
 
 struct notif_entry {
drivers/tee/optee/optee_private.h +1 -1
index 7a5243c78b55..a0698ac18993 100644
@@ -9,7 +9,7 @@
 #include <linux/arm-smccc.h>
 #include <linux/rhashtable.h>
 #include <linux/semaphore.h>
-#include <linux/tee_drv.h>
+#include <linux/tee_core.h>
 #include <linux/types.h>
 #include "optee_msg.h"
 
drivers/tee/optee/rpc.c +1 -1
index e69bc6380683..f086812f1179 100644
@@ -8,7 +8,7 @@
 #include <linux/delay.h>
 #include <linux/i2c.h>
 #include <linux/slab.h>
-#include <linux/tee_drv.h>
+#include <linux/tee_core.h>
 #include "optee_private.h"
 #include "optee_rpc_cmd.h"
 
drivers/tee/optee/smc_abi.c +1 -1
index a37f87087e5c..9c296b887dc1 100644
@@ -23,7 +23,7 @@
 #include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/string.h>
-#include <linux/tee_drv.h>
+#include <linux/tee_core.h>
 #include <linux/types.h>
 #include <linux/workqueue.h>
 #include "optee_private.h"
drivers/tee/tee_core.c +1 -1
index e59c20d74b36..82ad095d2b1c 100644
@@ -11,7 +11,7 @@
 #include <linux/idr.h>
 #include <linux/module.h>
 #include <linux/slab.h>
-#include <linux/tee_drv.h>
+#include <linux/tee_core.h>
 #include <linux/uaccess.h>
 #include <crypto/hash.h>
 #include <crypto/sha1.h>
drivers/tee/tee_private.h +0 -35
index 754e11dcb240..9bc50605227c 100644
@@ -12,41 +12,6 @@
 #include <linux/mutex.h>
 #include <linux/types.h>
 
-#define TEE_DEVICE_FLAG_REGISTERED	0x1
-#define TEE_MAX_DEV_NAME_LEN		32
-
-/**
- * struct tee_device - TEE Device representation
- * @name:	name of device
- * @desc:	description of device
- * @id:		unique id of device
- * @flags:	represented by TEE_DEVICE_FLAG_REGISTERED above
- * @dev:	embedded basic device structure
- * @cdev:	embedded cdev
- * @num_users:	number of active users of this device
- * @c_no_user:	completion used when unregistering the device
- * @mutex:	mutex protecting @num_users and @idr
- * @idr:	register of user space shared memory objects allocated or
- *		registered on this device
- * @pool:	shared memory pool
- */
-struct tee_device {
-	char name[TEE_MAX_DEV_NAME_LEN];
-	const struct tee_desc *desc;
-	int id;
-	unsigned int flags;
-
-	struct device dev;
-	struct cdev cdev;
-
-	size_t num_users;
-	struct completion c_no_users;
-	struct mutex mutex;	/* protects num_users and idr */
-
-	struct idr idr;
-	struct tee_shm_pool *pool;
-};
-
 int tee_shm_get_fd(struct tee_shm *shm);
 
 bool tee_device_get(struct tee_device *teedev);
drivers/tee/tee_shm.c +1 -1
index 731d9028b67f..96a45c817427 100644
@@ -8,7 +8,7 @@
 #include <linux/mm.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
-#include <linux/tee_drv.h>
+#include <linux/tee_core.h>
 #include <linux/uaccess.h>
 #include <linux/uio.h>
 #include <linux/highmem.h>
drivers/tee/tee_shm_pool.c +1 -1
index 058bfbac657a..80004b55628d 100644
@@ -6,7 +6,7 @@
 #include <linux/dma-buf.h>
 #include <linux/genalloc.h>
 #include <linux/slab.h>
-#include <linux/tee_drv.h>
+#include <linux/tee_core.h>
 #include "tee_private.h"
 
 static int pool_op_gen_alloc(struct tee_shm_pool *pool, struct tee_shm *shm,
include/linux/tee_core.h new file +296 -0

296 lines not on this page · raw message

include/linux/tee_drv.h +31 -254

368 lines not on this page · raw message

Signature · 1 line
2.34.1
author maintainer
#2 lore raw

PATCH v4 2/5 tee: optee: Move pool_op helper functions

In reply to Balint Dobszay

Move the pool alloc and free helper functions from the OP-TEE driver to the TEE subsystem, since these could be reused in other TEE drivers. This patch is not supposed to change behavior, it's only reorganizing the code.

---
 drivers/tee/optee/core.c          | 64 -------------------------------
 drivers/tee/optee/ffa_abi.c       |  6 +--
 drivers/tee/optee/optee_private.h | 12 ------
 drivers/tee/optee/smc_abi.c       |  9 ++---
 drivers/tee/tee_shm.c             | 64 +++++++++++++++++++++++++++++++
 include/linux/tee_core.h          | 10 +++++
 6 files changed, 81 insertions(+), 84 deletions(-)
drivers/tee/optee/core.c +0 -64
index f762e3a25119..39e688d4e974 100644
@@ -9,7 +9,6 @@
 #include <linux/crash_dump.h>
 #include <linux/errno.h>
 #include <linux/io.h>
-#include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/string.h>
@@ -17,69 +16,6 @@
 #include <linux/types.h>
 #include "optee_private.h"
 
-int optee_pool_op_alloc_helper(struct tee_shm_pool *pool, struct tee_shm *shm,
-			       size_t size, size_t align,
-			       int (*shm_register)(struct tee_context *ctx,
-						   struct tee_shm *shm,
-						   struct page **pages,
-						   size_t num_pages,
-						   unsigned long start))
-{
-	size_t nr_pages = roundup(size, PAGE_SIZE) / PAGE_SIZE;
-	struct page **pages;
-	unsigned int i;
-	int rc = 0;
-
-	/*
-	 * Ignore alignment since this is already going to be page aligned
-	 * and there's no need for any larger alignment.
-	 */
-	shm->kaddr = alloc_pages_exact(nr_pages * PAGE_SIZE,
-				       GFP_KERNEL | __GFP_ZERO);
-	if (!shm->kaddr)
-		return -ENOMEM;
-
-	shm->paddr = virt_to_phys(shm->kaddr);
-	shm->size = nr_pages * PAGE_SIZE;
-
-	pages = kcalloc(nr_pages, sizeof(*pages), GFP_KERNEL);
-	if (!pages) {
-		rc = -ENOMEM;
-		goto err;
-	}
-
-	for (i = 0; i < nr_pages; i++)
-		pages[i] = virt_to_page((u8 *)shm->kaddr + i * PAGE_SIZE);
-
-	shm->pages = pages;
-	shm->num_pages = nr_pages;
-
-	if (shm_register) {
-		rc = shm_register(shm->ctx, shm, pages, nr_pages,
-				  (unsigned long)shm->kaddr);
-		if (rc)
-			goto err;
-	}
-
-	return 0;
-err:
-	free_pages_exact(shm->kaddr, shm->size);
-	shm->kaddr = NULL;
-	return rc;
-}
-
-void optee_pool_op_free_helper(struct tee_shm_pool *pool, struct tee_shm *shm,
-			       int (*shm_unregister)(struct tee_context *ctx,
-						     struct tee_shm *shm))
-{
-	if (shm_unregister)
-		shm_unregister(shm->ctx, shm);
-	free_pages_exact(shm->kaddr, shm->size);
-	shm->kaddr = NULL;
-	kfree(shm->pages);
-	shm->pages = NULL;
-}
-
 static void optee_bus_scan(struct work_struct *work)
 {
 	WARN_ON(optee_enumerate_devices(PTA_CMD_GET_DEVICES_SUPP));
drivers/tee/optee/ffa_abi.c +3 -3
index cee8ccb84cb8..3235e1c719e8 100644
@@ -374,14 +374,14 @@ static int optee_ffa_shm_unregister_supp(struct tee_context *ctx,
 static int pool_ffa_op_alloc(struct tee_shm_pool *pool,
 			     struct tee_shm *shm, size_t size, size_t align)
 {
-	return optee_pool_op_alloc_helper(pool, shm, size, align,
-					  optee_ffa_shm_register);
+	return tee_dyn_shm_alloc_helper(shm, size, align,
+					optee_ffa_shm_register);
 }
 
 static void pool_ffa_op_free(struct tee_shm_pool *pool,
 			     struct tee_shm *shm)
 {
-	optee_pool_op_free_helper(pool, shm, optee_ffa_shm_unregister);
+	tee_dyn_shm_free_helper(shm, optee_ffa_shm_unregister);
 }
 
 static void pool_ffa_op_destroy_pool(struct tee_shm_pool *pool)
drivers/tee/optee/optee_private.h +0 -12
index a0698ac18993..429cc20be5cc 100644
@@ -283,18 +283,6 @@ int optee_cancel_req(struct tee_context *ctx, u32 cancel_id, u32 session);
 int optee_enumerate_devices(u32 func);
 void optee_unregister_devices(void);
 
-int optee_pool_op_alloc_helper(struct tee_shm_pool *pool, struct tee_shm *shm,
-			       size_t size, size_t align,
-			       int (*shm_register)(struct tee_context *ctx,
-						   struct tee_shm *shm,
-						   struct page **pages,
-						   size_t num_pages,
-						   unsigned long start));
-void optee_pool_op_free_helper(struct tee_shm_pool *pool, struct tee_shm *shm,
-			       int (*shm_unregister)(struct tee_context *ctx,
-						     struct tee_shm *shm));
-
-
 void optee_remove_common(struct optee *optee);
 int optee_open(struct tee_context *ctx, bool cap_memref_null);
 void optee_release(struct tee_context *ctx);
drivers/tee/optee/smc_abi.c +4 -5
index 9c296b887dc1..734c484ed0f6 100644
@@ -592,19 +592,18 @@ static int pool_op_alloc(struct tee_shm_pool *pool,
 	 * to be registered with OP-TEE.
 	 */
 	if (shm->flags & TEE_SHM_PRIV)
-		return optee_pool_op_alloc_helper(pool, shm, size, align, NULL);
+		return tee_dyn_shm_alloc_helper(shm, size, align, NULL);
 
-	return optee_pool_op_alloc_helper(pool, shm, size, align,
-					  optee_shm_register);
+	return tee_dyn_shm_alloc_helper(shm, size, align, optee_shm_register);
 }
 
 static void pool_op_free(struct tee_shm_pool *pool,
 			 struct tee_shm *shm)
 {
 	if (!(shm->flags & TEE_SHM_PRIV))
-		optee_pool_op_free_helper(pool, shm, optee_shm_unregister);
+		tee_dyn_shm_free_helper(shm, optee_shm_unregister);
 	else
-		optee_pool_op_free_helper(pool, shm, NULL);
+		tee_dyn_shm_free_helper(shm, NULL);
 }
 
 static void pool_op_destroy_pool(struct tee_shm_pool *pool)
drivers/tee/tee_shm.c +64 -0

70 lines not on this page · raw message

include/linux/tee_core.h +10 -0
index d9b3ba8e8fa9..efd16ed52315 100644
@@ -232,6 +232,16 @@ void *tee_get_drvdata(struct tee_device *teedev);
  */
 struct tee_shm *tee_shm_alloc_priv_buf(struct tee_context *ctx, size_t size);
 
+int tee_dyn_shm_alloc_helper(struct tee_shm *shm, size_t size, size_t align,
+			     int (*shm_register)(struct tee_context *ctx,
+						 struct tee_shm *shm,
+						 struct page **pages,
+						 size_t num_pages,
+						 unsigned long start));
+void tee_dyn_shm_free_helper(struct tee_shm *shm,
+			     int (*shm_unregister)(struct tee_context *ctx,
+						   struct tee_shm *shm));
+
 /**
  * tee_shm_is_dynamic() - Check if shared memory object is of the dynamic kind
  * @shm:	Shared memory handle
Signature · 1 line
2.34.1
#3 lore raw

Re: [PATCH v4 2/5] tee: optee: Move pool_op helper functions

Hi Balint,

Quoted 9 lines · Balint Dobszay

Move the pool alloc and free helper functions from the OP-TEE driver to the TEE subsystem, since these could be reused in other TEE drivers. This patch is not supposed to change behavior, it's only reorganizing the code.

Quoted 8 lines
---
 drivers/tee/optee/core.c          | 64 -------------------------------
 drivers/tee/optee/ffa_abi.c       |  6 +--
 drivers/tee/optee/optee_private.h | 12 ------
 drivers/tee/optee/smc_abi.c       |  9 ++---
 drivers/tee/tee_shm.c             | 64 +++++++++++++++++++++++++++++++
 include/linux/tee_core.h          | 10 +++++
 6 files changed, 81 insertions(+), 84 deletions(-)

This patch fails to build on x86_64:
CC [M] drivers/tee/tee_shm.o
drivers/tee/tee_shm.c: In function ‘tee_dyn_shm_alloc_helper’:
linux/drivers/tee/tee_shm.c:226:22: error: implicit declaration of function ‘virt_to_phys’; did you mean ‘virt_to_page’? [-Werror=implicit-function-declaration]

  226 |         shm->paddr = virt_to_phys(shm->kaddr);
      |                      ^~~~~~~~~~~~
      |                      virt_to_page

It's fixed by adding
#include <linux/io.h>

I'll fix up the patch if you agree with the fix.

Cheers,
Jens

Quoted 255 lines
drivers/tee/optee/core.c +0 -64
index f762e3a25119..39e688d4e974 100644
@@ -9,7 +9,6 @@
 #include <linux/crash_dump.h>
 #include <linux/errno.h>
 #include <linux/io.h>
-#include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/string.h>
@@ -17,69 +16,6 @@
 #include <linux/types.h>
 #include "optee_private.h"
 
-int optee_pool_op_alloc_helper(struct tee_shm_pool *pool, struct tee_shm *shm,
-                              size_t size, size_t align,
-                              int (*shm_register)(struct tee_context *ctx,
-                                                  struct tee_shm *shm,
-                                                  struct page **pages,
-                                                  size_t num_pages,
-                                                  unsigned long start))
-{
-       size_t nr_pages = roundup(size, PAGE_SIZE) / PAGE_SIZE;
-       struct page **pages;
-       unsigned int i;
-       int rc = 0;
-
-       /*
-        * Ignore alignment since this is already going to be page aligned
-        * and there's no need for any larger alignment.
-        */
-       shm->kaddr = alloc_pages_exact(nr_pages * PAGE_SIZE,
-                                      GFP_KERNEL | __GFP_ZERO);
-       if (!shm->kaddr)
-               return -ENOMEM;
-
-       shm->paddr = virt_to_phys(shm->kaddr);
-       shm->size = nr_pages * PAGE_SIZE;
-
-       pages = kcalloc(nr_pages, sizeof(*pages), GFP_KERNEL);
-       if (!pages) {
-               rc = -ENOMEM;
-               goto err;
-       }
-
-       for (i = 0; i < nr_pages; i++)
-               pages[i] = virt_to_page((u8 *)shm->kaddr + i * PAGE_SIZE);
-
-       shm->pages = pages;
-       shm->num_pages = nr_pages;
-
-       if (shm_register) {
-               rc = shm_register(shm->ctx, shm, pages, nr_pages,
-                                 (unsigned long)shm->kaddr);
-               if (rc)
-                       goto err;
-       }
-
-       return 0;
-err:
-       free_pages_exact(shm->kaddr, shm->size);
-       shm->kaddr = NULL;
-       return rc;
-}
-
-void optee_pool_op_free_helper(struct tee_shm_pool *pool, struct tee_shm *shm,
-                              int (*shm_unregister)(struct tee_context *ctx,
-                                                    struct tee_shm *shm))
-{
-       if (shm_unregister)
-               shm_unregister(shm->ctx, shm);
-       free_pages_exact(shm->kaddr, shm->size);
-       shm->kaddr = NULL;
-       kfree(shm->pages);
-       shm->pages = NULL;
-}
-
 static void optee_bus_scan(struct work_struct *work)
 {
        WARN_ON(optee_enumerate_devices(PTA_CMD_GET_DEVICES_SUPP));
drivers/tee/optee/ffa_abi.c +3 -3
index cee8ccb84cb8..3235e1c719e8 100644
@@ -374,14 +374,14 @@ static int optee_ffa_shm_unregister_supp(struct tee_context *ctx,
 static int pool_ffa_op_alloc(struct tee_shm_pool *pool,
                             struct tee_shm *shm, size_t size, size_t align)
 {
-       return optee_pool_op_alloc_helper(pool, shm, size, align,
-                                         optee_ffa_shm_register);
+       return tee_dyn_shm_alloc_helper(shm, size, align,
+                                       optee_ffa_shm_register);
 }
 
 static void pool_ffa_op_free(struct tee_shm_pool *pool,
                             struct tee_shm *shm)
 {
-       optee_pool_op_free_helper(pool, shm, optee_ffa_shm_unregister);
+       tee_dyn_shm_free_helper(shm, optee_ffa_shm_unregister);
 }
 
 static void pool_ffa_op_destroy_pool(struct tee_shm_pool *pool)
drivers/tee/optee/optee_private.h +0 -12
index a0698ac18993..429cc20be5cc 100644
@@ -283,18 +283,6 @@ int optee_cancel_req(struct tee_context *ctx, u32 cancel_id, u32 session);
 int optee_enumerate_devices(u32 func);
 void optee_unregister_devices(void);
 
-int optee_pool_op_alloc_helper(struct tee_shm_pool *pool, struct tee_shm *shm,
-                              size_t size, size_t align,
-                              int (*shm_register)(struct tee_context *ctx,
-                                                  struct tee_shm *shm,
-                                                  struct page **pages,
-                                                  size_t num_pages,
-                                                  unsigned long start));
-void optee_pool_op_free_helper(struct tee_shm_pool *pool, struct tee_shm *shm,
-                              int (*shm_unregister)(struct tee_context *ctx,
-                                                    struct tee_shm *shm));
-
-
 void optee_remove_common(struct optee *optee);
 int optee_open(struct tee_context *ctx, bool cap_memref_null);
 void optee_release(struct tee_context *ctx);
drivers/tee/optee/smc_abi.c +4 -5
index 9c296b887dc1..734c484ed0f6 100644
@@ -592,19 +592,18 @@ static int pool_op_alloc(struct tee_shm_pool *pool,
         * to be registered with OP-TEE.
         */
        if (shm->flags & TEE_SHM_PRIV)
-               return optee_pool_op_alloc_helper(pool, shm, size, align, NULL);
+               return tee_dyn_shm_alloc_helper(shm, size, align, NULL);
 
-       return optee_pool_op_alloc_helper(pool, shm, size, align,
-                                         optee_shm_register);
+       return tee_dyn_shm_alloc_helper(shm, size, align, optee_shm_register);
 }
 
 static void pool_op_free(struct tee_shm_pool *pool,
                         struct tee_shm *shm)
 {
        if (!(shm->flags & TEE_SHM_PRIV))
-               optee_pool_op_free_helper(pool, shm, optee_shm_unregister);
+               tee_dyn_shm_free_helper(shm, optee_shm_unregister);
        else
-               optee_pool_op_free_helper(pool, shm, NULL);
+               tee_dyn_shm_free_helper(shm, NULL);
 }
 
 static void pool_op_destroy_pool(struct tee_shm_pool *pool)
drivers/tee/tee_shm.c +64 -0
index 96a45c817427..5bf76c35cd9e 100644
@@ -202,6 +202,70 @@ struct tee_shm *tee_shm_alloc_priv_buf(struct tee_context *ctx, size_t size)
 }
 EXPORT_SYMBOL_GPL(tee_shm_alloc_priv_buf);
 
+int tee_dyn_shm_alloc_helper(struct tee_shm *shm, size_t size, size_t align,
+                            int (*shm_register)(struct tee_context *ctx,
+                                                struct tee_shm *shm,
+                                                struct page **pages,
+                                                size_t num_pages,
+                                                unsigned long start))
+{
+       size_t nr_pages = roundup(size, PAGE_SIZE) / PAGE_SIZE;
+       struct page **pages;
+       unsigned int i;
+       int rc = 0;
+
+       /*
+        * Ignore alignment since this is already going to be page aligned
+        * and there's no need for any larger alignment.
+        */
+       shm->kaddr = alloc_pages_exact(nr_pages * PAGE_SIZE,
+                                      GFP_KERNEL | __GFP_ZERO);
+       if (!shm->kaddr)
+               return -ENOMEM;
+
+       shm->paddr = virt_to_phys(shm->kaddr);
+       shm->size = nr_pages * PAGE_SIZE;
+
+       pages = kcalloc(nr_pages, sizeof(*pages), GFP_KERNEL);
+       if (!pages) {
+               rc = -ENOMEM;
+               goto err;
+       }
+
+       for (i = 0; i < nr_pages; i++)
+               pages[i] = virt_to_page((u8 *)shm->kaddr + i * PAGE_SIZE);
+
+       shm->pages = pages;
+       shm->num_pages = nr_pages;
+
+       if (shm_register) {
+               rc = shm_register(shm->ctx, shm, pages, nr_pages,
+                                 (unsigned long)shm->kaddr);
+               if (rc)
+                       goto err;
+       }
+
+       return 0;
+err:
+       free_pages_exact(shm->kaddr, shm->size);
+       shm->kaddr = NULL;
+       return rc;
+}
+EXPORT_SYMBOL_GPL(tee_dyn_shm_alloc_helper);
+
+void tee_dyn_shm_free_helper(struct tee_shm *shm,
+                            int (*shm_unregister)(struct tee_context *ctx,
+                                                  struct tee_shm *shm))
+{
+       if (shm_unregister)
+               shm_unregister(shm->ctx, shm);
+       free_pages_exact(shm->kaddr, shm->size);
+       shm->kaddr = NULL;
+       kfree(shm->pages);
+       shm->pages = NULL;
+}
+EXPORT_SYMBOL_GPL(tee_dyn_shm_free_helper);
+
 static struct tee_shm *
 register_shm_helper(struct tee_context *ctx, struct iov_iter *iter, u32 flags,
                    int id)
include/linux/tee_core.h +10 -1
index d9b3ba8e8fa9..efd16ed52315 100644
@@ -232,6 +232,16 @@ void *tee_get_drvdata(struct tee_device *teedev);
  */
 struct tee_shm *tee_shm_alloc_priv_buf(struct tee_context *ctx, size_t size);
 
+int tee_dyn_shm_alloc_helper(struct tee_shm *shm, size_t size, size_t align,
+                            int (*shm_register)(struct tee_context *ctx,
+                                                struct tee_shm *shm,
+                                                struct page **pages,
+                                                size_t num_pages,
+                                                unsigned long start));
+void tee_dyn_shm_free_helper(struct tee_shm *shm,
+                            int (*shm_unregister)(struct tee_context *ctx,
+                                                  struct tee_shm *shm));
+
 /**
  * tee_shm_is_dynamic() - Check if shared memory object is of the dynamic kind
  * @shm:       Shared memory handle
--

2.34.1

author maintainer
#4 lore raw

Re: [PATCH v4 2/5] tee: optee: Move pool_op helper functions

Hi Jens,

Quoted 27 lines · Jens Wiklander

Hi Balint,

Quoted 9 lines · Balint Dobszay

Move the pool alloc and free helper functions from the OP-TEE driver to the TEE subsystem, since these could be reused in other TEE drivers. This patch is not supposed to change behavior, it's only reorganizing the code.

Quoted 8 lines
---
 drivers/tee/optee/core.c          | 64 -------------------------------
 drivers/tee/optee/ffa_abi.c       |  6 +--
 drivers/tee/optee/optee_private.h | 12 ------
 drivers/tee/optee/smc_abi.c       |  9 ++---
 drivers/tee/tee_shm.c             | 64 +++++++++++++++++++++++++++++++
 include/linux/tee_core.h          | 10 +++++
 6 files changed, 81 insertions(+), 84 deletions(-)

This patch fails to build on x86_64:
CC [M] drivers/tee/tee_shm.o
drivers/tee/tee_shm.c: In function ‘tee_dyn_shm_alloc_helper’:
linux/drivers/tee/tee_shm.c:226:22: error: implicit declaration of function ‘virt_to_phys’; did you mean ‘virt_to_page’? [-Werror=implicit-function-declaration]

Quoted 8 lines
  226 |         shm->paddr = virt_to_phys(shm->kaddr);
      |                      ^~~~~~~~~~~~
      |                      virt_to_page

It's fixed by adding
#include <linux/io.h>

I'll fix up the patch if you agree with the fix.

Thanks for catching this. I agree with the fix, please apply it.

Regards,
Balint

Quoted 255 lines
Quoted 255 lines
drivers/tee/optee/core.c +0 -64
index f762e3a25119..39e688d4e974 100644
@@ -9,7 +9,6 @@
 #include <linux/crash_dump.h>
 #include <linux/errno.h>
 #include <linux/io.h>
-#include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/string.h>
@@ -17,69 +16,6 @@
 #include <linux/types.h>
 #include "optee_private.h"
 
-int optee_pool_op_alloc_helper(struct tee_shm_pool *pool, struct tee_shm *shm,
-                              size_t size, size_t align,
-                              int (*shm_register)(struct tee_context *ctx,
-                                                  struct tee_shm *shm,
-                                                  struct page **pages,
-                                                  size_t num_pages,
-                                                  unsigned long start))
-{
-       size_t nr_pages = roundup(size, PAGE_SIZE) / PAGE_SIZE;
-       struct page **pages;
-       unsigned int i;
-       int rc = 0;
-
-       /*
-        * Ignore alignment since this is already going to be page aligned
-        * and there's no need for any larger alignment.
-        */
-       shm->kaddr = alloc_pages_exact(nr_pages * PAGE_SIZE,
-                                      GFP_KERNEL | __GFP_ZERO);
-       if (!shm->kaddr)
-               return -ENOMEM;
-
-       shm->paddr = virt_to_phys(shm->kaddr);
-       shm->size = nr_pages * PAGE_SIZE;
-
-       pages = kcalloc(nr_pages, sizeof(*pages), GFP_KERNEL);
-       if (!pages) {
-               rc = -ENOMEM;
-               goto err;
-       }
-
-       for (i = 0; i < nr_pages; i++)
-               pages[i] = virt_to_page((u8 *)shm->kaddr + i * PAGE_SIZE);
-
-       shm->pages = pages;
-       shm->num_pages = nr_pages;
-
-       if (shm_register) {
-               rc = shm_register(shm->ctx, shm, pages, nr_pages,
-                                 (unsigned long)shm->kaddr);
-               if (rc)
-                       goto err;
-       }
-
-       return 0;
-err:
-       free_pages_exact(shm->kaddr, shm->size);
-       shm->kaddr = NULL;
-       return rc;
-}
-
-void optee_pool_op_free_helper(struct tee_shm_pool *pool, struct tee_shm *shm,
-                              int (*shm_unregister)(struct tee_context *ctx,
-                                                    struct tee_shm *shm))
-{
-       if (shm_unregister)
-               shm_unregister(shm->ctx, shm);
-       free_pages_exact(shm->kaddr, shm->size);
-       shm->kaddr = NULL;
-       kfree(shm->pages);
-       shm->pages = NULL;
-}
-
 static void optee_bus_scan(struct work_struct *work)
 {
        WARN_ON(optee_enumerate_devices(PTA_CMD_GET_DEVICES_SUPP));
drivers/tee/optee/ffa_abi.c +3 -3
index cee8ccb84cb8..3235e1c719e8 100644
@@ -374,14 +374,14 @@ static int optee_ffa_shm_unregister_supp(struct tee_context *ctx,
 static int pool_ffa_op_alloc(struct tee_shm_pool *pool,
                             struct tee_shm *shm, size_t size, size_t align)
 {
-       return optee_pool_op_alloc_helper(pool, shm, size, align,
-                                         optee_ffa_shm_register);
+       return tee_dyn_shm_alloc_helper(shm, size, align,
+                                       optee_ffa_shm_register);
 }
 
 static void pool_ffa_op_free(struct tee_shm_pool *pool,
                             struct tee_shm *shm)
 {
-       optee_pool_op_free_helper(pool, shm, optee_ffa_shm_unregister);
+       tee_dyn_shm_free_helper(shm, optee_ffa_shm_unregister);
 }
 
 static void pool_ffa_op_destroy_pool(struct tee_shm_pool *pool)
drivers/tee/optee/optee_private.h +0 -12
index a0698ac18993..429cc20be5cc 100644
@@ -283,18 +283,6 @@ int optee_cancel_req(struct tee_context *ctx, u32 cancel_id, u32 session);
 int optee_enumerate_devices(u32 func);
 void optee_unregister_devices(void);
 
-int optee_pool_op_alloc_helper(struct tee_shm_pool *pool, struct tee_shm *shm,
-                              size_t size, size_t align,
-                              int (*shm_register)(struct tee_context *ctx,
-                                                  struct tee_shm *shm,
-                                                  struct page **pages,
-                                                  size_t num_pages,
-                                                  unsigned long start));
-void optee_pool_op_free_helper(struct tee_shm_pool *pool, struct tee_shm *shm,
-                              int (*shm_unregister)(struct tee_context *ctx,
-                                                    struct tee_shm *shm));
-
-
 void optee_remove_common(struct optee *optee);
 int optee_open(struct tee_context *ctx, bool cap_memref_null);
 void optee_release(struct tee_context *ctx);
drivers/tee/optee/smc_abi.c +4 -5
index 9c296b887dc1..734c484ed0f6 100644
@@ -592,19 +592,18 @@ static int pool_op_alloc(struct tee_shm_pool *pool,
         * to be registered with OP-TEE.
         */
        if (shm->flags & TEE_SHM_PRIV)
-               return optee_pool_op_alloc_helper(pool, shm, size, align, NULL);
+               return tee_dyn_shm_alloc_helper(shm, size, align, NULL);
 
-       return optee_pool_op_alloc_helper(pool, shm, size, align,
-                                         optee_shm_register);
+       return tee_dyn_shm_alloc_helper(shm, size, align, optee_shm_register);
 }
 
 static void pool_op_free(struct tee_shm_pool *pool,
                         struct tee_shm *shm)
 {
        if (!(shm->flags & TEE_SHM_PRIV))
-               optee_pool_op_free_helper(pool, shm, optee_shm_unregister);
+               tee_dyn_shm_free_helper(shm, optee_shm_unregister);
        else
-               optee_pool_op_free_helper(pool, shm, NULL);
+               tee_dyn_shm_free_helper(shm, NULL);
 }
 
 static void pool_op_destroy_pool(struct tee_shm_pool *pool)
drivers/tee/tee_shm.c +64 -0
index 96a45c817427..5bf76c35cd9e 100644
@@ -202,6 +202,70 @@ struct tee_shm *tee_shm_alloc_priv_buf(struct tee_context *ctx, size_t size)
 }
 EXPORT_SYMBOL_GPL(tee_shm_alloc_priv_buf);
 
+int tee_dyn_shm_alloc_helper(struct tee_shm *shm, size_t size, size_t align,
+                            int (*shm_register)(struct tee_context *ctx,
+                                                struct tee_shm *shm,
+                                                struct page **pages,
+                                                size_t num_pages,
+                                                unsigned long start))
+{
+       size_t nr_pages = roundup(size, PAGE_SIZE) / PAGE_SIZE;
+       struct page **pages;
+       unsigned int i;
+       int rc = 0;
+
+       /*
+        * Ignore alignment since this is already going to be page aligned
+        * and there's no need for any larger alignment.
+        */
+       shm->kaddr = alloc_pages_exact(nr_pages * PAGE_SIZE,
+                                      GFP_KERNEL | __GFP_ZERO);
+       if (!shm->kaddr)
+               return -ENOMEM;
+
+       shm->paddr = virt_to_phys(shm->kaddr);
+       shm->size = nr_pages * PAGE_SIZE;
+
+       pages = kcalloc(nr_pages, sizeof(*pages), GFP_KERNEL);
+       if (!pages) {
+               rc = -ENOMEM;
+               goto err;
+       }
+
+       for (i = 0; i < nr_pages; i++)
+               pages[i] = virt_to_page((u8 *)shm->kaddr + i * PAGE_SIZE);
+
+       shm->pages = pages;
+       shm->num_pages = nr_pages;
+
+       if (shm_register) {
+               rc = shm_register(shm->ctx, shm, pages, nr_pages,
+                                 (unsigned long)shm->kaddr);
+               if (rc)
+                       goto err;
+       }
+
+       return 0;
+err:
+       free_pages_exact(shm->kaddr, shm->size);
+       shm->kaddr = NULL;
+       return rc;
+}
+EXPORT_SYMBOL_GPL(tee_dyn_shm_alloc_helper);
+
+void tee_dyn_shm_free_helper(struct tee_shm *shm,
+                            int (*shm_unregister)(struct tee_context *ctx,
+                                                  struct tee_shm *shm))
+{
+       if (shm_unregister)
+               shm_unregister(shm->ctx, shm);
+       free_pages_exact(shm->kaddr, shm->size);
+       shm->kaddr = NULL;
+       kfree(shm->pages);
+       shm->pages = NULL;
+}
+EXPORT_SYMBOL_GPL(tee_dyn_shm_free_helper);
+
 static struct tee_shm *
 register_shm_helper(struct tee_context *ctx, struct iov_iter *iter, u32 flags,
                    int id)
include/linux/tee_core.h +10 -1
index d9b3ba8e8fa9..efd16ed52315 100644
@@ -232,6 +232,16 @@ void *tee_get_drvdata(struct tee_device *teedev);
  */
 struct tee_shm *tee_shm_alloc_priv_buf(struct tee_context *ctx, size_t size);
 
+int tee_dyn_shm_alloc_helper(struct tee_shm *shm, size_t size, size_t align,
+                            int (*shm_register)(struct tee_context *ctx,
+                                                struct tee_shm *shm,
+                                                struct page **pages,
+                                                size_t num_pages,
+                                                unsigned long start));
+void tee_dyn_shm_free_helper(struct tee_shm *shm,
+                            int (*shm_unregister)(struct tee_context *ctx,
+                                                  struct tee_shm *shm));
+
 /**
  * tee_shm_is_dynamic() - Check if shared memory object is of the dynamic kind
  * @shm:       Shared memory handle
--

2.34.1

author maintainer
#5 lore raw

PATCH v4 3/5 tee: tstee: Add Trusted Services TEE driver

In reply to Balint Dobszay

The Trusted Services project provides a framework for developing and deploying device Root of Trust services in FF-A Secure Partitions. The FF-A SPs are accessible through the FF-A driver, but this doesn't provide a user space interface. The goal of this TEE driver is to make Trusted Services SPs accessible for user space clients.

All TS SPs have the same FF-A UUID, it identifies the RPC protocol used by TS. A TS SP can host one or more services, a service is identified by its service UUID. The same type of service cannot be present twice in the same SP. During SP boot each service in an SP is assigned an interface ID, this is just a short ID to simplify message addressing. There is 1:1 mapping between TS SPs and TEE devices, i.e. a separate TEE device is registered for each TS SP. This is required since contrary to the generic TEE design where memory is shared with the whole TEE implementation, in case of FF-A, memory is shared with a specific SP. A user space client has to be able to separately share memory with each SP based on its endpoint ID.

---
 drivers/tee/Kconfig               |   1 +
 drivers/tee/Makefile              |   1 +
 drivers/tee/tstee/Kconfig         |  11 +
 drivers/tee/tstee/Makefile        |   3 +
 drivers/tee/tstee/core.c          | 480 ++++++++++++++++++++++++++++++
 drivers/tee/tstee/tstee_private.h |  92 ++++++
 include/uapi/linux/tee.h          |   1 +
 7 files changed, 589 insertions(+)
 create mode 100644 drivers/tee/tstee/Kconfig
 create mode 100644 drivers/tee/tstee/Makefile
 create mode 100644 drivers/tee/tstee/core.c
 create mode 100644 drivers/tee/tstee/tstee_private.h
drivers/tee/Kconfig +1 -0
index 73a147202e88..61b507c18780 100644
@@ -15,5 +15,6 @@ if TEE
 
 source "drivers/tee/optee/Kconfig"
 source "drivers/tee/amdtee/Kconfig"
+source "drivers/tee/tstee/Kconfig"
 
 endif
drivers/tee/Makefile +1 -0
index 68da044afbfa..5488cba30bd2 100644
@@ -5,3 +5,4 @@ tee-objs += tee_shm.o
 tee-objs += tee_shm_pool.o
 obj-$(CONFIG_OPTEE) += optee/
 obj-$(CONFIG_AMDTEE) += amdtee/
+obj-$(CONFIG_ARM_TSTEE) += tstee/
drivers/tee/tstee/Kconfig new file +11 -0
new file mode 100644
index 000000000000..d32f91d47398
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0-only
+config ARM_TSTEE
+	tristate "Arm Trusted Services TEE driver"
+	depends on ARM_FFA_TRANSPORT
+	default n
+	help
+	  The Trusted Services project provides a framework for developing and
+	  deploying device Root of Trust services in FF-A Secure Partitions.
+	  This driver provides an interface to make Trusted Services Secure
+	  Partitions accessible for user space clients, since the FF-A driver
+	  doesn't implement a user space interface directly.
drivers/tee/tstee/Makefile new file +3 -0
new file mode 100644
index 000000000000..5227020ebd30
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0-only
+arm-tstee-objs := core.o
+obj-$(CONFIG_ARM_TSTEE) = arm-tstee.o
drivers/tee/tstee/core.c new file +480 -0

480 lines not on this page · raw message

drivers/tee/tstee/tstee_private.h new file +92 -0

92 lines not on this page · raw message

include/uapi/linux/tee.h +1 -0
index 23e57164693c..d0430bee8292 100644
@@ -56,6 +56,7 @@
  */
 #define TEE_IMPL_ID_OPTEE	1
 #define TEE_IMPL_ID_AMDTEE	2
+#define TEE_IMPL_ID_TSTEE	3
 
 /*
  * OP-TEE specific capabilities
Signature · 1 line
2.34.1
author maintainer
#6 lore raw

PATCH v4 4/5 Documentation: tee: Add TS-TEE driver

In reply to Balint Dobszay

Add documentation for the Trusted Services TEE driver.

---
 Documentation/tee/index.rst  |  1 +
 Documentation/tee/ts-tee.rst | 71 ++++++++++++++++++++++++++++++++++++
 2 files changed, 72 insertions(+)
 create mode 100644 Documentation/tee/ts-tee.rst
Documentation/tee/index.rst +1 -0
index a23bd08847e5..4be6e69d7837 100644
@@ -10,6 +10,7 @@ TEE Subsystem
    tee
    op-tee
    amd-tee
+   ts-tee
 
 .. only::  subproject and html
 
Documentation/tee/ts-tee.rst new file +71 -0

71 lines not on this page · raw message

Signature · 1 line
2.34.1
author maintainer
#7 lore raw

PATCH v4 5/5 MAINTAINERS: tee: tstee: Add entry

In reply to Balint Dobszay

Create an entry for the newly added Trusted Services TEE driver, with Sudeep and myself as maintainers.

---
 MAINTAINERS | 9 +++++++++
 1 file changed, 9 insertions(+)
MAINTAINERS +9 -0
index fd221a7d4d1c..eaa89feabd25 100644
@@ -22470,6 +22470,15 @@ F:	Documentation/ABI/testing/configfs-tsm
 F:	drivers/virt/coco/tsm.c
 F:	include/linux/tsm.h
 
+TRUSTED SERVICES TEE DRIVER
+M:	Balint Dobszay <[email protected]>
+M:	Sudeep Holla <[email protected]>
+L:	linux-arm-kernel(a)lists.infradead.org (moderated for non-subscribers)
+L:	trusted-services(a)lists.trustedfirmware.org
+S:	Maintained
+F:	Documentation/tee/ts-tee.rst
+F:	drivers/tee/tstee/
+
 TTY LAYER AND SERIAL DRIVERS
 M:	Greg Kroah-Hartman <[email protected]>
 M:	Jiri Slaby <[email protected]>
Signature · 1 line
2.34.1
Reviewed-by on v4 5/5
#8 lore raw

Re: [PATCH v4 5/5] MAINTAINERS: tee: tstee: Add entry

Quoted 9 lines · Balint Dobszay

Create an entry for the newly added Trusted Services TEE driver, with Sudeep and myself as maintainers.

---
 MAINTAINERS | 9 +++++++++
 1 file changed, 9 insertions(+)

-Sumit

Quoted 23 lines
MAINTAINERS +9 -1
index fd221a7d4d1c..eaa89feabd25 100644
@@ -22470,6 +22470,15 @@ F:     Documentation/ABI/testing/configfs-tsm
 F:     drivers/virt/coco/tsm.c
 F:     include/linux/tsm.h
 
+TRUSTED SERVICES TEE DRIVER
+M:     Balint Dobszay <[email protected]>
+M:     Sudeep Holla <[email protected]>
+L:     linux-arm-kernel(a)lists.infradead.org (moderated for non-subscribers)
+L:     trusted-services(a)lists.trustedfirmware.org
+S:     Maintained
+F:     Documentation/tee/ts-tee.rst
+F:     drivers/tee/tstee/
+
 TTY LAYER AND SERIAL DRIVERS
 M:     Greg Kroah-Hartman <[email protected]>
 M:     Jiri Slaby <[email protected]>
--

2.34.1

Acked-by on v4 5/5
#9 lore raw

Re: [PATCH v4 5/5] MAINTAINERS: tee: tstee: Add entry

In reply to Balint Dobszay
Quoted 3 lines · Balint Dobszay

Create an entry for the newly added Trusted Services TEE driver, with Sudeep and myself as maintainers.

Quoted 28 lines
---
 MAINTAINERS | 9 +++++++++
 1 file changed, 9 insertions(+)
MAINTAINERS +9 -0
index fd221a7d4d1c..eaa89feabd25 100644
@@ -22470,6 +22470,15 @@ F:	Documentation/ABI/testing/configfs-tsm
 F:	drivers/virt/coco/tsm.c
 F:	include/linux/tsm.h
 
+TRUSTED SERVICES TEE DRIVER
+M:	Balint Dobszay <[email protected]>
+M:	Sudeep Holla <[email protected]>
+L:	linux-arm-kernel(a)lists.infradead.org (moderated for non-subscribers)
+L:	trusted-services(a)lists.trustedfirmware.org
+S:	Maintained
+F:	Documentation/tee/ts-tee.rst
+F:	drivers/tee/tstee/
+
 TTY LAYER AND SERIAL DRIVERS
 M:	Greg Kroah-Hartman <[email protected]>
 M:	Jiri Slaby <[email protected]>
Signature · 1 line
2.34.1
Signature · 2 lines
Regards,
Sudeep
#10 lore raw
In reply to Balint Dobszay
Quoted 99 lines · Balint Dobszay

This series introduces a TEE driver for Trusted Services [1].

Trusted Services is a TrustedFirmware.org project that provides a framework for developing and deploying device Root of Trust services in FF-A [2] Secure Partitions. The project hosts the reference implementation of Arm Platform Security Architecture [3] for Arm A-profile devices.

The FF-A Secure Partitions are accessible through the FF-A driver in Linux. However, the FF-A driver doesn't have a user space interface so user space clients currently cannot access Trusted Services. The goal of this TEE driver is to bridge this gap and make Trusted Services functionality accessible from user space.

Changelog:
v3[7] -> v4:
- Remove unnecessary callbacks from tstee_ops
- Add maintainers entry for the new driver

v2[6] -> v3:
- Add patch "tee: Refactor TEE subsystem header files" from Sumit
- Remove unnecessary includes from core.c
- Remove the mutex from "struct ts_context_data" since the same mechanism could be implemented by reusing the XArray's internal lock
- Rename tee_shm_pool_op_*_helper functions as suggested by Sumit
- Replace pr_* with dev_* as previously suggested by Krzysztof

v1[5] -> v2:
- Refactor session handling to use XArray instead of IDR and linked list (the linked list was redundant as pointed out by Jens, and IDR is now deprecated in favor of XArray)
- Refactor tstee_probe() to not call tee_device_unregister() before calling tee_device_register()
- Address comments from Krzysztof and Jens
- Address documentation comments from Randy
- Use module_ffa_driver() macro instead of separate module init / exit functions
- Reformat max line length 100 -> 80

RFC[4] -> v1:
- Add patch for moving pool_op helper functions to the TEE subsystem, as suggested by Jens
- Address comments from Sumit, add patch for documentation

[1] https://www.trustedfirmware.org/projects/trusted-services/
[2] https://developer.arm.com/documentation/den0077/
[3] https://www.arm.com/architecture/security-features/platform-security
[4] https://lore.kernel.org/linux-arm-kernel/20230927152145.111777-1-balint.dobszay(a)arm.com/
[5] https://lore.kernel.org/lkml/20240213145239.379875-1-balint.dobszay(a)arm.com/
[6] https://lore.kernel.org/lkml/20240223095133.109046-1-balint.dobszay(a)arm.com/
[7] https://lore.kernel.org/lkml/20240305101745.213933-1-balint.dobszay(a)arm.com/

Balint Dobszay (4):
tee: optee: Move pool_op helper functions
tee: tstee: Add Trusted Services TEE driver
Documentation: tee: Add TS-TEE driver
MAINTAINERS: tee: tstee: Add entry

Sumit Garg (1):
tee: Refactor TEE subsystem header files

 Documentation/tee/index.rst         |   1 +
 Documentation/tee/ts-tee.rst        |  71 ++++
 MAINTAINERS                         |  10 +
 drivers/tee/Kconfig                 |   1 +
 drivers/tee/Makefile                |   1 +
 drivers/tee/amdtee/amdtee_private.h |   2 +-
 drivers/tee/amdtee/call.c           |   2 +-
 drivers/tee/amdtee/core.c           |   3 +-
 drivers/tee/amdtee/shm_pool.c       |   2 +-
 drivers/tee/optee/call.c            |   2 +-
 drivers/tee/optee/core.c            |  66 +---
 drivers/tee/optee/device.c          |   2 +-
 drivers/tee/optee/ffa_abi.c         |   8 +-
 drivers/tee/optee/notif.c           |   2 +-
 drivers/tee/optee/optee_private.h   |  14 +-
 drivers/tee/optee/rpc.c             |   2 +-
 drivers/tee/optee/smc_abi.c         |  11 +-
 drivers/tee/tee_core.c              |   2 +-
 drivers/tee/tee_private.h           |  35 --
 drivers/tee/tee_shm.c               |  66 +++-
 drivers/tee/tee_shm_pool.c          |   2 +-
 drivers/tee/tstee/Kconfig           |  11 +
 drivers/tee/tstee/Makefile          |   3 +
 drivers/tee/tstee/core.c            | 480 ++++++++++++++++++++++++++++
 drivers/tee/tstee/tstee_private.h   |  92 ++++++
 include/linux/tee_core.h            | 306 ++++++++++++++++++
 include/linux/tee_drv.h             | 285 ++---------------
 include/uapi/linux/tee.h            |   1 +
 28 files changed, 1094 insertions(+), 389 deletions(-)
 create mode 100644 Documentation/tee/ts-tee.rst
 create mode 100644 drivers/tee/tstee/Kconfig
 create mode 100644 drivers/tee/tstee/Makefile
 create mode 100644 drivers/tee/tstee/core.c
 create mode 100644 drivers/tee/tstee/tstee_private.h
 create mode 100644 include/linux/tee_core.h
Quoted 3 lines

--
2.34.1

I'm picking up this patch set.

Thanks,
Jens