Skip to content

Commit

Permalink
core: OCALL support (OP-TEE Core part)
Browse files Browse the repository at this point in the history
Adds the ability for Core to perform "Out Calls", or OCALLs. OCALLs
allow OP-TEE Core PTA services to invoke commands on their corresponding
client in the same way that client can invoke commands on TAs.

Adds a new capability that reports whether OP-TEE was built with OCALL
support.

Signed-off-by: Hernan Gatta <[email protected]>
Reviewed-by: Jerome Forissier <[email protected]>
[etienne: picked from OP-TEE#3673 series]
[etienne: split CFG_OCALL into CFG_{CORE|USER}_OCALL, no libutee, no pta]
Signed-off-by: Etienne Carriere <[email protected]>
Change-Id: I410d8f5743473177f7091c6db0f9aea5fe4ce5bc
Reviewed-on: https://gerrit.st.com/c/mpu/oe/optee/optee_os/+/202483
Tested-by: Etienne CARRIERE <[email protected]>
Tested-by: Lionel DEBIEVE <[email protected]>
Reviewed-by: Etienne CARRIERE <[email protected]>
Reviewed-by: Lionel DEBIEVE <[email protected]>
  • Loading branch information
Lionel Debieve authored and arnout committed Jan 6, 2023
1 parent ac59f39 commit 74defe0
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
2 changes: 2 additions & 0 deletions core/arch/arm/include/sm/optee_smc.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@
#define OPTEE_SMC_SEC_CAP_ASYNC_NOTIF BIT(5)
/* Secure world supports pre-allocating RPC arg struct */
#define OPTEE_SMC_SEC_CAP_RPC_ARG BIT(6)
/* Secure world is built with OCALL support */
#define OPTEE_SMC_SEC_CAP_OCALL BIT(31)

#define OPTEE_SMC_FUNCID_EXCHANGE_CAPABILITIES U(9)
#define OPTEE_SMC_EXCHANGE_CAPABILITIES \
Expand Down
3 changes: 3 additions & 0 deletions core/arch/arm/tee/entry_fast.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ static void tee_entry_exchange_capabilities(struct thread_smc_args *args)
DMSG("Asynchronous notifications are %sabled",
IS_ENABLED(CFG_CORE_ASYNC_NOTIF) ? "en" : "dis");

if (IS_ENABLED(CFG_CORE_OCALL))
args->a1 |= OPTEE_SMC_SEC_CAP_OCALL;

#if defined(CFG_CORE_DYN_SHM)
dyn_shm_en = core_mmu_nsec_ddr_is_defined();
if (dyn_shm_en)
Expand Down
4 changes: 2 additions & 2 deletions core/include/kernel/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
* Copyright (c) 2014, STMicroelectronics International N.V.
* Copyright (c) 2016-2017, Linaro Limited
* Copyright (c) 2020-2021, Arm Limited
* Copyright (c) 2020, Arm Limited
*/

#ifndef KERNEL_THREAD_H
Expand All @@ -23,7 +23,7 @@
#define THREAD_ID_0 0
#define THREAD_ID_INVALID -1

#define THREAD_RPC_MAX_NUM_PARAMS U(4)
#define THREAD_RPC_MAX_NUM_PARAMS U(6)

#ifndef __ASSEMBLER__

Expand Down
12 changes: 12 additions & 0 deletions core/include/optee_rpc_cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,18 @@
* Definition of protocol for command OPTEE_RPC_CMD_FS
*/

/*
* Send an OCALL to the Client Application
*
* [in] value[0].a CA Command ID (i.e., OCALL# for the CA to execute)
* [out] value[0].b OCALL return value
* [out] value[0].c OCALL return value origin
* [in] value[1].a UUID of TA whence OCALL originated (HI bits)
* [out] value[1].b UUID of TA whence OCALL originated (LO bits)
* [in/out] any[2..5].* OCALL parameters as specified by the TA, if any
*/
#define OPTEE_RPC_CMD_OCALL 22

/*
* Open a file
*
Expand Down
7 changes: 7 additions & 0 deletions mk/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,13 @@ CFG_DRIVERS_RSTCTRL ?= n
# configuration.
CFG_WARN_INSECURE ?= y

# CFG_CORE_OCALL=y enables support for OCALLs, allowing core to return
# from an session or command invocation with an Ocall RPC context.
CFG_CORE_OCALL ?= n
ifeq ($(CFG_CORE_SEL1_SPMC)-$(CFG_CORE_OCALL),y-y)
$(error "SPMC at SEL-1 does not comply with CFG_CORE_OCALL=y")
endif

# Enables warnings for declarations mixed with statements
CFG_WARN_DECL_AFTER_STATEMENT ?= y

Expand Down

0 comments on commit 74defe0

Please sign in to comment.