Received: from eggs.gnu.org ([2001:4830:134:3::10]:36118) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a4Hc0-00049F-Os for qemu-devel@nongnu.org; Wed, 02 Dec 2015 19:19:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a4Hc0-0001xG-1b for qemu-devel@nongnu.org; Wed, 02 Dec 2015 19:19:04 -0500 From: Michael Davidsaver Date: Wed, 2 Dec 2015 19:18:33 -0500 Message-Id: <1449101933-24928-7-git-send-email-mdavidsaver@gmail.com> In-Reply-To: <1449101933-24928-1-git-send-email-mdavidsaver@gmail.com> References: <1449101933-24928-1-git-send-email-mdavidsaver@gmail.com> Subject: [Qemu-devel] [PATCH v2 06/26] armv7m: fix I and F flag handling List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Peter Crosthwaite , qemu-arm@nongnu.org, Michael Davidsaver Despite having the same notation, these bits have completely different meaning than -AR. Use armv7m_excp_running_prio() and the highest pending exception priority to determine if the pending exception can interrupt preempt. --- target-arm/cpu.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/target-arm/cpu.c b/target-arm/cpu.c index 5348028..6e3b251 100644 --- a/target-arm/cpu.c +++ b/target-arm/cpu.c @@ -305,19 +305,15 @@ static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { CPUClass *cc = CPU_GET_CLASS(cs); ARMCPU *cpu = ARM_CPU(cs); - CPUARMState *env = &cpu->env; bool ret = false; - - if (interrupt_request & CPU_INTERRUPT_FIQ - && !(env->daif & PSTATE_F)) { - cs->exception_index = EXCP_FIQ; - cc->do_interrupt(cs); - ret = true; - } + /* ARMv7-M interrupt masking works differently than -A or -R. + * There is no FIQ/IRQ distinction. + * Instead of masking interrupt sources, the I and F bits + * (along with basepri) mask certain exception priority levels. + */ if (interrupt_request & CPU_INTERRUPT_HARD - && !(env->daif & PSTATE_I) - ) { + && (armv7m_excp_running_prio(cpu) > cpu->env.v7m.pending_prio)) { cs->exception_index = EXCP_IRQ; cc->do_interrupt(cs); ret = true; -- 2.1.4