From ec4dae08e454bd099de16a55432112a2a1d90b0b Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Mon, 12 Feb 2018 11:07:24 -0500 Subject: [PATCH] target-arm: Make arm_current_el() return sensible values for M profile Although M profile doesn't have the same concept of exception level as A profile, it does have a notion of privileged versus not, which we currently track in the privmode TB flag. Support returning this information if arm_current_el() is called on an M profile core, so that we can identify the correct MMU index to use (and put the MMU index in the TB flags) without having to special-case M profile. Backports commit 6d54ed3c93f1e05a483201b087142998381c9be8 from qemu --- qemu/target-arm/cpu.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qemu/target-arm/cpu.h b/qemu/target-arm/cpu.h index 38e784f3..9003dffe 100644 --- a/qemu/target-arm/cpu.h +++ b/qemu/target-arm/cpu.h @@ -1234,6 +1234,10 @@ static inline bool cptype_valid(int cptype) */ static inline int arm_current_el(CPUARMState *env) { + if (arm_feature(env, ARM_FEATURE_M)) { + return !((env->v7m.exception == 0) && (env->v7m.control & 1)); + } + if (is_a64(env)) { return extract32(env->pstate, 2, 2); }