From fd231e32e92a5b78a0d5d18450ef1384b52a70f8 Mon Sep 17 00:00:00 2001 From: Jaxson Han Date: Tue, 1 Mar 2022 15:58:13 +0800 Subject: [PATCH] arm64: Fix booting issue with FVP V8R >= 11.16.16 In the Armv8R AArch64 profile[1], the Armv8R AArch64 is always in secure mode. But the FVP_BaseR_AEMv8R before version 11.16.16 doesn't strictly follow this rule. It still has some non-secure registers (e.g. CNTHP_CTL_EL2). Since version 11.16.16, the FVP_BaseR_AEMv8R has fixed this issue. The CNTHP_XXX_EL2 registers have been changed to CNTHPS_XXX_EL2. So the FVP_BaseR_AEMv8R (version >= 11.16.16) cannot boot Zephyr. This patch will fix it. [1] https://developer.arm.com/documentation/ddi0600/latest/ Signed-off-by: Jaxson Han Change-Id: If986f34dc080ae7a8b226bba589b6fe616a4260b --- arch/arm64/core/reset.c | 4 ++++ include/arch/arm64/lib_helpers.h | 1 + 2 files changed, 5 insertions(+) diff --git a/arch/arm64/core/reset.c b/arch/arm64/core/reset.c index 2c5372f6b84..e92efa27434 100644 --- a/arch/arm64/core/reset.c +++ b/arch/arm64/core/reset.c @@ -129,7 +129,11 @@ void z_arm64_el2_init(void) zero_cntvoff_el2(); /* Set 64-bit virtual timer offset to 0 */ zero_cnthctl_el2(); +#ifdef CONFIG_CPU_AARCH64_CORTEX_R + zero_cnthps_ctl_el2(); +#else zero_cnthp_ctl_el2(); +#endif /* * Enable this if/when we use the hypervisor timer. * write_cnthp_cval_el2(~(uint64_t)0); diff --git a/include/arch/arm64/lib_helpers.h b/include/arch/arm64/lib_helpers.h index 23ac8a0f1db..e03c0db039d 100644 --- a/include/arch/arm64/lib_helpers.h +++ b/include/arch/arm64/lib_helpers.h @@ -56,6 +56,7 @@ MAKE_REG_HELPER(cntfrq_el0); MAKE_REG_HELPER(cnthctl_el2); MAKE_REG_HELPER(cnthp_ctl_el2); +MAKE_REG_HELPER(cnthps_ctl_el2); MAKE_REG_HELPER(cntv_ctl_el0) MAKE_REG_HELPER(cntv_cval_el0) MAKE_REG_HELPER(cntvct_el0);