aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--el3/aarch64/el3_monitor_asm.S4
-rw-r--r--el3/el3.c12
2 files changed, 14 insertions, 2 deletions
diff --git a/el3/aarch64/el3_monitor_asm.S b/el3/aarch64/el3_monitor_asm.S
index 2eac3b3..ea69b6d 100644
--- a/el3/aarch64/el3_monitor_asm.S
+++ b/el3/aarch64/el3_monitor_asm.S
@@ -94,8 +94,8 @@ monitor_switch:
stp x0, x1, [sp, #-16]! /* Save the input regs x0:x3 */
stp x2, x3, [sp, #-16]! /* Save the input regs x0:x3 */
mrs x3, scr_el3
- and x3, x3, #0x1
- cbz x3, switch_to_nsec
+ and x2, x3, #0x1
+ cbz x2, switch_to_nsec
switch_to_sec:
adr x0, nsec_state
MONITOR_SAVE_STATE
diff --git a/el3/el3.c b/el3/el3.c
index 78e69d1..f8c9107 100644
--- a/el3/el3.c
+++ b/el3/el3.c
@@ -328,6 +328,18 @@ void el3_start(uintptr_t base, uintptr_t size)
el3_monitor_init();
+ /* Initialize SCR. In particular, we must ensure that SCR_EL3.RW is 1
+ * so that we define EL1 as AArch64; otherwise the exception return
+ * will fail; we also want SCR_EL3.NS to be 0.
+ * Setting SCR_ST and SCR_HCE isn't necessary but this configuration
+ * is essentially "turn off all the trap-to-EL3 possibilities".
+ */
+#ifdef AARCH64
+ WRITE_SCR(SCR_ST | SCR_RW | SCR_HCE);
+#else
+ WRITE_SCR(SCR_HCE);
+#endif
+
/* Set-up our state to return to secure EL1 to start its init on exception
* return.
*/