diff options
author | Jayanth Dodderi Chidanand <jayanthdodderi.chidanand@arm.com> | 2022-05-09 12:33:03 +0100 |
---|---|---|
committer | Jayanth Dodderi Chidanand <jayanthdodderi.chidanand@arm.com> | 2022-06-06 11:43:03 +0100 |
commit | 1298f2f13d6d97dfcac120a2ee68d5eea3797068 (patch) | |
tree | bf1b1da903dd38efcbc1b4524f8536c172528312 | |
parent | 5e529e32ee6cf6ac9203ada4fade49a47893fa51 (diff) | |
download | arm-trusted-firmware-1298f2f13d6d97dfcac120a2ee68d5eea3797068.tar.gz |
feat(brbe): add brbe under feature detection mechanism
This change adds "FEAT_BRBE" to be part of feature detection mechanism.
Previously feature enablement flags were of boolean type, possessing
either 0 or 1. With the introduction of feature detection procedure
we now support three states for feature enablement build flags(0 to 2).
Accordingly, "ENABLE_BRBE_FOR_NS" flag is now modified from boolean
to numeric type to align with the feature detection.
Signed-off-by: Jayanth Dodderi Chidanand <jayanthdodderi.chidanand@arm.com>
Change-Id: I1eb52863b4afb10b808e2f0b6584a8a210d0f38c
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | common/feat_detect.c | 13 | ||||
-rw-r--r-- | docs/getting_started/build-options.rst | 9 | ||||
-rw-r--r-- | include/arch/aarch64/arch_features.h | 11 | ||||
-rw-r--r-- | lib/extensions/brbe/brbe.c | 12 |
5 files changed, 32 insertions, 15 deletions
@@ -1045,7 +1045,6 @@ $(eval $(call assert_booleans,\ COT_DESC_IN_DTB \ USE_SP804_TIMER \ PSA_FWU_SUPPORT \ - ENABLE_BRBE_FOR_NS \ ENABLE_TRBE_FOR_NS \ ENABLE_SYS_REG_TRACE_FOR_NS \ ENABLE_MPMM \ @@ -1062,6 +1061,7 @@ $(eval $(call assert_numerics,\ CTX_INCLUDE_PAUTH_REGS \ CTX_INCLUDE_MTE_REGS \ CTX_INCLUDE_NEVE_REGS \ + ENABLE_BRBE_FOR_NS \ ENABLE_BTI \ ENABLE_PAUTH \ ENABLE_FEAT_AMUv1 \ diff --git a/common/feat_detect.c b/common/feat_detect.c index 8f98876ac..9d0685be6 100644 --- a/common/feat_detect.c +++ b/common/feat_detect.c @@ -234,6 +234,16 @@ 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_1) + feat_detect_panic(is_feat_brbe_present(), "BRBE"); +#endif +} + /*********************************************************************************** * TF-A supports many Arm architectural features starting from arch version * (8.0 till 8.7+). These features are mostly enabled through build flags. This @@ -294,6 +304,9 @@ void detect_arch_features(void) /* v8.7 features */ read_feat_hcx(); + /* v9.0 features */ + read_feat_brbe(); + /* v9.2 features */ read_feat_rme(); } diff --git a/docs/getting_started/build-options.rst b/docs/getting_started/build-options.rst index cfd7201c3..79159b7cd 100644 --- a/docs/getting_started/build-options.rst +++ b/docs/getting_started/build-options.rst @@ -982,10 +982,11 @@ Common build options functions that wait for an arbitrary time length (udelay and mdelay). The default value is 0. -- ``ENABLE_BRBE_FOR_NS``: This flag enables access to the branch record buffer - registers from NS ELs when FEAT_BRBE is implemented. BRBE is an optional - architectural feature for AArch64. The default is 0 and it is automatically - disabled when the target architecture is AArch32. +- ``ENABLE_BRBE_FOR_NS``: Numeric value to enable access to the branch record + buffer registers from NS ELs when FEAT_BRBE is implemented. BRBE is an + optional architectural feature for AArch64. This flag can take the values + 0 to 2, to align with the ``FEATURE_DETECTION`` mechanism. The default is 0 + and it is automatically disabled when the target architecture is AArch32. - ``ENABLE_TRBE_FOR_NS``: This flag is used to enable access of trace buffer control registers from NS ELs, NS-EL2 or NS-EL1(when NS-EL2 is implemented diff --git a/include/arch/aarch64/arch_features.h b/include/arch/aarch64/arch_features.h index 29710e736..cf39e1094 100644 --- a/include/arch/aarch64/arch_features.h +++ b/include/arch/aarch64/arch_features.h @@ -224,4 +224,15 @@ static inline unsigned int get_armv8_4_feat_nv_support(void) ID_AA64MMFR2_EL1_NV_MASK)); } +/******************************************************************************* + * Function to identify the presence of FEAT_BRBE (Branch Record Buffer + * Extension) + ******************************************************************************/ +static inline bool is_feat_brbe_present(void) +{ + return (((read_id_aa64dfr0_el1() >> ID_AA64DFR0_BRBE_SHIFT) & + ID_AA64DFR0_BRBE_MASK) == ID_AA64DFR0_BRBE_SUPPORTED); +} + + #endif /* ARCH_FEATURES_H */ diff --git a/lib/extensions/brbe/brbe.c b/lib/extensions/brbe/brbe.c index 6975b049c..1982619b7 100644 --- a/lib/extensions/brbe/brbe.c +++ b/lib/extensions/brbe/brbe.c @@ -5,22 +5,14 @@ */ #include <arch.h> +#include <arch_features.h> #include <arch_helpers.h> -static bool brbe_supported(void) -{ - uint64_t features; - - features = read_id_aa64dfr0_el1() >> ID_AA64DFR0_BRBE_SHIFT; - return ((features & ID_AA64DFR0_BRBE_MASK) == - ID_AA64DFR0_BRBE_SUPPORTED); -} - void brbe_enable(void) { uint64_t val; - if (brbe_supported()) { + if (is_feat_brbe_present()) { /* * MDCR_EL3.SBRBE = 0b01 * |