diff mbox

[02/11] target-arm: Make arm_current_el() return sensible values for M profile

Message ID 1422037228-5363-3-git-send-email-peter.maydell@linaro.org
State Superseded
Headers show

Commit Message

Peter Maydell Jan. 23, 2015, 6:20 p.m. UTC
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.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 target-arm/cpu.h | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Greg Bellows Jan. 23, 2015, 9:38 p.m. UTC | #1
On Fri, Jan 23, 2015 at 12:20 PM, Peter Maydell
<peter.maydell@linaro.org> wrote:
> 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.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  target-arm/cpu.h | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/target-arm/cpu.h b/target-arm/cpu.h
> index cd7a9e8..3eb00f4 100644
> --- a/target-arm/cpu.h
> +++ b/target-arm/cpu.h
> @@ -1211,6 +1211,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);
>      }
> --
> 1.9.1
>

Reviewed-by: Greg Bellows <greg.bellows@linaro.org>
diff mbox

Patch

diff --git a/target-arm/cpu.h b/target-arm/cpu.h
index cd7a9e8..3eb00f4 100644
--- a/target-arm/cpu.h
+++ b/target-arm/cpu.h
@@ -1211,6 +1211,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);
     }