Remove coherent stack usage from the warm boot path
This patch uses stacks allocated in normal memory to enable the MMU early in the
warm boot path thus removing the dependency on stacks allocated in coherent
memory. Necessary cache and stack maintenance is performed when a cpu is being
powered down and up. This avoids any coherency issues that can arise from
reading speculatively fetched stale stack memory from another CPUs cache. These
changes affect the warm boot path in both BL3-1 and BL3-2.
The EL3 system registers responsible for preserving the MMU state are not saved
and restored any longer. Static values are used to program these system
registers when a cpu is powered on or resumed from suspend.
Change-Id: I8357e2eb5eb6c5f448492c5094b82b8927603784
diff --git a/bl31/aarch64/context.S b/bl31/aarch64/context.S
index 2698215..79b5d19 100644
--- a/bl31/aarch64/context.S
+++ b/bl31/aarch64/context.S
@@ -43,23 +43,9 @@
.global el3_sysregs_context_save
func el3_sysregs_context_save
- mrs x10, sctlr_el3
- str x10, [x0, #CTX_SCTLR_EL3]
-
- mrs x11, cptr_el3
- stp x11, xzr, [x0, #CTX_CPTR_EL3]
-
- mrs x13, cntfrq_el0
- mrs x14, mair_el3
- stp x13, x14, [x0, #CTX_CNTFRQ_EL0]
-
- mrs x15, tcr_el3
- mrs x16, ttbr0_el3
- stp x15, x16, [x0, #CTX_TCR_EL3]
-
- mrs x17, daif
- and x17, x17, #(DAIF_ABT_BIT | DAIF_DBG_BIT)
- stp x17, xzr, [x0, #CTX_DAIF_EL3]
+ mrs x10, cptr_el3
+ mrs x11, cntfrq_el0
+ stp x10, x11, [x0, #CTX_CPTR_EL3]
ret
@@ -78,27 +64,9 @@
.global el3_sysregs_context_restore
func el3_sysregs_context_restore
- ldp x11, xzr, [x0, #CTX_CPTR_EL3]
- msr cptr_el3, x11
-
- ldp x13, x14, [x0, #CTX_CNTFRQ_EL0]
- msr cntfrq_el0, x13
- msr mair_el3, x14
-
- ldp x15, x16, [x0, #CTX_TCR_EL3]
- msr tcr_el3, x15
- msr ttbr0_el3, x16
-
- ldp x17, xzr, [x0, #CTX_DAIF_EL3]
- mrs x11, daif
- orr x17, x17, x11
- msr daif, x17
-
- /* Make sure all the above changes are observed */
- isb
-
- ldr x10, [x0, #CTX_SCTLR_EL3]
- msr sctlr_el3, x10
+ ldp x13, x14, [x0, #CTX_CPTR_EL3]
+ msr cptr_el3, x13
+ msr cntfrq_el0, x14
isb
ret
diff --git a/bl31/aarch64/runtime_exceptions.S b/bl31/aarch64/runtime_exceptions.S
index a11cd71..0ab86ab 100644
--- a/bl31/aarch64/runtime_exceptions.S
+++ b/bl31/aarch64/runtime_exceptions.S
@@ -403,7 +403,7 @@
mrs x17, elr_el3
mrs x18, scr_el3
stp x16, x17, [x6, #CTX_EL3STATE_OFFSET + CTX_SPSR_EL3]
- stp x18, xzr, [x6, #CTX_EL3STATE_OFFSET + CTX_SCR_EL3]
+ str x18, [x6, #CTX_EL3STATE_OFFSET + CTX_SCR_EL3]
/* Copy SCR_EL3.NS bit to the flag to indicate caller's security */
bfi x7, x18, #0, #1
@@ -446,7 +446,7 @@
* Restore SPSR_EL3, ELR_EL3 and SCR_EL3 prior to ERET
* -----------------------------------------------------
*/
- ldp x18, xzr, [sp, #CTX_EL3STATE_OFFSET + CTX_SCR_EL3]
+ ldr x18, [sp, #CTX_EL3STATE_OFFSET + CTX_SCR_EL3]
ldp x16, x17, [sp, #CTX_EL3STATE_OFFSET + CTX_SPSR_EL3]
msr scr_el3, x18
msr spsr_el3, x16
diff --git a/bl31/bl31.mk b/bl31/bl31.mk
index 5555c31..fb17a2e 100644
--- a/bl31/bl31.mk
+++ b/bl31/bl31.mk
@@ -48,6 +48,7 @@
services/std_svc/psci/psci_afflvl_suspend.c \
services/std_svc/psci/psci_common.c \
services/std_svc/psci/psci_entry.S \
+ services/std_svc/psci/psci_helpers.S \
services/std_svc/psci/psci_main.c \
services/std_svc/psci/psci_setup.c