From 7f044bf8ccdc5455801492b5b59e65426ded6dce Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Fri, 2 Mar 2018 13:41:13 -0500 Subject: [PATCH] armv7m: Clear FAULTMASK on return from non-NMI exceptions FAULTMASK must be cleared on return from all exceptions other than NMI. Backports commit a20ee6005564590d33eabec11ed4dc7c432db36b from qemu --- qemu/target/arm/helper.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/qemu/target/arm/helper.c b/qemu/target/arm/helper.c index 8c0b7b01..bd4dcaf6 100644 --- a/qemu/target/arm/helper.c +++ b/qemu/target/arm/helper.c @@ -5339,8 +5339,14 @@ static void do_v7m_exception_exit(CPUARMState *env) uint32_t xpsr; type = env->regs[15]; - //if (env->v7m.exception != 0) - // armv7m_nvic_complete_irq(env->nvic, env->v7m.exception); + if (env->v7m.exception != ARMV7M_EXCP_NMI) { + /* Auto-clear FAULTMASK on return from other than NMI */ + env->daif &= ~PSTATE_F; + } + /* Unicorn: commented out + 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);