feat(spmd): initialize SCR_EL3.EEL2 bit at RESET
This patch is meant to apply commit 8815cdaf5 to v2.8 releases cleanly.
SCR_EL3.EEL2 bit enabled denotes that the system has S-EL2 present and
enabled, Ideally this bit is constant throughout the lifetime and
should not be modified. Currently this bit is initialized in the context
mgmt code where each world copy of the SCR_EL3 register has this bit set
to 1, but for the time duration between the RESET and the first exit to
a lower EL this bit is zero.
Modifying SCR_EL3.EEL2 along with EA bit at RESET does also helps in
mitigating against ERRATA_V2_3099206.
For details on Neoverse V2 errata 3099206, refer the SDEN document
given below.
https://developer.arm.com/documentation/SDEN-2332927/latest
Change-Id: Ia246235aa8d8004dcaf845f21c8aeeabbbbbe520
Signed-off-by: Manish Pandey <manish.pandey2@arm.com>
diff --git a/lib/el3_runtime/aarch64/context_mgmt.c b/lib/el3_runtime/aarch64/context_mgmt.c
index 866ac41..2f1beeb 100644
--- a/lib/el3_runtime/aarch64/context_mgmt.c
+++ b/lib/el3_runtime/aarch64/context_mgmt.c
@@ -133,16 +133,6 @@
}
#endif /* CTX_INCLUDE_MTE_REGS */
- /* Enable S-EL2 if the next EL is EL2 and S-EL2 is present */
- if ((GET_EL(ep->spsr) == MODE_EL2) && is_armv8_4_sel2_present()) {
- if (GET_RW(ep->spsr) != MODE_RW_64) {
- ERROR("S-EL2 can not be used in AArch32\n.");
- panic();
- }
-
- scr_el3 |= SCR_EEL2_BIT;
- }
-
write_ctx_reg(state, CTX_SCR_EL3, scr_el3);
/*
@@ -380,6 +370,13 @@
scr_el3 |= SCR_TWEDEn_BIT;
#endif /* ENABLE_FEAT_TWED */
+#if IMAGE_BL31 && defined(SPD_spmd) && SPMD_SPM_AT_SEL2
+ /* Enable S-EL2 if FEAT_SEL2 is implemented for all the contexts. */
+ if (is_armv8_4_sel2_present()) {
+ scr_el3 |= SCR_EEL2_BIT;
+ }
+#endif /* (IMAGE_BL31 && defined(SPD_spmd) && SPMD_SPM_AT_SEL2) */
+
/*
* Populate EL3 state so that we've the right context
* before doing ERET