]> git.baikalelectronics.ru Git - arm-tf.git/commitdiff
refactor(brbe): enable FEAT_BRBE for FEAT_STATE_CHECKED
authorAndre Przywara <andre.przywara@arm.com>
Thu, 17 Nov 2022 16:42:09 +0000 (16:42 +0000)
committerAndre Przywara <andre.przywara@arm.com>
Mon, 27 Feb 2023 18:04:14 +0000 (18:04 +0000)
At the moment we only support FEAT_BRBE to be either unconditionally
compiled in, or to be not supported at all.

Add support for runtime detection (ENABLE_BRBE_FOR_NS=2), by splitting
is_feat_brbe_present() into an ID register reading function and a second
function to report the support status. That function considers both
build time settings and runtime information (if needed), and is used
before we access BRBE related registers.

The FVP platform decided to compile in support unconditionally (=1),
even though FEAT_BRBE is an ARMv9 feature, so is not available with the
FVP model's default command line.
Change that to the now supported dynamic option (=2), so the right
decision can be made by the code at runtime.

Change-Id: I5f2e2c9648300f65f0fa9a5f8e2f34e73529d053
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
bl31/bl31.mk
common/feat_detect.c
include/arch/aarch64/arch_features.h
lib/el3_runtime/aarch64/context_mgmt.c
lib/extensions/brbe/brbe.c
plat/arm/board/fvp/platform.mk

index 4d2fc874dbef1eacdbb9e7773360cc3da03f064a..ebb664e9a8fd9c479ee72a23fdb946f8e4c175b5 100644 (file)
@@ -116,7 +116,7 @@ ifneq (${ENABLE_TRBE_FOR_NS},0)
 BL31_SOURCES           +=      lib/extensions/trbe/trbe.c
 endif
 
-ifeq (${ENABLE_BRBE_FOR_NS},1)
+ifneq (${ENABLE_BRBE_FOR_NS},0)
 BL31_SOURCES           +=      lib/extensions/brbe/brbe.c
 endif
 
index 3012c8bbe68ce1868de612c39a5c69ab3df51ca1..4c54cb5f8768d1c36aad4590435f57c6c8f44568 100644 (file)
@@ -248,16 +248,6 @@ static void read_feat_rme(void)
 #endif
 }
 
-/******************************************************
- * Feature : FEAT_BRBE (Branch Record Buffer Extension)
- *****************************************************/
-static void read_feat_brbe(void)
-{
-#if (ENABLE_BRBE_FOR_NS == FEAT_STATE_ALWAYS)
-       feat_detect_panic(is_feat_brbe_present(), "BRBE");
-#endif
-}
-
 /******************************************************************
  * Feature : FEAT_RNG_TRAP (Trapping support for RNDR/RNDRRS)
  *****************************************************************/
@@ -334,7 +324,8 @@ void detect_arch_features(void)
        check_feature(ENABLE_FEAT_HCX, read_feat_hcx_id_field(), "HCX", 1, 1);
 
        /* v9.0 features */
-       read_feat_brbe();
+       check_feature(ENABLE_BRBE_FOR_NS, read_feat_brbe_id_field(),
+                     "BRBE", 1, 2);
        check_feature(ENABLE_TRBE_FOR_NS, read_feat_trbe_id_field(),
                      "TRBE", 1, 1);
 
index ded42d477c4f6b62023b595192c4ab89049bb4f8..9f6af39af77e43a59f2b06d5a3cbb99ea5c03f7a 100644 (file)
@@ -288,10 +288,22 @@ static inline unsigned int get_armv8_4_feat_nv_support(void)
  * Function to identify the presence of FEAT_BRBE (Branch Record Buffer
  * Extension)
  ******************************************************************************/
-static inline bool is_feat_brbe_present(void)
+static inline unsigned int read_feat_brbe_id_field(void)
 {
-       return (((read_id_aa64dfr0_el1() >> ID_AA64DFR0_BRBE_SHIFT) &
-               ID_AA64DFR0_BRBE_MASK) == ID_AA64DFR0_BRBE_SUPPORTED);
+       return ISOLATE_FIELD(read_id_aa64dfr0_el1(), ID_AA64DFR0_BRBE);
+}
+
+static inline bool is_feat_brbe_supported(void)
+{
+       if (ENABLE_BRBE_FOR_NS == FEAT_STATE_DISABLED) {
+               return false;
+       }
+
+       if (ENABLE_BRBE_FOR_NS == FEAT_STATE_ALWAYS) {
+               return true;
+       }
+
+       return read_feat_brbe_id_field() != 0U;
 }
 
 /*******************************************************************************
index 1dfb71f76b36d19e7176d1ceed60a66ee5767ef7..54e257b756eb5509543fdc1570cf23faf2945c94 100644 (file)
@@ -499,9 +499,9 @@ static void manage_extensions_nonsecure(bool el2_unused, cpu_context_t *ctx)
                trbe_enable();
        }
 
-#if ENABLE_BRBE_FOR_NS
-       brbe_enable();
-#endif /* ENABLE_BRBE_FOR_NS */
+       if (is_feat_brbe_supported()) {
+               brbe_enable();
+       }
 
 #if ENABLE_SYS_REG_TRACE_FOR_NS
        sys_reg_trace_enable(ctx);
index 1982619b7c92120055a1d3d13fa86e2eda5fcaeb..329cf982a2e56ab2748bb98627fb11bb429b0977 100644 (file)
@@ -12,16 +12,14 @@ void brbe_enable(void)
 {
        uint64_t val;
 
-       if (is_feat_brbe_present()) {
-               /*
-                * MDCR_EL3.SBRBE = 0b01
-                *
-                * Allows BRBE usage in non-secure world and prohibited in
-                * secure world.
-                */
-               val = read_mdcr_el3();
-               val &= ~(MDCR_SBRBE_MASK << MDCR_SBRBE_SHIFT);
-               val |= (0x1UL << MDCR_SBRBE_SHIFT);
-               write_mdcr_el3(val);
-       }
+       /*
+        * MDCR_EL3.SBRBE = 0b01
+        *
+        * Allows BRBE usage in non-secure world and prohibited in
+        * secure world.
+        */
+       val = read_mdcr_el3();
+       val &= ~(MDCR_SBRBE_MASK << MDCR_SBRBE_SHIFT);
+       val |= (0x1UL << MDCR_SBRBE_SHIFT);
+       write_mdcr_el3(val);
 }
index 7991c14f6bee6c0253c5ff27d8277256eada6cc1..dda7e6cfebb3cb461382b24ccb4658bc4394d17b 100644 (file)
@@ -453,7 +453,7 @@ ENABLE_TRBE_FOR_NS          := 2
 # do not enable when ENABLE_RME=1
 ifeq (${ARCH}, aarch64)
 ifeq (${ENABLE_RME},0)
-       ENABLE_BRBE_FOR_NS              := 1
+       ENABLE_BRBE_FOR_NS              := 2
 endif
 endif