aarch64: reset: initialize CNTFRQ_EL0 in the highest EL

Can only be written at the highest Exception level implemented.
For example, if EL3 is the highest implemented Exception level,
CNTFRQ_EL0 can only be written at EL3.

Also move z_arm64_el_highest_plat_init to be called when is_el_highest

Signed-off-by: Peng Fan <peng.fan@nxp.com>
This commit is contained in:
Peng Fan 2021-03-08 18:56:19 +08:00 committed by Carles Cufí
commit b4f5b9e237
2 changed files with 19 additions and 1 deletions

View file

@ -153,6 +153,22 @@ static inline bool is_el_implemented(unsigned int el)
return (((read_id_aa64pfr0_el1() >> shift) & ID_AA64PFR0_ELX_MASK) != 0U);
}
static inline bool is_el_highest_implemented(void)
{
uint32_t el_highest;
uint32_t curr_el;
el_highest = read_id_aa64pfr0_el1() & 0xFFFF;
el_highest = (31U - __builtin_clz(el_highest)) / 4;
curr_el = GET_EL(read_currentel());
if (curr_el < el_highest)
return false;
return true;
}
static inline bool is_el2_sec_supported(void)
{
return (((read_id_aa64pfr0_el1() >> ID_AA64PFR0_SEL2_SHIFT) &