aarch32: optee: define the OP-TEE secure payload
authorEtienne Carriere <etienne.carriere@linaro.org>
Mon, 5 Feb 2018 09:42:42 +0000 (10:42 +0100)
committerEtienne Carriere <etienne.carriere@linaro.org>
Mon, 5 Feb 2018 09:42:42 +0000 (10:42 +0100)
AArch32 only platforms can boot the OP-TEE secure firmware as
a BL32 secure payload. Such configuration can be defined through
AARCH32_SP=optee.

The source files can rely on AARCH32_SP_OPTEE to condition
OP-TEE boot specific instruction sequences.

OP-TEE does not expect ARM Trusted Firmware formatted structure
as boot argument. Load sequence is expected to have already loaded
to OP-TEE boot arguments into the bl32 entrypoint info structure.

Last, AArch32 platform can only boot AArch32 OP-TEE images.

Change-Id: Ic28eec5004315fc9111051add6bb1a1d607fc815
Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
bl2/bl2_image_load_v2.c
bl32/optee/optee.mk [new file with mode: 0644]
lib/optee/optee_utils.c

index 6517703d87893b52e1447e3b3d12fe36e6892ef2..198b65e405108c735b7101cd5c87d1aa7fe21925 100644 (file)
@@ -87,8 +87,10 @@ entry_point_info_t *bl2_load_images(void)
        assert(bl2_to_next_bl_params->h.version >= VERSION_2);
        assert(bl2_to_next_bl_params->head->ep_info);
 
-       /* Populate arg0 for the next BL image */
-       bl2_to_next_bl_params->head->ep_info->args.arg0 = (u_register_t)bl2_to_next_bl_params;
+       /* Populate arg0 for the next BL image if not already provided */
+       if (bl2_to_next_bl_params->head->ep_info->args.arg0 == 0)
+               bl2_to_next_bl_params->head->ep_info->args.arg0 =
+                                       (u_register_t)bl2_to_next_bl_params;
 
        /* Flush the parameters to be passed to next image */
        plat_flush_next_bl_params();
diff --git a/bl32/optee/optee.mk b/bl32/optee/optee.mk
new file mode 100644 (file)
index 0000000..462020f
--- /dev/null
@@ -0,0 +1,15 @@
+#
+# Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# This makefile only aims at complying with ARM Trusted Firmware build process so
+# that "optee" is a valid ARM Trusted Firmware AArch32 Secure Playload identifier.
+
+ifneq ($(ARCH),aarch32)
+$(error This directory targets AArch32 support)
+endif
+
+$(eval $(call add_define,AARCH32_SP_OPTEE))
+
+$(info ARM Trusted Firmware built for OP-TEE payload support)
index deb948c25cf07f5b9ced3c1bbcaaf9f011cc266d..87e52bd18854b05755c0c5e4dafc6b12fdb49d66 100644 (file)
@@ -158,9 +158,12 @@ int parse_optee_header(entry_point_info_t *header_ep,
         *      and BL32_EXTRA2_IMAGE_ID to load pager and paged bin.
         */
        if (!tee_validate_header(optee_header)) {
-               INFO("Invalid OPTEE header, legacy mode.\n");
-               /* Set legacy OPTEE runtime arch - aarch64 */
+               INFO("Invalid OPTEE header, set legacy mode.\n");
+#ifdef AARCH64
                header_ep->args.arg0 = MODE_RW_64;
+#else
+               header_ep->args.arg0 = MODE_RW_32;
+#endif
                return 0;
        }
 
@@ -208,10 +211,16 @@ int parse_optee_header(entry_point_info_t *header_ep,
        header_ep->args.arg2 = paged_image_info->image_size;
 
        /* Set OPTEE runtime arch - aarch32/aarch64 */
-       if (optee_header->arch == 0)
+       if (optee_header->arch == 0) {
                header_ep->args.arg0 = MODE_RW_32;
-       else
+       } else {
+#ifdef AARCH64
                header_ep->args.arg0 = MODE_RW_64;
+#else
+               ERROR("Cannot boot an AArch64 OP-TEE\n");
+               return -1;
+#endif
+       }
 
        return 0;
 }