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 <hegatta@microsoft.com>
Reviewed-by: Jerome Forissier <jerome@forissier.org>
[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 <etienne.carriere@linaro.org>
Change-Id: I410d8f5743473177f7091c6db0f9aea5fe4ce5bc
Reviewed-on: https://gerrit.st.com/c/mpu/oe/optee/optee_os/+/202483
Tested-by: Etienne CARRIERE <etienne.carriere@foss.st.com>
Tested-by: Lionel DEBIEVE <lionel.debieve@foss.st.com>
Reviewed-by: Etienne CARRIERE <etienne.carriere@foss.st.com>
Reviewed-by: Lionel DEBIEVE <lionel.debieve@foss.st.com>
  • Loading branch information
Lionel Debieve committed May 23, 2022
1 parent 2a17bf7 commit 5b86d56
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/arch/arm/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 @@ -20,7 +20,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
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 @@ -291,6 +291,8 @@
#define OPTEE_SMC_SEC_CAP_MEMREF_NULL BIT(4)
/* Secure world supports asynchronous notification of normal world */
#define OPTEE_SMC_SEC_CAP_ASYNC_NOTIF BIT(5)
/* 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
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 @@ -746,6 +746,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 5b86d56

Please sign in to comment.