Browse Source

Merge pull request #922 from davidcunado-arm/dc/smc_yielding_spds

Migrate secure payload dispatchers to new SMC terminology
pull/931/head
davidcunado-arm 8 years ago
committed by GitHub
parent
commit
07f40001d1
  1. 24
      include/bl32/payloads/tlk.h
  2. 8
      services/spd/opteed/opteed_main.c
  3. 4
      services/spd/opteed/opteed_private.h
  4. 4
      services/spd/tlkd/tlkd_common.c
  5. 24
      services/spd/tlkd/tlkd_main.c
  6. 23
      services/spd/tlkd/tlkd_private.h
  7. 24
      services/spd/trusty/smcall.h
  8. 8
      services/spd/trusty/trusty.c

24
include/bl32/payloads/tlk.h

@ -12,18 +12,18 @@
/*
* Generate function IDs for the Trusted OS/Apps
*/
#define TLK_TOS_STD_FID(fid) ((fid) | 0x72000000 | (0 << 31))
#define TLK_TA_STD_FID(fid) ((fid) | 0x70000000 | (0 << 31))
#define TLK_TOS_YIELD_FID(fid) ((fid) | 0x72000000 | (0 << 31))
#define TLK_TA_YIELD_FID(fid) ((fid) | 0x70000000 | (0 << 31))
/*
* Trusted OS specific function IDs
*/
#define TLK_REGISTER_LOGBUF TLK_TOS_STD_FID(0x1)
#define TLK_REGISTER_REQBUF TLK_TOS_STD_FID(0x2)
#define TLK_RESUME_FID TLK_TOS_STD_FID(0x100)
#define TLK_SYSTEM_SUSPEND TLK_TOS_STD_FID(0xE001)
#define TLK_SYSTEM_RESUME TLK_TOS_STD_FID(0xE002)
#define TLK_SYSTEM_OFF TLK_TOS_STD_FID(0xE003)
#define TLK_REGISTER_LOGBUF TLK_TOS_YIELD_FID(0x1)
#define TLK_REGISTER_REQBUF TLK_TOS_YIELD_FID(0x2)
#define TLK_RESUME_FID TLK_TOS_YIELD_FID(0x100)
#define TLK_SYSTEM_SUSPEND TLK_TOS_YIELD_FID(0xE001)
#define TLK_SYSTEM_RESUME TLK_TOS_YIELD_FID(0xE002)
#define TLK_SYSTEM_OFF TLK_TOS_YIELD_FID(0xE003)
/*
* SMC function IDs that TLK uses to signal various forms of completions
@ -40,10 +40,10 @@
/*
* Trusted Application specific function IDs
*/
#define TLK_OPEN_TA_SESSION TLK_TA_STD_FID(0x1)
#define TLK_CLOSE_TA_SESSION TLK_TA_STD_FID(0x2)
#define TLK_TA_LAUNCH_OP TLK_TA_STD_FID(0x3)
#define TLK_TA_SEND_EVENT TLK_TA_STD_FID(0x4)
#define TLK_OPEN_TA_SESSION TLK_TA_YIELD_FID(0x1)
#define TLK_CLOSE_TA_SESSION TLK_TA_YIELD_FID(0x2)
#define TLK_TA_LAUNCH_OP TLK_TA_YIELD_FID(0x3)
#define TLK_TA_SEND_EVENT TLK_TA_YIELD_FID(0x4)
/*
* Total number of function IDs implemented for services offered to NS clients.

8
services/spd/opteed/opteed_main.c

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2015, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2013-2017, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -235,7 +235,7 @@ uint64_t opteed_smc_handler(uint32_t smc_fid,
&optee_vectors->fast_smc_entry);
} else {
cm_set_elr_el3(SECURE, (uint64_t)
&optee_vectors->std_smc_entry);
&optee_vectors->yield_smc_entry);
}
cm_el1_sysregs_context_restore(SECURE);
@ -401,13 +401,13 @@ DECLARE_RT_SVC(
opteed_smc_handler
);
/* Define an OPTEED runtime service descriptor for standard SMC calls */
/* Define an OPTEED runtime service descriptor for yielding SMC calls */
DECLARE_RT_SVC(
opteed_std,
OEN_TOS_START,
OEN_TOS_END,
SMC_TYPE_STD,
SMC_TYPE_YIELD,
NULL,
opteed_smc_handler
);

