From: Mikulas Patocka <mpatocka@redhat.com>
To: Yoshinori Sato <yoshinori.sato@nifty.com>,
Richard Henderson <richard.henderson@linaro.org>
Cc: qemu-devel@nongnu.org
Subject: [PATCH] linux-user/sh4: Fix crashes on signal delivery in conditional delay slot
Date: Mon, 3 Aug 2026 21:38:32 +0200 (CEST) [thread overview]
Message-ID: <99f60fb8-e9db-e775-38db-44df9514a4c7@redhat.com> (raw)
If we get a signal in the delay slot, we must roll-back the PC to the
jump instruction. This was already fixed by the commit 3b894b699c9a
("linux-user/sh4: Fix crashes on signal delivery"), however this fix
omits a test for TB_FLAG_DELAY_SLOT_COND. TB_FLAG_DELAY_SLOT_COND is set
by the conditional delayed branches bf/s and bt/s. Qemu did not roll-back
the PC in this case, resulting in incorrect program execution.
This patch fixes it.
Cc: qemu-stable@nongnu.org
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
---
linux-user/sh4/signal.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: qemu/linux-user/sh4/signal.c
===================================================================
--- qemu.orig/linux-user/sh4/signal.c 2026-08-02 18:02:30.000000000 +0200
+++ qemu/linux-user/sh4/signal.c 2026-08-02 18:03:09.000000000 +0200
@@ -109,7 +109,7 @@ static void unwind_gusa(CPUSH4State *reg
the SP, otherwise we would be pushing the signal context to
invalid memory. */
regs->gregs[15] = regs->gregs[1];
- } else if (regs->flags & TB_FLAG_DELAY_SLOT) {
+ } else if (regs->flags & (TB_FLAG_DELAY_SLOT | TB_FLAG_DELAY_SLOT_COND)) {
/* If we are in a delay slot, push the previous instruction. */
regs->pc -= 2;
}
next reply other threads:[~2026-08-03 19:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 19:38 Mikulas Patocka [this message]
2026-08-04 9:27 ` [PATCH] linux-user/sh4: Fix crashes on signal delivery in conditional delay slot yoshinori.sato
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=99f60fb8-e9db-e775-38db-44df9514a4c7@redhat.com \
--to=mpatocka@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=yoshinori.sato@nifty.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.