From: Sebastian Huber <sebastian.huber@embedded-brains.de>
To: gdb-patches@sourceware.org
Cc: "Maciej W . Rozycki" <macro@orcam.me.uk>,
Andrew Burgess <aburgess@redhat.com>
Subject: [PATCH v2 4/6] sim/mips: Check all interrupt enable conditions
Date: Fri, 21 Aug 2026 05:23:02 +0200 [thread overview]
Message-ID: <20260821032304.293603-5-sebastian.huber@embedded-brains.de> (raw)
In-Reply-To: <20260821032304.293603-1-sebastian.huber@embedded-brains.de>
interrupt_event() tested Status.IE alone. On a target with an
exception level it delivered an interrupt while Status.EXL was set.
The simulator entered the exception handler again through the vector
and left EPC at the address of the older exception. The handler lost
its resume point. The test also let an interrupt through in debug
mode.
Collect the conditions which enable an interrupt in
interrupts_enabled(). Use this function for the delivery.
---
sim/mips/interp.c | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/sim/mips/interp.c b/sim/mips/interp.c
index 5dbd1482b99..dc918bb9281 100644
--- a/sim/mips/interp.c
+++ b/sim/mips/interp.c
@@ -295,12 +295,38 @@ static const OPTION mips_options[] =
int interrupt_pending;
+/* The interrupts are enabled while the Status register enables them and the
+ processor is at no exception level, at no error level and not in debug
+ mode:
+
+ Status.IE = 1, Status.EXL = 0, Status.ERL = 0, Debug.DM = 0
+
+ MIPS Architecture For Programmers Volume III: The MIPS Privileged Resource
+ Architecture, the Interrupts chapter. The R3000 generation, which the
+ R3900 belongs to, has no exception level and no error level. It disables
+ the interrupts through the interrupt enable stack of its Status register,
+ so only the current enable takes part. See the IDT R30xx Family Software
+ Reference Manual, the Status register of the CPU control chapter. */
+static int
+interrupts_enabled (sim_cpu *cpu)
+{
+ if ((SR & status_IE) == 0)
+ return 0;
+
+#ifndef SUBTARGET_R3900
+ if ((SR & (status_EXL | status_ERL)) != 0)
+ return 0;
+#endif
+
+ return (Debug & Debug_DM) == 0;
+}
+
void
interrupt_event (SIM_DESC sd, void *data)
{
sim_cpu *cpu = STATE_CPU (sd, 0); /* FIXME */
address_word cia = CPU_PC_GET (cpu);
- if (SR & status_IE)
+ if (interrupts_enabled (cpu))
{
interrupt_pending = 0;
SignalExceptionInterrupt (1); /* interrupt "1" */
--
2.51.0
next prev parent reply other threads:[~2026-08-21 3:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-21 3:22 [PATCH v2 0/6] sim: Fix MIPS livelocks and add software interrupts Sebastian Huber
2026-08-21 3:22 ` [PATCH v2 1/6] sim: Allow an overdue event to be descheduled Sebastian Huber
2026-08-21 3:23 ` [PATCH v2 2/6] sim/mips: Do not abort on a HI/LO hazard Sebastian Huber
2026-08-21 3:23 ` [PATCH v2 3/6] sim/mips: Deliver the reserved instruction exception Sebastian Huber
2026-08-21 3:23 ` Sebastian Huber [this message]
2026-08-21 3:23 ` [PATCH v2 5/6] sim/mips: Keep the pending interrupts in Cause Sebastian Huber
2026-08-21 3:23 ` [PATCH v2 6/6] sim/mips: Recognise a software interrupt request Sebastian Huber
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260821032304.293603-5-sebastian.huber@embedded-brains.de \
--to=sebastian.huber@embedded-brains.de \
--cc=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=macro@orcam.me.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox