On 10/7/26 01:34, Brian Cain wrote:
hexagon-softmmu had no enforcement of alignment for scalar loads and
stores: the MO_ALIGN flag added by the previous two commits triggers
TLB_INVALID_MASK/alignment faults in cputlb.c, but Hexagon's
TCGCPUOps did not implement do_unaligned_access, so the fault was
never delivered to the guest.

Add hexagon_cpu_do_unaligned_access(), which raises
HEX_CAUSE_MISALIGNED_LOAD/_STORE via the existing HEX_EVENT_PRECISE
path, mirroring raise_tlbmiss_exception()/raise_perm_exception().

Also add a linux-user cpu_loop handler for these two cause codes for
consistency with hexswi.c's sysemu handling, even though linux-user's
own alignment check in accel/tcg/user-exec.c currently raises SIGBUS
before Hexagon's cause-code machinery is reached.

Signed-off-by: Brian Cain <[email protected]>
---
  linux-user/hexagon/cpu_loop.c |  5 +++++
  target/hexagon/cpu.c          | 25 +++++++++++++++++++++++++
  2 files changed, 30 insertions(+)

diff --git a/linux-user/hexagon/cpu_loop.c b/linux-user/hexagon/cpu_loop.c
index 0958c51fbb3..d7f73439dbc 100644
--- a/linux-user/hexagon/cpu_loop.c
+++ b/linux-user/hexagon/cpu_loop.c
@@ -76,6 +76,11 @@ void cpu_loop(CPUHexagonState *env)
              force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPC,
                      env->gpr[HEX_REG_PC]);
              break;
+            case HEX_CAUSE_MISALIGNED_LOAD:
+            case HEX_CAUSE_MISALIGNED_STORE:
+            force_sig_fault(TARGET_SIGBUS, TARGET_BUS_ADRALN,
+                    env->gpr[HEX_REG_PC]);
+            break;
              default:
                  EXCP_DUMP(env, "\nqemu: unhandled CPU precise exception "
                      "cause code 0x%x - aborting\n",

It would be clearer to have this hunk in a preliminary patch
(more even since the $subject is about sysemu).

Reply via email to