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 1/6] sim: Allow an overdue event to be descheduled
Date: Fri, 21 Aug 2026 05:22:59 +0200 [thread overview]
Message-ID: <20260821032304.293603-2-sebastian.huber@embedded-brains.de> (raw)
In-Reply-To: <20260821032304.293603-1-sebastian.huber@embedded-brains.de>
sim_events_deschedule() asserted that a non-empty event queue implies a
non-negative time from event. That is not an invariant.
sim_events_slip() decrements the time from event unconditionally, so the
time can pass an event which is still queued. update_time_from_event()
then computes a negative time from event for the head of the queue,
which is overdue rather than pending. The next tick raises the pending
work flag and sim_events_process() consumes it, so nothing is lost.
An event handler which deschedules another overdue event triggers the
assertion. The MIPS jmr3904 board reaches this with two timers running:
they queue events for the same time, a branch delay slot slips the time
past both, and the handler of the first deschedules the second.
Assert only the direction which holds: an empty queue gives a negative
time from event.
Approved-By: Andrew Burgess <aburgess@redhat.com>
---
sim/common/sim-events.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/sim/common/sim-events.c b/sim/common/sim-events.c
index f87f133efc3..e832992c266 100644
--- a/sim/common/sim-events.c
+++ b/sim/common/sim-events.c
@@ -852,7 +852,11 @@ sim_events_deschedule (SIM_DESC sd,
(dead->trace != NULL) ? dead->trace : ""));
sim_events_free (sd, dead);
update_time_from_event (sd);
- SIM_ASSERT ((events->time_from_event >= 0) == (events->queue != NULL));
+ /* sim_events_slip() advances the time past an event
+ which is still queued. The head of the queue is then
+ overdue rather than pending. */
+ SIM_ASSERT (events->queue != NULL
+ || events->time_from_event < 0);
return;
}
}
--
2.51.0
next prev parent reply other threads:[~2026-08-21 3:24 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 ` Sebastian Huber [this message]
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 ` [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-2-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