All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Yoshinori Sato" <yoshinori.sato@nifty.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	qemu-stable@nongnu.org, "Guenter Roeck" <linux@roeck-us.net>
Subject: [PATCH 1/3] target/sh4: Re-allow unaligned access on system emulation
Date: Wed, 13 May 2026 08:54:35 +0200	[thread overview]
Message-ID: <20260513065438.8680-2-philmd@linaro.org> (raw)
In-Reply-To: <20260513065438.8680-1-philmd@linaro.org>

The change 0 -> MO_ALIGN in commit eb978e50e42 ("target/sh4: Use
MO_ALIGN for system UNALIGN()") would have been correct if it was
merged before commit 1fceff9c3ca ("tcg: Remove TARGET_ALIGNED_ONLY")
which defined MO_UNALN -> 0. What we really want here now is
MO_UNALN (MO_ALIGN is dealt with in commit 03a0d87e8dd "target/sh4:
Use MO_ALIGN where required").

Use the correct definition, otherwise we get when booting Linux:

  ok 14 bitfields
      KTAP version 1
      # Subtest: blackholedev
      # module: blackhole_dev_kunit
      1..1
  delay-slot-insn faulting in handle_unaligned_delayslot: 0000 [#1]
  Modules linked in:
  CPU: 0 UID: 0 PID: 298 Comm: kunit_try_catch Tainted: G                 N
  6.17.0-12907-g8765f467912f #1 NONE
  Tainted: [N]=TEST
  PC is at test_blackholedev+0xc6/0x1c8
  PR is at test_blackholedev+0xca/0x1c8
  PC  : 8c228d16 SP  : 8d40bed0 SR  : 40008001 TEA : 8cce4026
  R0  : 00000000 R1  : 00000000 R2  : 000000d2 R3  : 8cc77b80
  R4  : 8cc77b40 R5  : 0000000e R6  : 8c228cea R7  : 8cce400e
  R8  : 8cc77b40 R9  : 8cc77bbc R10 : 8cc77bbe R11 : 8c4b46b0
  R12 : 8c78310c R13 : 8cc29cf4 R14 : 8c6e3a88
  MACH: 0000d80d MACL: e554cb0f GBR : 00000000 PR  : 8c228d1a
  Call trace:
   [<8c05b378>] pick_next_task_fair+0x94/0x164
   [<8c5c2bce>] __schedule+0x306/0x6ec
   [<8c21fa68>] kunit_try_run_case+0x58/0x174
  ...

Cc: qemu-stable@nongnu.org
Fixes: eb978e50e42 ("target/sh4: Use MO_ALIGN for system UNALIGN()")
Reported-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/sh4/translate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/sh4/translate.c b/target/sh4/translate.c
index 5adf650744c..3ddd4f612e4 100644
--- a/target/sh4/translate.c
+++ b/target/sh4/translate.c
@@ -54,7 +54,7 @@ typedef struct DisasContext {
 #define UNALIGN(C)   (ctx->tbflags & TB_FLAG_UNALIGN ? MO_UNALN : MO_ALIGN)
 #else
 #define IS_USER(ctx) (!(ctx->tbflags & (1u << SR_MD)))
-#define UNALIGN(C)   MO_ALIGN
+#define UNALIGN(C)   MO_UNALN
 #endif
 
 /* Target-specific values for ctx->base.is_jmp.  */
-- 
2.53.0



  reply	other threads:[~2026-05-13  6:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-13  6:54 [PATCH 0/3] target/sh4: Re-allow unaligned access on system emulation Philippe Mathieu-Daudé
2026-05-13  6:54 ` Philippe Mathieu-Daudé [this message]
2026-05-13 18:24   ` [PATCH 1/3] " Richard Henderson
2026-05-13 18:34     ` Guenter Roeck
2026-05-14  3:11       ` yoshinori.sato
2026-05-13  6:54 ` [PATCH 2/3] target/sh4: Hold alignment as DisasContext::mo_align Philippe Mathieu-Daudé
2026-05-13  6:54 ` [PATCH 3/3] target/sh4: Inline UNALIGN() macro Philippe Mathieu-Daudé

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=20260513065438.8680-2-philmd@linaro.org \
    --to=philmd@linaro.org \
    --cc=linux@roeck-us.net \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@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.