Skip to content

Commit 314b72f

Browse files
cocoeolicarlescufi
authored andcommitted
arch: arm64: Re-init HCR_EL2 in z_arm64_el2_init
HCR_EL2 is configured to certain value by some loaders such as Uboot on some arm64 boards(such as roc_rk3568_pc), When HCR_EL2.TGE, HCR_EL2.AMO and HCR_EL2.IMO bits are set to 1, some unpredictable behaviors may occur during zephyr boot. So we clear these bits to avoid it. Signed-off-by: Charlie Xiong <[email protected]>
1 parent 3ed1c99 commit 314b72f

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

arch/arm64/core/reset.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ void z_arm64_el2_init(void)
125125
write_sctlr_el2(reg);
126126

127127
reg = read_hcr_el2();
128+
/* when EL2 is enable in current security status:
129+
* Clear TGE bit: All exceptions that would not be routed to EL2;
130+
* Clear AMO bit: Physical SError interrupts are not taken to EL2 and EL3.
131+
* Clear IMO bit: Physical IRQ interrupts are not taken to EL2 and EL3.
132+
*/
133+
reg &= ~(HCR_IMO_BIT | HCR_AMO_BIT | HCR_TGE_BIT);
128134
reg |= HCR_RW_BIT; /* EL1 Execution state is AArch64 */
129135
write_hcr_el2(reg);
130136

include/zephyr/arch/arm64/cpu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@
137137
#define HCR_FMO_BIT BIT(3)
138138
#define HCR_IMO_BIT BIT(4)
139139
#define HCR_AMO_BIT BIT(5)
140+
#define HCR_TGE_BIT BIT(27)
140141
#define HCR_RW_BIT BIT(31)
141142

142143
/* System register interface to GICv3 */

0 commit comments

Comments
 (0)