Skip to content

Commit 0c23453

Browse files
Igor Opaniukjforissier
authored andcommitted
tee: support of allocating DMA shared buffers **not for mainline**
Add support of allocating DMA shared buffers via RPC calls. The main difference with OPTEE_MSG_RPC_SHM_TYPE_KERNEL is that SHM pool manager for shared memory exported to user space is explicitly chosen. As dma-buf is used for exporting buffers to userspace, it provides a possiblity to mmap an allocated SHM buffer into multiple TEE client applications (unlike OPTEE_MSG_RPC_SHM_TYPE_APPL, which leverages tee-supplicant for private allocations). Such buffers should be used only for internal purposes, when there is a need to share meta data between different OP-TEE components (for debugging/profiling purposes). Signed-off-by: Igor Opaniuk <[email protected]>
1 parent f5d5641 commit 0c23453

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

drivers/tee/optee/optee_msg.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,8 @@ struct optee_msg_arg {
429429
#define OPTEE_MSG_RPC_SHM_TYPE_APPL 0
430430
/* Memory only shared with non-secure kernel */
431431
#define OPTEE_MSG_RPC_SHM_TYPE_KERNEL 1
432+
/* Memory shared with non-secure kernel, but exported to userspace */
433+
#define OPTEE_MSG_RPC_SHM_TYPE_GLOBAL 2
432434

433435
/*
434436
* Free shared memory previously allocated with OPTEE_MSG_RPC_CMD_SHM_ALLOC

drivers/tee/optee/rpc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,9 @@ static void handle_rpc_func_cmd_shm_alloc(struct tee_context *ctx,
233233
case OPTEE_MSG_RPC_SHM_TYPE_KERNEL:
234234
shm = tee_shm_alloc(ctx, sz, TEE_SHM_MAPPED);
235235
break;
236+
case OPTEE_MSG_RPC_SHM_TYPE_KERNEL_GLOBAL:
237+
shm = tee_shm_alloc(ctx, sz, TEE_SHM_MAPPED | TEE_SHM_DMA_BUF);
238+
break;
236239
default:
237240
arg->ret = TEEC_ERROR_BAD_PARAMETERS;
238241
return;
@@ -341,6 +344,7 @@ static void handle_rpc_func_cmd_shm_free(struct tee_context *ctx,
341344
cmd_free_suppl(ctx, shm);
342345
break;
343346
case OPTEE_MSG_RPC_SHM_TYPE_KERNEL:
347+
case OPTEE_MSG_RPC_SHM_TYPE_GLOBAL:
344348
tee_shm_free(shm);
345349
break;
346350
default:

0 commit comments

Comments
 (0)