From: Henry Beberman <Henry.Beberman@microsoft.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 03/11] spl: Add FIT boot into OP-TEE then U-Boot proper
Date: Sat, 14 Jul 2018 00:11:47 +0000 [thread overview]
Message-ID: <20180714001117.14584-4-hebeberm@microsoft.com> (raw)
In-Reply-To: <20180714001117.14584-1-hebeberm@microsoft.com>
From: Henry Beberman <henry.beberman@microsoft.com>
This patch is a part of the i.MX Windows 10 IoT Core boot flow.
It adds an entry path for OP-TEE when loaded from a FIT blob when
loadable has the OS type IH_OS_TEE. This booth path flushes and
disables caches, disables interrupts, and jumps into OP-TEE passing
the entry point for U-Boot Proper in one of the registers.
The CONFIG_SPL_OPTEE_BOOT option enables this boot path, and is also
used to automatically set the CONFIG_SYS_NORMAL_WORLD Kconfig option
while building U-Boot proper. This is because when OP-TEE returns to
U-Boot proper's entry point, it will be in normal mode, so several
secure world only initializations need to be omitted.
New Kconfig option:
CONFIG_SPL_OPTEE_BOOT - Enables SPL FIT to boot in to OP-TEE, and will
set the CONFIG_SYS_NORMAL_WORLD in U-Boot Proper to omit secure world
only code.
Signed-off-by: Henry Beberman <henry.beberman@microsoft.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Cc: Tom Rini <trini@konsulko.com>
---
arch/arm/cpu/armv7/Makefile | 1 +
arch/arm/cpu/armv7/optee_jump.S | 31 +++++++++++++++++++++++++++++++
arch/arm/lib/spl.c | 16 ++++++++++++++++
common/spl/Kconfig | 9 +++++++++
common/spl/spl.c | 6 ++++++
include/spl.h | 21 +++++++++++++++++++++
6 files changed, 84 insertions(+)
create mode 100644 arch/arm/cpu/armv7/optee_jump.S
diff --git a/arch/arm/cpu/armv7/Makefile b/arch/arm/cpu/armv7/Makefile
index 4f4647c90a..5bad36a8b8 100644
--- a/arch/arm/cpu/armv7/Makefile
+++ b/arch/arm/cpu/armv7/Makefile
@@ -27,6 +27,7 @@ obj-$(CONFIG_ARMV7_PSCI) += psci.o psci-common.o
obj-$(CONFIG_IPROC) += iproc-common/
obj-$(CONFIG_KONA) += kona-common/
obj-$(CONFIG_SYS_ARCH_TIMER) += arch_timer.o
+obj-$(CONFIG_SPL_OPTEE_BOOT) += optee_jump.o
ifneq (,$(filter s5pc1xx exynos,$(SOC)))
obj-y += s5p-common/
diff --git a/arch/arm/cpu/armv7/optee_jump.S b/arch/arm/cpu/armv7/optee_jump.S
new file mode 100644
index 0000000000..2a1d994bcc
--- /dev/null
+++ b/arch/arm/cpu/armv7/optee_jump.S
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2018 Microsoft Corporation
+ */
+
+#include <asm-offsets.h>
+#include <config.h>
+#include <asm/system.h>
+#include <linux/linkage.h>
+
+#ifdef CONFIG_SPL_OPTEE_BOOT
+
+ .globl arch_jump_to_image_optee
+
+/*
+ void __noreturn arch_jump_to_image_optee(
+ u32 optee_entry_point,
+ u32 pageable_part,
+ u32 uboot_entry_point
+ );
+*/
+ENTRY(arch_jump_to_image_optee)
+
+ mov r3, r0
+ mov r0, r1
+ mov lr, r2
+
+ bx r3
+
+ENDPROC(arch_jump_to_image_optee)
+#endif
diff --git a/arch/arm/lib/spl.c b/arch/arm/lib/spl.c
index 33cc76ba3d..ee311d9fe8 100644
--- a/arch/arm/lib/spl.c
+++ b/arch/arm/lib/spl.c
@@ -73,3 +73,19 @@ void __noreturn jump_to_image_linux(struct spl_image_info *spl_image)
}
#endif /* CONFIG_ARM64 */
#endif
+
+#ifdef CONFIG_SPL_OPTEE_BOOT
+void __noreturn arch_jump_to_image_optee(u32 optee_entry_point,
+ u32 pageable_part,
+ u32 uboot_entry_point);
+
+void __noreturn jump_to_image_optee(struct spl_image_info *spl_image)
+{
+ /* flush and turn off caches before jumping to OPTEE */
+ cleanup_before_linux();
+
+ arch_jump_to_image_optee(spl_image->entry_point,
+ 0,
+ CONFIG_SYS_TEXT_BASE);
+}
+#endif
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 0bbf8d5b02..643484a4a4 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -792,6 +792,15 @@ config SPL_ATF_NO_PLATFORM_PARAM
If your ATF is affected, say Y.
+config SPL_OPTEE_BOOT
+ depends on SPL
+ bool "Enable support for loading OPTEE and jumping to it from SPL"
+ default n
+ help
+ Configure SPL to boot OPTEE. SPL passes the U-Boot proper entry
+ point as the return address when it jumps to OPTEE, allowing OPTEE
+ to start U-Boot proper in normal mode when it returns.
+
config SPL_AM33XX_ENABLE_RTC32K_OSC
bool "Enable the RTC32K OSC on AM33xx based platforms"
default y if AM33XX
diff --git a/common/spl/spl.c b/common/spl/spl.c
index a09ada37d7..237083b08d 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -519,6 +519,12 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
spl_invoke_atf(&spl_image);
break;
#endif
+#ifdef CONFIG_SPL_OPTEE_BOOT
+ case IH_OS_TEE:
+ debug("Jumping to OPTEE\n");
+ jump_to_image_optee(&spl_image);
+ break;
+#endif
#ifdef CONFIG_SPL_OS_BOOT
case IH_OS_LINUX:
debug("Jumping to Linux\n");
diff --git a/include/spl.h b/include/spl.h
index 8454ea7ad4..338b4b573d 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -125,6 +125,19 @@ int spl_board_ubi_load_image(u32 boot_device);
*/
void __noreturn jump_to_image_linux(struct spl_image_info *spl_image);
+#ifdef CONFIG_SPL_OPTEE_BOOT
+/**
+ * jump_to_image_optee() - Jump to OP-TEE from SPL
+ *
+ * This jumps into OP-TEE using the information in @spl_image, passing
+ * it the entry point of U-Boot Proper so it can return there
+ * in non-secure mode
+ *
+ * @spl_image: Image description to set up
+ */
+void __noreturn jump_to_image_optee(struct spl_image_info *spl_image);
+#endif
+
/**
* spl_start_uboot() - Check if SPL should start the kernel or U-Boot
*
@@ -296,4 +309,12 @@ void spl_invoke_atf(struct spl_image_info *spl_image);
* can implement 'board_return_to_bootrom'.
*/
void board_return_to_bootrom(void);
+
+#ifdef CONFIG_SPL_OPTEE_BOOT
+#include <tee/optee.h>
+
+struct optee_image_info {
+ struct optee_header header;
+};
+#endif
#endif
--
2.16.2.gvfs.1.33.gf5370f1
next prev parent reply other threads:[~2018-07-14 0:11 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-14 0:11 [U-Boot] [PATCH 00/11] Enable Windows 10 IoT Core on i.MX6 and i.MX7 Henry Beberman
2018-07-14 0:11 ` [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI from mmc Henry Beberman
2018-07-16 17:16 ` Trent Piepho
2018-07-16 22:28 ` Henry Beberman
2018-07-16 22:45 ` Trent Piepho
2018-07-16 23:56 ` Henry Beberman
2018-07-17 17:24 ` Trent Piepho
2018-07-18 0:52 ` Henry Beberman
2018-07-17 17:09 ` Fabio Estevam
2018-07-17 17:20 ` Henry Beberman
2018-08-07 11:11 ` Stefano Babic
2018-08-07 11:16 ` Tom Rini
2018-08-07 13:45 ` Alexander Graf
2018-08-08 2:24 ` Henry Beberman
2018-08-15 14:46 ` Alexander Graf
2018-07-14 0:11 ` Henry Beberman [this message]
2018-07-14 0:11 ` [U-Boot] [PATCH 02/11] arm: Allow U-Boot Proper to run in normal world Henry Beberman
2018-07-14 0:11 ` [U-Boot] [PATCH 04/11] spl: imx: Add optional lds to keep SPL entirely in on-chip RAM Henry Beberman
2018-07-16 17:32 ` Trent Piepho
2018-07-16 22:48 ` Henry Beberman
2018-08-07 12:17 ` Stefano Babic
2018-08-08 3:22 ` Henry Beberman
2018-07-14 0:11 ` [U-Boot] [PATCH 05/11] mx6sabresd: Add Windows boot support for iMX6 Sabre Henry Beberman
2018-07-14 0:11 ` [U-Boot] [PATCH 07/11] mx6cuboxi: Add Windows boot support for mx6cuboxi Henry Beberman
2018-07-14 0:11 ` [U-Boot] [PATCH 06/11] mx7dsabresd: Add Windows boot support for iMX7 Sabre Henry Beberman
2018-07-16 18:22 ` Trent Piepho
2018-07-17 1:41 ` Henry Beberman
2018-07-17 17:02 ` Trent Piepho
2018-07-17 21:31 ` Henry Beberman
2018-07-14 0:11 ` [U-Boot] [PATCH 08/11] udoo_neo: Add Windows boot support for UDOO Neo Henry Beberman
2018-07-14 0:11 ` [U-Boot] [PATCH 09/11] cl-som-imx7: Add Windows boot support for cl-som-imx7 Henry Beberman
2018-07-14 0:11 ` [U-Boot] [PATCH 11/11] imx: Add MAC addresses to global page to pass MAC into UEFI Henry Beberman
2018-07-14 0:11 ` [U-Boot] [PATCH 10/11] imx: Reserve a global page in memory to pass configuration to UEFI Henry Beberman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180714001117.14584-4-hebeberm@microsoft.com \
--to=henry.beberman@microsoft.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox