diff options
author | Marc Kleine-Budde <mkl@pengutronix.de> | 2023-11-27 07:35:58 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2023-12-05 08:44:03 +0100 |
commit | 77104566679319d68e30b20ad6d7e7183ab80663 (patch) | |
tree | 9492ff3f9e69800c731cb8fd9557093aa896df00 /include/linux/tee_drv.h | |
parent | 937914dc5be77cd8464be51190fd2ffc2adb9333 (diff) | |
download | barebox-77104566679319d68e30b20ad6d7e7183ab80663.tar.gz barebox-77104566679319d68e30b20ad6d7e7183ab80663.tar.xz |
optee: add experimental support for /dev/tee0
Userspace accesses OP-TEE via ioctls and mmaps of the /dev/tee0
device. Replicating this in barebox is useful for verifying proper
operation of CONFIG_OPTEE by hacking libteeclient + optee_tests to
run under barebox.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20231127063559.2205776-8-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/linux/tee_drv.h')
-rw-r--r-- | include/linux/tee_drv.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/include/linux/tee_drv.h b/include/linux/tee_drv.h index e5f0344d4d..4a5cb0f0a5 100644 --- a/include/linux/tee_drv.h +++ b/include/linux/tee_drv.h @@ -182,6 +182,9 @@ int tee_session_calc_client_uuid(uuid_t *uuid, u32 connection_method, * @refcount: reference counter * @flags: defined by TEE_SHM_* in tee_drv.h * @link: list head for registering object globally + * @fd: file descriptor for use in userspace + * @dev: device for registering shared memory + * @res: resource to be associated with device * * This pool is only supposed to be accessed directly from the TEE * subsystem and from drivers that implements their own shm pool manager. @@ -194,6 +197,11 @@ struct tee_shm { refcount_t refcount; u32 flags; struct list_head link; + + int fd; + struct device_d dev; + struct cdev cdev; + struct resource res; }; /** @@ -205,6 +213,10 @@ void *tee_get_drvdata(struct tee_device *teedev); struct tee_shm *tee_shm_alloc_priv_buf(struct tee_context *ctx, size_t size); struct tee_shm *tee_shm_alloc_kernel_buf(struct tee_context *ctx, size_t size); +struct tee_shm *tee_shm_alloc_user_buf(struct tee_context *ctx, size_t size); +struct tee_shm *tee_shm_register_user_buf(struct tee_context *ctx, + unsigned long addr, size_t length); + /** * tee_shm_is_dynamic() - Check if shared memory object is of the dynamic kind * @shm: Shared memory handle @@ -257,6 +269,27 @@ static inline size_t tee_shm_get_size(struct tee_shm *shm) } /** + * tee_shm_get_id() - Get id of a shared memory object + * @shm: Shared memory handle + * @returns id + */ +static inline int tee_shm_get_id(struct tee_shm *shm) +{ + /* Only call on non-private SHMs */ + BUG_ON(shm->dev.id < 0); + return shm->dev.id; +} + +/** + * tee_shm_get_from_id() - Find shared memory object and increase reference + * count + * @ctx: Context owning the shared memory + * @id: Id of shared memory object + * @returns a pointer to 'struct tee_shm' on success or an ERR_PTR on failure + */ +struct tee_shm *tee_shm_get_from_id(struct tee_context *ctx, int id); + +/** * tee_client_open_context() - Open a TEE context * @start: if not NULL, continue search after this context * @match: function to check TEE device |