Skip to content

Commit

Permalink
tee: support of allocating DMA shared buffers **not for mainline**
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Igor Opaniuk authored and jforissier committed Jun 19, 2018
1 parent f5d5641 commit 0c23453
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/tee/optee/optee_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,8 @@ struct optee_msg_arg {
#define OPTEE_MSG_RPC_SHM_TYPE_APPL 0
/* Memory only shared with non-secure kernel */
#define OPTEE_MSG_RPC_SHM_TYPE_KERNEL 1
/* Memory shared with non-secure kernel, but exported to userspace */
#define OPTEE_MSG_RPC_SHM_TYPE_GLOBAL 2

/*
* Free shared memory previously allocated with OPTEE_MSG_RPC_CMD_SHM_ALLOC
Expand Down
4 changes: 4 additions & 0 deletions drivers/tee/optee/rpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ static void handle_rpc_func_cmd_shm_alloc(struct tee_context *ctx,
case OPTEE_MSG_RPC_SHM_TYPE_KERNEL:
shm = tee_shm_alloc(ctx, sz, TEE_SHM_MAPPED);
break;
case OPTEE_MSG_RPC_SHM_TYPE_KERNEL_GLOBAL:
shm = tee_shm_alloc(ctx, sz, TEE_SHM_MAPPED | TEE_SHM_DMA_BUF);
break;
default:
arg->ret = TEEC_ERROR_BAD_PARAMETERS;
return;
Expand Down Expand Up @@ -341,6 +344,7 @@ static void handle_rpc_func_cmd_shm_free(struct tee_context *ctx,
cmd_free_suppl(ctx, shm);
break;
case OPTEE_MSG_RPC_SHM_TYPE_KERNEL:
case OPTEE_MSG_RPC_SHM_TYPE_GLOBAL:
tee_shm_free(shm);
break;
default:
Expand Down

0 comments on commit 0c23453

Please sign in to comment.