diff options
author | Andre Przywara <andre.przywara@arm.com> | 2022-11-17 16:42:09 +0000 |
---|---|---|
committer | Andre Przywara <andre.przywara@arm.com> | 2023-03-20 13:37:36 +0000 |
commit | 6437a09a2db5774438fb1a95c508ed6b0a9f0ef2 (patch) | |
tree | 831ab1562452ab1700c3e40684dd871fb4deb083 /include/arch | |
parent | 90118bb5c180198db3386c3e1f5be8e32707c2cc (diff) | |
download | arm-trusted-firmware-6437a09a2db5774438fb1a95c508ed6b0a9f0ef2.tar.gz |
refactor(spe): enable FEAT_SPE for FEAT_STATE_CHECKED
At the moment we only support FEAT_SPE to be either unconditionally
compiled in, or to be not supported at all.
Add support for runtime detection (ENABLE_SPE_FOR_NS=2), by splitting
is_armv8_2_feat_spe_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 SPE related registers.
Previously SPE was enabled unconditionally for all platforms, change
this now to the runtime detection version.
Change-Id: I830c094107ce6a398bf1f4aef7ffcb79d4f36552
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Diffstat (limited to 'include/arch')
-rw-r--r-- | include/arch/aarch32/arch_features.h | 6 | ||||
-rw-r--r-- | include/arch/aarch64/arch_features.h | 18 |
2 files changed, 21 insertions, 3 deletions
diff --git a/include/arch/aarch32/arch_features.h b/include/arch/aarch32/arch_features.h index a5a5e278b..12df6da4b 100644 --- a/include/arch/aarch32/arch_features.h +++ b/include/arch/aarch32/arch_features.h @@ -43,4 +43,10 @@ static inline bool is_feat_trf_supported(void) return read_feat_trf_id_field() != 0U; } +static inline bool is_feat_spe_supported(void) +{ + /* FEAT_SPE is AArch64 only */ + return false; +} + #endif /* ARCH_FEATURES_H */ diff --git a/include/arch/aarch64/arch_features.h b/include/arch/aarch64/arch_features.h index 582aed12f..58b37521b 100644 --- a/include/arch/aarch64/arch_features.h +++ b/include/arch/aarch64/arch_features.h @@ -249,10 +249,22 @@ static inline bool is_armv8_0_feat_csv2_2_present(void) /********************************************************************************** * Function to identify the presence of FEAT_SPE (Statistical Profiling Extension) *********************************************************************************/ -static inline bool is_armv8_2_feat_spe_present(void) +static inline unsigned int read_feat_spe_id_field(void) { - return (((read_id_aa64dfr0_el1() >> ID_AA64DFR0_PMS_SHIFT) & - ID_AA64DFR0_PMS_MASK) != ID_AA64DFR0_SPE_NOT_SUPPORTED); + return ISOLATE_FIELD(read_id_aa64dfr0_el1(), ID_AA64DFR0_PMS); +} + +static inline bool is_feat_spe_supported(void) +{ + if (ENABLE_SPE_FOR_NS == FEAT_STATE_DISABLED) { + return false; + } + + if (ENABLE_SPE_FOR_NS == FEAT_STATE_ALWAYS) { + return true; + } + + return read_feat_spe_id_field() != 0U; } /******************************************************************************* |