From cce21771b36248887cde6a51c15b4a8928a45ec8 Mon Sep 17 00:00:00 2001 From: Greg Bellows Date: Mon, 12 Feb 2018 10:33:00 -0500 Subject: [PATCH] target-arm: Change reset to highest available EL Update to arm_cpu_reset() to reset into the highest available exception level based on the set ARM features. Backports commit 5097227c15aa89baec1123aac25dd9500a62684d from qemu --- qemu/target-arm/cpu.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/qemu/target-arm/cpu.c b/qemu/target-arm/cpu.c index 9eee5973..7dda0e2a 100644 --- a/qemu/target-arm/cpu.c +++ b/qemu/target-arm/cpu.c @@ -109,7 +109,14 @@ static void arm_cpu_reset(CPUState *s) /* and to the FP/Neon instructions */ env->cp15.c1_coproc = deposit64(env->cp15.c1_coproc, 20, 2, 3); #else - env->pstate = PSTATE_MODE_EL1h; + /* Reset into the highest available EL */ + if (arm_feature(env, ARM_FEATURE_EL3)) { + env->pstate = PSTATE_MODE_EL3h; + } else if (arm_feature(env, ARM_FEATURE_EL2)) { + env->pstate = PSTATE_MODE_EL2h; + } else { + env->pstate = PSTATE_MODE_EL1h; + } env->pc = cpu->rvbar; #endif } else {