Skip to content

Commit

Permalink
Cleanup HCR_EL2/VBAR_EL2 before jumping to aarch64 bootloader in EL2
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
stephan-gh committed Mar 28, 2021
1 parent 9f5e376 commit f68a765
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion qhypstub.s
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit f68a765

Please sign in to comment.