Migrate secure payload dispatchers to new SMC terminology
authorDavid Cunado <david.cunado@arm.com>
Sun, 16 Apr 2017 16:15:08 +0000 (17:15 +0100)
committerDavid Cunado <david.cunado@arm.com>
Thu, 4 May 2017 20:23:06 +0000 (21:23 +0100)
Since Issue B (November 2016) of the SMC Calling Convention document
standard SMC calls are renamed to yielding SMC calls to help avoid
confusion with the standard service SMC range, which remains unchanged.

http://infocenter.arm.com/help/topic/com.arm.doc.den0028b/ARM_DEN0028B_SMC_Calling_Convention.pd

A previous patch introduced a new define for yielding SMC call type.
This patch updates the secure payload dispatchers (except the TSPD) to
use this new define and also migrates the code to use the new
terminology.

Change-Id: I3d2437c04e3b21fdbd32019f55c066c87679a5bf
Signed-off-by: David Cunado <david.cunado@arm.com>
include/bl32/payloads/tlk.h
services/spd/opteed/opteed_main.c
services/spd/opteed/opteed_private.h
services/spd/tlkd/tlkd_common.c
services/spd/tlkd/tlkd_main.c
services/spd/tlkd/tlkd_private.h
services/spd/trusty/smcall.h
services/spd/trusty/trusty.c

index db9815f7865f198fdbddf65e01ef6e1d44cbea83..4e06bcd9ad3b6b2e4ed889122d0e8481103f2ebf 100644 (file)
 /*
  * 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
 /*
  * 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.
index 20a4866330f2473d9522d46b041b7e1a30ef72cc..418e4820ede97340a0f25bc19c55da2759070948 100644 (file)
@@ -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
 );
index 49ea499645ec4011da6433ee407313fc83ad2ecc..70cc9250cafa02bd22773a2ec6d9b555977dfa32 100644 (file)
@@ -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;
index a36a908e1d376a9071ead3e30dc7b13357ce0053..599d7a30f83b5682836ab5e32fec7d81c1591f2e 100644 (file)
@@ -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)
index 572e022a3af72a93999712dba5e2c864a1e65aaa..274886834fb5e3a26e0d2d2f9eda40f28f49500d 100644 (file)
@@ -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
 );
index 130544f00bd495a048fb6b322328220efda9d0ff..ba660989c2f7eba2ba882367a150a4082d9c242f 100644 (file)
@@ -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
  * 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
index d0299c7fbbc45e68f543cc523fa5dac704c17a66..99f1608d3794da335ec8507fcb95ca4122597440 100644 (file)
@@ -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 */
 #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)
 #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 */
index 1968ac45123f0c0ddcec106cc80fe4d523aa77d3..a95141bff4028ca2dc795965e00c0ebecde89ba5 100644 (file)
@@ -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
 );