From f68a765e6812163231c7b93b9b2328260ed5c915 Mon Sep 17 00:00:00 2001 From: Stephan Gerhold Date: Thu, 25 Mar 2021 19:37:42 +0100 Subject: [PATCH] Cleanup HCR_EL2/VBAR_EL2 before jumping to aarch64 bootloader in EL2 At the moment, attempting to boot U-Boot in EL2 using the HVC call results in the device rebooting. I'm not entirely sure why that happens, but it stops happening if I clear the HCR_EL2 register before jumping to U-Boot. I guess U-Boot does not properly reset these registers as it should. (Because the ARM manual describes most registers as having "an architecturally UNKNOWN" value on reset...) So, reset HCR_EL2 and while we're at it also VBAR_EL2 before we jump to the aarch64 bootloader/kernel in EL2. --- qhypstub.s | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/qhypstub.s b/qhypstub.s index f24a693..20a8e0c 100644 --- a/qhypstub.s +++ b/qhypstub.s @@ -174,8 +174,16 @@ finish_smc_switch_aarch64: /* * We get here once TZ has switched EL1 to aarch64 execution state * and EL1 ran into the Instruction Abort. - * Now, simply jump to the entry point directly in EL2! + * + * First, cleanup some EL2 configuration registers. This should not + * be necessary since the next bootloader/kernel/... should re-initialize + * these. However, not clearing HCR_EL2 causes reboots with U-Boot + * at least for some weird reason. I guess it doesn't hurt :) */ + msr hcr_el2, xzr + msr vbar_el2, xzr + + /* Now, simply jump to the entry point directly in EL2! */ mrs lr, elr_el2 ret