refactor(cpufeat): convert FEAT_HCX to new scheme

Use the generic check function in feat_detect.c, and split the feature
check into two functions, as done for FEAT_FGT before.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Change-Id: I0a4f973427c10d5d15c414ff5e12b18b7e645fae
This commit is contained in:
Andre Przywara 2022-11-15 11:45:19 +00:00
parent 15107daad6
commit d242128c1d
3 changed files with 18 additions and 15 deletions

View file

@ -99,7 +99,7 @@ void bl31_setup(u_register_t arg0, u_register_t arg1, u_register_t arg2,
* an exception would occur during context save/restore if enabled but
* not supported.
*/
assert(is_feat_hcx_present());
assert(is_feat_hcx_supported());
#endif /* ENABLE_FEAT_HCX */
#if CTX_INCLUDE_PAUTH_REGS

View file

@ -228,16 +228,6 @@ static void read_feat_twed(void)
#endif
}
/******************************************************************
* Feature : FEAT_HCX (Extended Hypervisor Configuration Register)
*****************************************************************/
static void read_feat_hcx(void)
{
#if (ENABLE_FEAT_HCX == FEAT_STATE_ALWAYS)
feat_detect_panic(is_feat_hcx_present(), "HCX");
#endif
}
/**************************************************
* Feature : FEAT_RME (Realm Management Extension)
*************************************************/
@ -341,7 +331,7 @@ void detect_arch_features(void)
read_feat_twed();
/* v8.7 features */
read_feat_hcx();
check_feature(ENABLE_FEAT_HCX, read_feat_hcx_id_field(), "HCX");
/* v9.0 features */
read_feat_brbe();

View file

@ -173,10 +173,23 @@ static inline unsigned int get_mpam_version(void)
ID_AA64PFR1_MPAM_FRAC_SHIFT) & ID_AA64PFR1_MPAM_FRAC_MASK));
}
static inline bool is_feat_hcx_present(void)
static inline unsigned int read_feat_hcx_id_field(void)
{
return (((read_id_aa64mmfr1_el1() >> ID_AA64MMFR1_EL1_HCX_SHIFT) &
ID_AA64MMFR1_EL1_HCX_MASK) == ID_AA64MMFR1_EL1_HCX_SUPPORTED);
return (read_id_aa64mmfr1_el1() >> ID_AA64MMFR1_EL1_HCX_SHIFT) &
ID_AA64MMFR1_EL1_HCX_MASK;
}
static inline bool is_feat_hcx_supported(void)
{
if (ENABLE_FEAT_HCX == FEAT_STATE_DISABLED) {
return false;
}
if (ENABLE_FEAT_HCX == FEAT_STATE_ALWAYS) {
return true;
}
return read_feat_hcx_id_field() != 0U;
}
static inline bool is_feat_rng_trap_present(void)