4
services/spd/opteed/opteed_private.h

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2013-2017, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -86,7 +86,7 @@
typedef uint32_t optee_vector_isn_t;
typedef struct optee_vectors {
optee_vector_isn_t std_smc_entry;
optee_vector_isn_t yield_smc_entry;
optee_vector_isn_t fast_smc_entry;
optee_vector_isn_t cpu_on_entry;
optee_vector_isn_t cpu_off_entry;

4
services/spd/tlkd/tlkd_common.c

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -88,7 +88,7 @@ void tlkd_init_tlk_ep_state(struct entry_point_info *tlk_entry_point,
/* Associate this context with the cpu specified */
tlk_ctx->mpidr = read_mpidr_el1();
clr_std_smc_active_flag(tlk_ctx->state);
clr_yield_smc_active_flag(tlk_ctx->state);
cm_set_context(&tlk_ctx->cpu_ctx, SECURE);
if (rw == SP_AARCH64)

24
services/spd/tlkd/tlkd_main.c

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2016, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -195,7 +195,7 @@ uint64_t tlkd_smc_handler(uint32_t smc_fid,
* Applications.
* c. open/close sessions
* d. issue commands to the Trusted Apps
* e. resume the preempted standard SMC call.
* e. resume the preempted yielding SMC call.
*/
case TLK_REGISTER_LOGBUF:
case TLK_REGISTER_REQBUF:
@ -217,15 +217,15 @@ uint64_t tlkd_smc_handler(uint32_t smc_fid,
assert(handle == cm_get_context(NON_SECURE));
/*
* Check if we are already processing a standard SMC
* Check if we are already processing a yielding SMC
* call. Of all the supported fids, only the "resume"
* fid expects the flag to be set.
*/
if (smc_fid == TLK_RESUME_FID) {
if (!get_std_smc_active_flag(tlk_ctx.state))
if (!get_yield_smc_active_flag(tlk_ctx.state))
SMC_RET1(handle, SMC_UNK);
} else {
if (get_std_smc_active_flag(tlk_ctx.state))
if (get_yield_smc_active_flag(tlk_ctx.state))
SMC_RET1(handle, SMC_UNK);
}
@ -239,7 +239,7 @@ uint64_t tlkd_smc_handler(uint32_t smc_fid,
/*
* Mark the SP state as active.
*/
set_std_smc_active_flag(tlk_ctx.state);
set_yield_smc_active_flag(tlk_ctx.state);
/*
* We are done stashing the non-secure context. Ask the
@ -298,7 +298,7 @@ uint64_t tlkd_smc_handler(uint32_t smc_fid,
/*
* This is a request from the SP to mark completion of
* a standard function ID.
* a yielding function ID.
*/
case TLK_REQUEST_DONE:
if (ns)
@ -307,7 +307,7 @@ uint64_t tlkd_smc_handler(uint32_t smc_fid,
/*
* Mark the SP state as inactive.
*/
clr_std_smc_active_flag(tlk_ctx.state);
clr_yield_smc_active_flag(tlk_ctx.state);
/* Get a reference to the non-secure context */
ns_cpu_context = cm_get_context(NON_SECURE);
@ -411,13 +411,13 @@ DECLARE_RT_SVC(
tlkd_smc_handler
);
/* Define a SPD runtime service descriptor for standard SMC calls */
/* Define a SPD runtime service descriptor for yielding SMC calls */
DECLARE_RT_SVC(
tlkd_tos_std,
OEN_TOS_START,
OEN_TOS_END,
SMC_TYPE_STD,
SMC_TYPE_YIELD,
NULL,
tlkd_smc_handler
);
@ -433,13 +433,13 @@ DECLARE_RT_SVC(
tlkd_smc_handler
);
/* Define a SPD runtime service descriptor for standard SMC calls */
/* Define a SPD runtime service descriptor for yielding SMC calls */
DECLARE_RT_SVC(
tlkd_tap_std,
OEN_TAP_START,
OEN_TAP_END,
SMC_TYPE_STD,
SMC_TYPE_YIELD,
NULL,
tlkd_smc_handler
);

23
services/spd/tlkd/tlkd_private.h

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -14,7 +14,7 @@
#include <psci.h>
/*
* This flag is used by the TLKD to determine if the SP is servicing a standard
* This flag is used by the TLKD to determine if the SP is servicing a yielding
* SMC request prior to programming the next entry into the SP e.g. if SP
* execution is preempted by a non-secure interrupt and handed control to the
* normal world. If another request which is distinct from what the SP was
@ -22,15 +22,16 @@
* reject the new request or service it while ensuring that the previous context
* is not corrupted.
*/
#define STD_SMC_ACTIVE_FLAG_SHIFT 2
#define STD_SMC_ACTIVE_FLAG_MASK 1
#define get_std_smc_active_flag(state) (((state) >> STD_SMC_ACTIVE_FLAG_SHIFT) \
& STD_SMC_ACTIVE_FLAG_MASK)
#define set_std_smc_active_flag(state) ((state) |= \
(1 << STD_SMC_ACTIVE_FLAG_SHIFT))
#define clr_std_smc_active_flag(state) ((state) &= \
~(STD_SMC_ACTIVE_FLAG_MASK \
<< STD_SMC_ACTIVE_FLAG_SHIFT))
#define YIELD_SMC_ACTIVE_FLAG_SHIFT 2
#define YIELD_SMC_ACTIVE_FLAG_MASK 1
#define get_yield_smc_active_flag(state) \
(((state) >> YIELD_SMC_ACTIVE_FLAG_SHIFT) \
& YIELD_SMC_ACTIVE_FLAG_MASK)
#define set_yield_smc_active_flag(state) ((state) |= \
(1 << YIELD_SMC_ACTIVE_FLAG_SHIFT))
#define clr_yield_smc_active_flag(state) ((state) &= \
~(YIELD_SMC_ACTIVE_FLAG_MASK \
<< YIELD_SMC_ACTIVE_FLAG_SHIFT))
/*******************************************************************************
* Translate virtual address received from the NS world

24
services/spd/trusty/smcall.h

@ -24,9 +24,9 @@
)
#define SMC_FASTCALL_NR(entity, fn) SMC_NR((entity), (fn), 1, 0)
#define SMC_STDCALL_NR(entity, fn) SMC_NR((entity), (fn), 0, 0)
#define SMC_FASTCALL64_NR(entity, fn) SMC_NR((entity), (fn), 1, 1)
#define SMC_STDCALL64_NR(entity, fn) SMC_NR((entity), (fn), 0, 1)
#define SMC_YIELDCALL_NR(entity, fn) SMC_NR((entity), (fn), 0, 0)
#define SMC_YIELDCALL64_NR(entity, fn) SMC_NR((entity), (fn), 0, 1)
#define SMC_ENTITY_ARCH 0 /* ARM Architecture calls */
#define SMC_ENTITY_CPU 1 /* CPU Service calls */
@ -39,14 +39,14 @@
#define SMC_ENTITY_LOGGING 51 /* Used for secure -> nonsecure logging */
#define SMC_ENTITY_SECURE_MONITOR 60 /* Trusted OS calls internal to secure monitor */
/* FC = Fast call, SC = Standard call */
#define SMC_SC_RESTART_LAST SMC_STDCALL_NR (SMC_ENTITY_SECURE_MONITOR, 0)
#define SMC_SC_NOP SMC_STDCALL_NR (SMC_ENTITY_SECURE_MONITOR, 1)
/* FC = Fast call, YC = Yielding call */
#define SMC_YC_RESTART_LAST SMC_YIELDCALL_NR (SMC_ENTITY_SECURE_MONITOR, 0)
#define SMC_YC_NOP SMC_YIELDCALL_NR (SMC_ENTITY_SECURE_MONITOR, 1)
/*
* Return from secure os to non-secure os with return value in r1
*/
#define SMC_SC_NS_RETURN SMC_STDCALL_NR (SMC_ENTITY_SECURE_MONITOR, 0)
#define SMC_YC_NS_RETURN SMC_YIELDCALL_NR (SMC_ENTITY_SECURE_MONITOR, 0)
#define SMC_FC_RESERVED SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 0)
#define SMC_FC_FIQ_EXIT SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 1)
@ -64,12 +64,12 @@
#define SMC_FC_GET_VERSION_STR SMC_FASTCALL_NR (SMC_ENTITY_SECURE_MONITOR, 10)
/* Trusted OS entity calls */
#define SMC_SC_VIRTIO_GET_DESCR SMC_STDCALL_NR(SMC_ENTITY_TRUSTED_OS, 20)
#define SMC_SC_VIRTIO_START SMC_STDCALL_NR(SMC_ENTITY_TRUSTED_OS, 21)
#define SMC_SC_VIRTIO_STOP SMC_STDCALL_NR(SMC_ENTITY_TRUSTED_OS, 22)
#define SMC_YC_VIRTIO_GET_DESCR SMC_YIELDCALL_NR(SMC_ENTITY_TRUSTED_OS, 20)
#define SMC_YC_VIRTIO_START SMC_YIELDCALL_NR(SMC_ENTITY_TRUSTED_OS, 21)
#define SMC_YC_VIRTIO_STOP SMC_YIELDCALL_NR(SMC_ENTITY_TRUSTED_OS, 22)
#define SMC_SC_VDEV_RESET SMC_STDCALL_NR(SMC_ENTITY_TRUSTED_OS, 23)
#define SMC_SC_VDEV_KICK_VQ SMC_STDCALL_NR(SMC_ENTITY_TRUSTED_OS, 24)
#define SMC_SC_SET_ROT_PARAMS SMC_STDCALL_NR(SMC_ENTITY_TRUSTED_OS, 65535)
#define SMC_YC_VDEV_RESET SMC_YIELDCALL_NR(SMC_ENTITY_TRUSTED_OS, 23)
#define SMC_YC_VDEV_KICK_VQ SMC_YIELDCALL_NR(SMC_ENTITY_TRUSTED_OS, 24)
#define SMC_YC_SET_ROT_PARAMS SMC_YIELDCALL_NR(SMC_ENTITY_TRUSTED_OS, 65535)
#endif /* __LIB_SM_SMCALL_H */

8
services/spd/trusty/trusty.c

@ -221,14 +221,14 @@ static uint64_t trusty_smc_handler(uint32_t smc_fid,
* Verified Boot is not even supported and returning success here
* would not compromise the boot process.
*/
if (!ep_info && (smc_fid == SMC_SC_SET_ROT_PARAMS)) {
if (!ep_info && (smc_fid == SMC_YC_SET_ROT_PARAMS)) {
SMC_RET1(handle, 0);
} else if (!ep_info) {
SMC_RET1(handle, SMC_UNK);
}
if (is_caller_secure(flags)) {
if (smc_fid == SMC_SC_NS_RETURN) {
if (smc_fid == SMC_YC_NS_RETURN) {
ret = trusty_context_switch(SECURE, x1, 0, 0, 0);
SMC_RET8(handle, ret.r0, ret.r1, ret.r2, ret.r3,
ret.r4, ret.r5, ret.r6, ret.r7);
@ -424,13 +424,13 @@ DECLARE_RT_SVC(
trusty_smc_handler
);
/* Define a SPD runtime service descriptor for standard SMC calls */
/* Define a SPD runtime service descriptor for yielding SMC calls */
DECLARE_RT_SVC(
trusty_std,
OEN_TAP_START,
SMC_ENTITY_SECURE_MONITOR,
SMC_TYPE_STD,
SMC_TYPE_YIELD,
NULL,
trusty_smc_handler
);

Loading…
Cancel
Save