fix(cpufeat): do feature detection before feature enablement
Situations where feature configuration does not reflect hardware's
features can cause unhandled exceptions at EL3. Feature detection is
meant to guard against these errors by checking hardware against the
configuration. For this to happen though, feature detection has to
happen before these unhandled exceptions have had a chance to happen.
Change-Id: I47f05a9f01321e011623083afb638552311ed013
Signed-off-by: Boyan Karatotev <boyan.karatotev@arm.com>
diff --git a/bl31/bl31_main.c b/bl31/bl31_main.c
index 9d300b4..b8c915a 100644
--- a/bl31/bl31_main.c
+++ b/bl31/bl31_main.c
@@ -97,6 +97,11 @@
void bl31_setup(u_register_t arg0, u_register_t arg1, u_register_t arg2,
u_register_t arg3)
{
+#if FEATURE_DETECTION
+ /* Detect if features enabled during compilation are supported by PE. */
+ detect_arch_features(plat_my_core_pos());
+#endif /* FEATURE_DETECTION */
+
/* Enable early console if EARLY_CONSOLE flag is enabled */
plat_setup_early_console();
@@ -131,11 +136,6 @@
NOTICE("BL31: %s\n", build_version_string);
NOTICE("BL31: %s\n", build_message);
-#if FEATURE_DETECTION
- /* Detect if features enabled during compilation are supported by PE. */
- detect_arch_features(core_pos);
-#endif /* FEATURE_DETECTION */
-
#if ENABLE_RUNTIME_INSTRUMENTATION
PMF_CAPTURE_TIMESTAMP(bl_svc, BL31_ENTRY, PMF_CACHE_MAINT);
#endif