diff options
| author | Boyan Karatotev <boyan.karatotev@arm.com> | 2026-05-12 18:15:21 +0100 |
|---|---|---|
| committer | Boyan Karatotev <boyan.karatotev@arm.com> | 2026-07-30 09:00:25 +0100 |
| commit | cb2c6d77e35f8d138205d6a99535e84b4e4ec8d9 (patch) | |
| tree | de9f1d2d579eab990113456b60f20bdf86b79485 /include | |
| parent | 30cff0b4f99eae4df53fa9b2e6bd90528b94d7da (diff) | |
| download | arm-trusted-firmware-cb2c6d77e35f8d138205d6a99535e84b4e4ec8d9.tar.gz arm-trusted-firmware-cb2c6d77e35f8d138205d6a99535e84b4e4ec8d9.zip | |
refactor(cpufeat): always use is_feat_abc_supported()
The ENABLE_FEAT framework's sole purpose is to manage, and match up,
firmware's view of the hardware while considering features' enable
flags. Firmware's obeys the state of a feature's enable flag as law. If
that causes ill effects, then this is up to whoever set the flag to
figure out. There are tools, like FEATURE_DETECTION, FEAT_IDTE3, and
SMCCC Feature Availability to help manage these effects.
As such, the default check for a feature should be
is_feat_abc_supported(). If there is a flag, it should be obeyed. If
there is no flag then the central database should have a reasonable
default (usually FEAT_STATE_CHECKED). If that ever changes - the helper
will automatically reflect the change. There must be a very good reason
to look at ID registers if not requested and there are none of the ones
checked.
Only exception is bl31_traps.c. The exception injection code is much
more sensitive to misconfiguration and could open up the system to
security issues. So there it makes sense to insist on always checking
the ID registers.
Change-Id: I8829f35e775dc687e346006eaff0e4dd6f48c4ae
Signed-off-by: Boyan Karatotev <boyan.karatotev@arm.com>
Diffstat (limited to 'include')
| -rw-r--r-- | include/arch/aarch32/arch_features.h | 11 | ||||
| -rw-r--r-- | include/arch/aarch64/arch_features.h | 6 |
2 files changed, 10 insertions, 7 deletions
diff --git a/include/arch/aarch32/arch_features.h b/include/arch/aarch32/arch_features.h index 8a926297c..fe692d185 100644 --- a/include/arch/aarch32/arch_features.h +++ b/include/arch/aarch32/arch_features.h @@ -23,12 +23,13 @@ CREATE_FEATURE_SUPPORTED(name, idreg, field, min, guard) __attribute__((always_inline)) -static inline bool is_armv7_gentimer_present(void) +static inline bool is_armv7_gentimer_supported(void) { return EXTRACT(ID_PFR1_GENTIMER, read_id_pfr1()) != 0U; } -CREATE_FEATURE_PRESENT(feat_ttcnp, id_mmfr4, ID_MMFR4_CNP, 1U) +CREATE_FEATURE_FUNCS(feat_ttcnp, id_mmfr4, ID_MMFR4_CNP, + 1U, FEAT_STATE_CHECKED) CREATE_FEATURE_FUNCS(feat_amu, id_pfr0, ID_PFR0_AMU, ID_PFR0_AMU_V1, ENABLE_FEAT_AMU) @@ -51,9 +52,11 @@ CREATE_FEATURE_FUNCS(feat_dit, id_pfr0, ID_PFR0_DIT, CREATE_FEATURE_FUNCS(feat_pan, id_mmfr3, ID_MMFR3_PAN, 1U, ENABLE_FEAT_PAN) -CREATE_FEATURE_PRESENT(feat_ssbs, id_pfr2, ID_PFR2_SSBS, 1U) +CREATE_FEATURE_FUNCS(feat_ssbs, id_pfr2, ID_PFR2_SSBS, + 1U, FEAT_STATE_CHECKED) -CREATE_FEATURE_PRESENT(feat_pmuv3, id_dfr0, ID_DFR0_PERFMON, 3U) +CREATE_FEATURE_FUNCS(feat_pmuv3, id_dfr0, ID_DFR0_PERFMON, + 3U, FEAT_STATE_CHECKED) CREATE_FEATURE_FUNCS(feat_mtpmu, id_dfr1, ID_DFR1_MTPMU, 1U, DISABLE_MTPMU) diff --git a/include/arch/aarch64/arch_features.h b/include/arch/aarch64/arch_features.h index 540392fc3..cf4ea87fd 100644 --- a/include/arch/aarch64/arch_features.h +++ b/include/arch/aarch64/arch_features.h @@ -635,7 +635,7 @@ FEAT_MPAM_PE_BW_CTRL(CREATE_FEATURE_FUNCS) * Non-standard, not directly architectural helpers ******************************************************************************/ __attribute__((always_inline)) -static inline bool is_armv7_gentimer_present(void) +static inline bool is_armv7_gentimer_supported(void) { /* The Generic Timer is always present in an ARMv8-A implementation */ return true; @@ -660,7 +660,7 @@ static inline bool is_feat_crypto_supported(void) } __attribute__((always_inline)) -static inline bool is_feat_tgran4K_present(void) +static inline bool is_feat_tgran4K_supported(void) { unsigned int tgranx = (unsigned int)EXTRACT(ID_AA64MMFR0_EL1_TGRAN4, read_id_aa64mmfr0_el1()); @@ -668,7 +668,7 @@ static inline bool is_feat_tgran4K_present(void) } __attribute__((always_inline)) -static inline bool is_feat_tgran64K_present(void) +static inline bool is_feat_tgran64K_supported(void) { unsigned int tgranx = (unsigned int)EXTRACT(ID_AA64MMFR0_EL1_TGRAN64, read_id_aa64mmfr0_el1()); |
