diff mbox series

[6/6] armv7m: Clear FAULTMASK on return from non-NMI exceptions

Message ID 1484937883-1068-7-git-send-email-peter.maydell@linaro.org
State Superseded
Headers show
Series ARMv7M: some simple bugfixes and cleanups | expand

Commit Message

Peter Maydell Jan. 20, 2017, 6:44 p.m. UTC
From: Michael Davidsaver <mdavidsaver@gmail.com>


FAULTMASK must be cleared on return from all
exceptions other than NMI.

Signed-off-by: Michael Davidsaver <mdavidsaver@gmail.com>

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

---
 target/arm/helper.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

-- 
2.7.4

Comments

Alex Bennée Jan. 24, 2017, 4:59 p.m. UTC | #1
Peter Maydell <peter.maydell@linaro.org> writes:

> From: Michael Davidsaver <mdavidsaver@gmail.com>

>

> FAULTMASK must be cleared on return from all

> exceptions other than NMI.

>

> Signed-off-by: Michael Davidsaver <mdavidsaver@gmail.com>

> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

> ---

>  target/arm/helper.c | 7 ++++++-

>  1 file changed, 6 insertions(+), 1 deletion(-)

>

> diff --git a/target/arm/helper.c b/target/arm/helper.c

> index dc383d1..cfbc622 100644

> --- a/target/arm/helper.c

> +++ b/target/arm/helper.c

> @@ -5969,8 +5969,13 @@ static void do_v7m_exception_exit(CPUARMState *env)

>      uint32_t xpsr;

>

>      type = env->regs[15];

> -    if (env->v7m.exception != 0)

> +    if (env->v7m.exception != ARMV7M_EXCP_NMI) {

> +        /* Auto-clear FAULTMASK on return from other than NMI */

> +        env->daif &= ~PSTATE_F;

> +    }

> +    if (env->v7m.exception != 0) {

>          armv7m_nvic_complete_irq(env->nvic, env->v7m.exception);

> +    }

>

>      /* Switch to the target stack.  */

>      switch_v7m_sp(env, (type & 4) != 0);


Reviewed-by: Alex Bennée <alex.bennee@linaro.org>


--
Alex Bennée
diff mbox series

Patch

diff --git a/target/arm/helper.c b/target/arm/helper.c
index dc383d1..cfbc622 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -5969,8 +5969,13 @@  static void do_v7m_exception_exit(CPUARMState *env)
     uint32_t xpsr;
 
     type = env->regs[15];
-    if (env->v7m.exception != 0)
+    if (env->v7m.exception != ARMV7M_EXCP_NMI) {
+        /* Auto-clear FAULTMASK on return from other than NMI */
+        env->daif &= ~PSTATE_F;
+    }
+    if (env->v7m.exception != 0) {
         armv7m_nvic_complete_irq(env->nvic, env->v7m.exception);
+    }
 
     /* Switch to the target stack.  */
     switch_v7m_sp(env, (type & 4) != 0);