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 5/6] sim/mips: Keep the pending interrupts in Cause
Date: Fri, 21 Aug 2026 05:23:03 +0200 [thread overview]
Message-ID: <20260821032304.293603-6-sebastian.huber@embedded-brains.de> (raw)
In-Reply-To: <20260821032304.293603-1-sebastian.huber@embedded-brains.de>
signal_exception() assigned the whole Cause register. It discarded
the interrupt pending field, so the handler of an interrupt read
Cause.IP as zero. The handler could not tell which interrupt the
processor delivered. The R3900 path keeps the field already.
Keep the interrupt pending field on the other targets as well. Add
cause_IPALL_mask for the complete field, because cause_IP_mask covers
only the six hardware interrupts.
---
sim/mips/interp.c | 4 ++--
sim/mips/sim-main.h | 4 ++++
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/sim/mips/interp.c b/sim/mips/interp.c
index dc918bb9281..8118b290a17 100644
--- a/sim/mips/interp.c
+++ b/sim/mips/interp.c
@@ -1962,7 +1962,7 @@ signal_exception (SIM_DESC sd,
/* See figure 5-17 for an outline of the code below */
if (! (SR & status_EXL))
{
- CAUSE = (exception << 2);
+ CAUSE = (CAUSE & cause_IPALL_mask) | (exception << 2);
if (STATE & simDELAYSLOT)
{
STATE &= ~simDELAYSLOT;
@@ -1976,7 +1976,7 @@ signal_exception (SIM_DESC sd,
}
else
{
- CAUSE = (exception << 2);
+ CAUSE = (CAUSE & cause_IPALL_mask) | (exception << 2);
/* vector = 0x180; */
}
SR |= status_EXL;
diff --git a/sim/mips/sim-main.h b/sim/mips/sim-main.h
index b6cb4e12258..28a4221dfd5 100644
--- a/sim/mips/sim-main.h
+++ b/sim/mips/sim-main.h
@@ -557,6 +557,10 @@ struct mips_sim_state {
#define cause_SW1 (1 << 9) /* Software interrupt 1 */
#define cause_IP_mask (0x3f) /* Interrupt pending field */
#define cause_IP_shift (10)
+/* The complete interrupt pending field, IP7:IP0. Its bits meet the
+ Status.IM bits. */
+#define cause_IPALL_mask ((cause_IP_mask << cause_IP_shift) \
+ | cause_SW1 | cause_SW0)
#define cause_set_EXC(x) CAUSE = (CAUSE & ~cause_EXC_mask) | ((x << cause_EXC_shift) & cause_EXC_mask)
#define cause_set_EXC2(x) CAUSE = (CAUSE & ~cause_EXC2_mask) | ((x << cause_EXC2_shift) & cause_EXC2_mask)
--
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 ` [PATCH v2 4/6] sim/mips: Check all interrupt enable conditions Sebastian Huber
2026-08-21 3:23 ` Sebastian Huber [this message]
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-6-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