From: Andrew Burgess <aburgess@redhat.com>
To: Sebastian Huber <sebastian.huber@embedded-brains.de>,
gdb-patches@sourceware.org
Subject: Re: [PATCH 2/4] sim/mips: Do not abort on a HI/LO hazard
Date: Tue, 18 Aug 2026 11:04:00 +0100 [thread overview]
Message-ID: <87wltn219r.fsf@redhat.com> (raw)
In-Reply-To: <20260816234357.278358-3-sebastian.huber@embedded-brains.de>
Sebastian Huber <sebastian.huber@embedded-brains.de> writes:
> check_mf_hilo() calls sim_engine_abort() when a mfhi or mflo reads a
> value which the ISA leaves UNPREDICTABLE. The comment above the helper
> states the rule correctly: the result is UNPREDICTABLE, not an error.
> Reading an undefined value is not a fault, and the return value of the
> helper is discarded at both call sites, so the abort is its only effect.
>
> The abort halts the client and the run loop resumes it on the faulting
> instruction, which reads the same register again and aborts again. An
> operating system may save HI and LO on interrupt entry and restores them
'restores' -> 'restore' please.
> unchanged, so it reads them at an arbitrary instruction boundary where
> the last writer is whatever the interrupted program did. Every clock
> tick landing in multiply or divide heavy code then deadlocks it.
>
> Warn instead.
>
> Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
> ---
> sim/mips/mips.igen | 17 +++++++++++------
> 1 file changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/sim/mips/mips.igen b/sim/mips/mips.igen
> index 8203d19f8c4..fc2f81f85d0 100644
> --- a/sim/mips/mips.igen
> +++ b/sim/mips/mips.igen
> @@ -411,12 +411,17 @@
> && peer->mf.timestamp < peer->mt.timestamp))
> {
> /* The peer has been written to since the last OP yet we have
> - not */
> - sim_engine_abort (SD, CPU, CIA, "HILO: %s: MF at 0x%08lx following OP at 0x%08lx corrupted by MT at 0x%08lx\n",
> - itable[MY_INDEX].name,
> - (long) CIA,
> - (long) history->op.cia,
> - (long) peer->mt.cia);
> + not. The ISA makes the result of this MF UNPREDICTABLE, it does not
> + make it an error. An operating system may save HI and LO
> + unconditionally on interrupt entry and restores them unchanged, so it
Same here: 'restores' -> 'restore' please.
> + reads whatever the interrupted program left behind. Aborting the
> + simulation here deadlocks such a system, since the run loop resumes at
> + the faulting instruction and the MF is executed again. */
> + sim_io_eprintf (SD, "HILO: %s: MF at 0x%08lx following OP at 0x%08lx corrupted by MT at 0x%08lx\n",
> + itable[MY_INDEX].name,
> + (long) CIA,
> + (long) history->op.cia,
> + (long) peer->mt.cia);
This is fine, but is there not a risk that this is going to end up
spamming stderr (or whatever) with these warnings? Would it not be
worth adding some kind of counter:
{
static warning_count = 0;
if (warning_count < 10)
{
++warning_count;
sim_io_eprintf (SD, ".....");
if (warning_count == 10)
sim_io_eprintf (SD, "Future warnings about .... are now silenced\n");
}
}
But I'll leave this up to you, I'm happy with the change as is.
Approved-By: Andrew Burgess <aburgess@redhat.com>
Thanks,
Andrew
> ok = 0;
> }
> history->mf.timestamp = time;
> --
> 2.51.0
next prev parent reply other threads:[~2026-08-18 10:05 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-16 23:43 [PATCH 0/4] Fix some MIPS GDB simulator issues Sebastian Huber
2026-08-16 23:43 ` [PATCH 1/4] sim: Allow an overdue event to be descheduled Sebastian Huber
2026-08-18 9:59 ` Andrew Burgess
2026-08-16 23:43 ` [PATCH 2/4] sim/mips: Do not abort on a HI/LO hazard Sebastian Huber
2026-08-18 10:04 ` Andrew Burgess [this message]
2026-08-16 23:43 ` [PATCH 3/4] sim/mips: Deliver the reserved instruction exception Sebastian Huber
2026-08-18 10:18 ` Andrew Burgess
2026-08-16 23:43 ` [PATCH 4/4] sim/mips: Recognise a software interrupt request Sebastian Huber
2026-08-18 10:42 ` Andrew Burgess
2026-08-18 11:45 ` Sebastian Huber
2026-08-19 0:03 ` Maciej W. Rozycki
2026-08-19 0:27 ` Sebastian Huber
2026-08-19 13:17 ` Maciej W. Rozycki
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=87wltn219r.fsf@redhat.com \
--to=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=sebastian.huber@embedded-brains.de \
/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