From: Henry Beberman <Henry.Beberman@microsoft.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 02/11] arm: Allow U-Boot Proper to run in normal world
Date: Sat, 14 Jul 2018 00:11:47 +0000 [thread overview]
Message-ID: <20180714001117.14584-3-hebeberm@microsoft.com> (raw)
In-Reply-To: <20180714001117.14584-1-hebeberm@microsoft.com>
From: Henry Beberman <henry.beberman@microsoft.com>
In order to minimize the surface area of secure world code, the i.MX
Windows 10 IoT Core boot flow uses SPL to jump into OP-TEE as soon as
possible. Once OP-TEE has locked down resources it returns into the
entry point U-Boot Proper in normal world.
The CONFIG_SYS_NORMAL_WORLD Kconfig option has been added so that
segments of code with a dependency on secure world are built into SPL
and selectively omitted from the U-Boot Proper built for normal world.
This is only enabled when the CONFIG_SPL_OPTEE_BOOT Kconfig option is
set. CONFIG_SPL_OPTEE_BOOT is added in the next patch in this series.
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/Kconfig | 7 +++++++
arch/arm/cpu/armv7/start.S | 11 ++++++-----
arch/arm/mach-imx/mx7/soc.c | 7 +++++--
arch/arm/mach-imx/syscounter.c | 2 ++
include/configs/mx6_common.h | 5 +++++
include/configs/mx7_common.h | 5 +++++
6 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/arch/arm/cpu/armv7/Kconfig b/arch/arm/cpu/armv7/Kconfig
index 37a0be932e..21d68ccb67 100644
--- a/arch/arm/cpu/armv7/Kconfig
+++ b/arch/arm/cpu/armv7/Kconfig
@@ -58,4 +58,11 @@ config ARMV7_LPAE
Say Y here to use the long descriptor page table format. This is
required if U-Boot runs in HYP mode.
+config SYS_NORMAL_WORLD
+ bool "An internal build option that tells code that it is running in normal world"
+ default n
+ help
+ This option is set internally by headers if the code being
+ compiled must run in normal world.
+
endif
diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S
index c996525f86..14612fd0fe 100644
--- a/arch/arm/cpu/armv7/start.S
+++ b/arch/arm/cpu/armv7/start.S
@@ -168,30 +168,31 @@ ENTRY(cpu_init_cp15)
mcr p15, 0, r0, c1, c0, 0 @ write system control register
#endif
-#if (defined(CONFIG_ARM_ERRATA_742230) || defined(CONFIG_ARM_ERRATA_794072))
+#if (defined(CONFIG_ARM_ERRATA_742230) || defined(CONFIG_ARM_ERRATA_794072)) \
+ && !defined(CONFIG_SYS_NORMAL_WORLD)
mrc p15, 0, r0, c15, c0, 1 @ read diagnostic register
orr r0, r0, #1 << 4 @ set bit #4
mcr p15, 0, r0, c15, c0, 1 @ write diagnostic register
#endif
-#ifdef CONFIG_ARM_ERRATA_743622
+#if defined(CONFIG_ARM_ERRATA_743622) && !defined(CONFIG_SYS_NORMAL_WORLD)
mrc p15, 0, r0, c15, c0, 1 @ read diagnostic register
orr r0, r0, #1 << 6 @ set bit #6
mcr p15, 0, r0, c15, c0, 1 @ write diagnostic register
#endif
-#ifdef CONFIG_ARM_ERRATA_751472
+#if defined(CONFIG_ARM_ERRATA_751472) && !defined(CONFIG_SYS_NORMAL_WORLD)
mrc p15, 0, r0, c15, c0, 1 @ read diagnostic register
orr r0, r0, #1 << 11 @ set bit #11
mcr p15, 0, r0, c15, c0, 1 @ write diagnostic register
#endif
-#ifdef CONFIG_ARM_ERRATA_761320
+#if defined(CONFIG_ARM_ERRATA_761320) && !defined(CONFIG_SYS_NORMAL_WORLD)
mrc p15, 0, r0, c15, c0, 1 @ read diagnostic register
orr r0, r0, #1 << 21 @ set bit #21
mcr p15, 0, r0, c15, c0, 1 @ write diagnostic register
#endif
-#ifdef CONFIG_ARM_ERRATA_845369
+#if defined(CONFIG_ARM_ERRATA_845369) && !defined(CONFIG_SYS_NORMAL_WORLD)
mrc p15, 0, r0, c15, c0, 1 @ read diagnostic register
orr r0, r0, #1 << 22 @ set bit #22
mcr p15, 0, r0, c15, c0, 1 @ write diagnostic register
diff --git a/arch/arm/mach-imx/mx7/soc.c b/arch/arm/mach-imx/mx7/soc.c
index 2aca24bbb0..cc987f2599 100644
--- a/arch/arm/mach-imx/mx7/soc.c
+++ b/arch/arm/mach-imx/mx7/soc.c
@@ -135,7 +135,7 @@ u32 __weak get_board_rev(void)
#endif
/* enable all periherial can be accessed in nosec mode */
-static void init_csu(void)
+static void __maybe_unused init_csu(void)
{
int i = 0;
for (i = 0; i < CSU_NUM_REGS; i++)
@@ -164,7 +164,10 @@ int arch_cpu_init(void)
{
init_aips();
+#ifndef CONFIG_SYS_NORMAL_WORLD
init_csu();
+#endif
+
/* Disable PDE bit of WMCR register */
imx_wdog_disable_powerdown();
@@ -194,7 +197,7 @@ int arch_misc_init(void)
env_set("soc", "imx7s");
#endif
-#ifdef CONFIG_FSL_CAAM
+#if defined(CONFIG_FSL_CAAM) && !defined(CONFIG_SYS_NORMAL_WORLD)
sec_init();
#endif
diff --git a/arch/arm/mach-imx/syscounter.c b/arch/arm/mach-imx/syscounter.c
index 676bb3caa9..cfd82236f8 100644
--- a/arch/arm/mach-imx/syscounter.c
+++ b/arch/arm/mach-imx/syscounter.c
@@ -57,6 +57,7 @@ static inline unsigned long long us_to_tick(unsigned long long usec)
int timer_init(void)
{
+#if !defined(CONFIG_SYS_NORMAL_WORLD)
struct sctr_regs *sctr = (struct sctr_regs *)SCTR_BASE_ADDR;
unsigned long val, freq;
@@ -70,6 +71,7 @@ int timer_init(void)
val &= ~(SC_CNTCR_FREQ0 | SC_CNTCR_FREQ1);
val |= SC_CNTCR_FREQ0 | SC_CNTCR_ENABLE | SC_CNTCR_HDBG;
writel(val, &sctr->cntcr);
+#endif
gd->arch.tbl = 0;
gd->arch.tbu = 0;
diff --git a/include/configs/mx6_common.h b/include/configs/mx6_common.h
index 1b2961f68e..756db4da61 100644
--- a/include/configs/mx6_common.h
+++ b/include/configs/mx6_common.h
@@ -69,4 +69,9 @@
#endif
#endif
+/* If OPTEE boot is enabled, u-boot proper runs in normal world */
+#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_OPTEE_BOOT)
+#define CONFIG_SYS_NORMAL_WORLD
+#endif
+
#endif
diff --git a/include/configs/mx7_common.h b/include/configs/mx7_common.h
index b0b7e1edd4..4864df5108 100644
--- a/include/configs/mx7_common.h
+++ b/include/configs/mx7_common.h
@@ -58,4 +58,9 @@
#endif
#endif
+/* If OPTEE boot is enabled, u-boot proper runs in normal world */
+#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_OPTEE_BOOT)
+#define CONFIG_SYS_NORMAL_WORLD
+#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 ` [U-Boot] [PATCH 03/11] spl: Add FIT boot into OP-TEE then U-Boot proper Henry Beberman
2018-07-14 0:11 ` Henry Beberman [this message]
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-3-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