From be76b2519a4f3dbfd2371a6d75fdfea74effab12 Mon Sep 17 00:00:00 2001 From: ouyangxiangzhen Date: Thu, 19 Sep 2024 21:03:48 +0800 Subject: [PATCH] imx8qm-mek: Resolve boot issue for non-EL3 environments This commit addresses the issue of unauthorized writes to cntfrq_el0 during boot when not in EL3 mode. Signed-off-by: ouyangxiangzhen --- arch/arm64/src/imx8/imx8_boot.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/arch/arm64/src/imx8/imx8_boot.c b/arch/arm64/src/imx8/imx8_boot.c index 62e6b1f0fd720..61ac5159c701c 100644 --- a/arch/arm64/src/imx8/imx8_boot.c +++ b/arch/arm64/src/imx8/imx8_boot.c @@ -80,9 +80,15 @@ const struct arm_mmu_config g_mmu_config = void arm64_el_init(void) { - write_sysreg(CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC, cntfrq_el0); + uint64_t el = arm64_current_el(); - ARM64_ISB(); + /* Only in EL3 we can write to cntfrq_el0. */ + + if (el == 3) + { + write_sysreg(CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC, cntfrq_el0); + ARM64_ISB(); + } } /****************************************************************************