Skip to content

Commit 4615e5a

Browse files
committed
optee: add FF-A support
Adds support for using FF-A [1] as transport to the OP-TEE driver. Introduces struct optee_msg_param_fmem which carries all information needed when OP-TEE is calling FFA_MEM_RETRIEVE_REQ to get the shared memory reference mapped by the hypervisor in S-EL2. Register usage is also updated to include the information needed. The FF-A part of this driver is enabled if CONFIG_ARM_FFA_TRANSPORT is enabled. [1] https://developer.arm.com/documentation/den0077/latest Acked-by: Sumit Garg <[email protected]> Signed-off-by: Jens Wiklander <[email protected]>
1 parent c51a564 commit 4615e5a

File tree

7 files changed

+1143
-13
lines changed

7 files changed

+1143
-13
lines changed

drivers/tee/optee/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ optee-objs += rpc.o
66
optee-objs += supp.o
77
optee-objs += device.o
88
optee-objs += smc_abi.o
9+
optee-objs += ffa_abi.o
910

1011
# for tracing framework to find optee_trace.h
1112
CFLAGS_smc_abi.o := -I$(src)

drivers/tee/optee/call.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,20 @@ static struct optee_session *find_session(struct optee_context_data *ctxdata,
107107
struct tee_shm *optee_get_msg_arg(struct tee_context *ctx, size_t num_params,
108108
struct optee_msg_arg **msg_arg)
109109
{
110+
struct optee *optee = tee_get_drvdata(ctx->teedev);
111+
size_t sz = OPTEE_MSG_GET_ARG_SIZE(num_params);
110112
struct tee_shm *shm;
111113
struct optee_msg_arg *ma;
112114

113-
shm = tee_shm_alloc(ctx, OPTEE_MSG_GET_ARG_SIZE(num_params),
114-
TEE_SHM_MAPPED | TEE_SHM_PRIV);
115+
/*
116+
* rpc_arg_count is set to the number of allocated parameters in
117+
* the RPC argument struct if a second MSG arg struct is expected.
118+
* The second arg struct will then be used for RPC.
119+
*/
120+
if (optee->rpc_arg_count)
121+
sz += OPTEE_MSG_GET_ARG_SIZE(optee->rpc_arg_count);
122+
123+
shm = tee_shm_alloc(ctx, sz, TEE_SHM_MAPPED | TEE_SHM_PRIV);
115124
if (IS_ERR(shm))
116125
return shm;
117126

drivers/tee/optee/core.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ void optee_remove_common(struct optee *optee)
172172
mutex_destroy(&optee->call_queue.mutex);
173173
}
174174

175+
static int smc_abi_rc;
176+
static int ffa_abi_rc;
177+
175178
static int optee_core_init(void)
176179
{
177180
/*
@@ -184,13 +187,22 @@ static int optee_core_init(void)
184187
if (is_kdump_kernel())
185188
return -ENODEV;
186189

187-
return optee_smc_abi_register();
190+
smc_abi_rc = optee_smc_abi_register();
191+
ffa_abi_rc = optee_ffa_abi_register();
192+
193+
/* If both failed there's no point with this module */
194+
if (smc_abi_rc && ffa_abi_rc)
195+
return smc_abi_rc;
196+
return 0;
188197
}
189198
module_init(optee_core_init);
190199

191200
static void optee_core_exit(void)
192201
{
193-
optee_smc_abi_unregister();
202+
if (!smc_abi_rc)
203+
optee_smc_abi_unregister();
204+
if (!ffa_abi_rc)
205+
optee_ffa_abi_unregister();
194206
}
195207
module_exit(optee_core_exit);
196208

0 commit comments

Comments
 (0)