Commit f82aba047b for qemu.org

commit f82aba047b5ff2f060b0546ae5a4743c57e8e0c3
Author: Anton Johansson <anjo@rev.ng>
Date:   Fri Nov 13 00:20:31 2026 +0100

    target/hexagon: Forward return address to HLX load/store helpers

    Fixes: 2db29a3615a5ad2a3 ("target/hexagon: add HLX helper support")
    Signed-off-by: Anton Johansson <anjo@rev.ng>
    Reviewed-by: Marco Liebel <marco.liebel@oss.qualcomm.com>
    Reviewed-by: Brian Cain <brian.cain@oss.qualcomm.com>
    Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>

diff --git a/target/hexagon/hlx_helper.c b/target/hexagon/hlx_helper.c
index c063706cfa..bc638f6403 100644
--- a/target/hexagon/hlx_helper.c
+++ b/target/hexagon/hlx_helper.c
@@ -7,6 +7,7 @@
 #include "cpu.h"
 #include "accel/tcg/cpu-ldst.h"
 #include "exec/helper-proto.h"
+#include "hlx_helper.h"
 #include "hlx/hlx.h"
 #include "hw/hexagon/hexagon_hlx.h"
 #include "accel/tcg/probe.h"
@@ -15,40 +16,52 @@
 #define HLX_MEM_ALIGN_MASK (~(HLX_VEC_SIZE_BYTES - 1))

 /* Align down to 2KB. Above and below are unused in V85. */
-void HELPER(hlx_load_vec)(CPUHexagonState *env, void *dst_void,
-                          target_ulong ea, uint32_t above, uint32_t below)
+void hlx_load_vec_ra(CPUHexagonState *env, void *dst_void,
+                     target_ulong ea, uint32_t above, uint32_t below,
+                     uintptr_t ra)
 {
     HLXVector *dst = (HLXVector *)dst_void;
     target_ulong aligned_ea = ea & HLX_MEM_ALIGN_MASK;
-    uintptr_t raddr = GETPC();
     int mmu_idx = cpu_mmu_index(env_cpu(env), false);

     /* A 2KB-aligned access stays within one page. */
-    void *host = probe_read(env, aligned_ea, HLX_VEC_SIZE_BYTES, mmu_idx,
-                            raddr);
+    void *host = probe_read(env, aligned_ea, HLX_VEC_SIZE_BYTES, mmu_idx, ra);

     if (host) {
         memcpy(dst, host, HLX_VEC_SIZE_BYTES);
     } else {
         for (int i = 0; i < HLX_VEC_SIZE_BYTES; i += 8) {
-            uint64_t val = cpu_ldq_le_data_ra(env, aligned_ea + i, raddr);
+            uint64_t val = cpu_ldq_le_data_ra(env, aligned_ea + i, ra);
             memcpy(&dst->ub[i], &val, 8);
         }
     }
 }

-void HELPER(hlx_store_vec)(CPUHexagonState *env, target_ulong ea,
-                           void *src_void, uint32_t above, uint32_t below)
+void hlx_store_vec_ra(CPUHexagonState *env, target_ulong ea,
+                      void *src_void, uint32_t above, uint32_t below,
+                      uintptr_t ra)
 {
     target_ulong aligned_ea = ea & HLX_MEM_ALIGN_MASK;
     int mmu_idx = cpu_mmu_index(env_cpu(env), false);

-    probe_write(env, aligned_ea, HLX_VEC_SIZE_BYTES, mmu_idx, GETPC());
+    probe_write(env, aligned_ea, HLX_VEC_SIZE_BYTES, mmu_idx, ra);
     memcpy(&env->hlx_store_data, src_void, sizeof(HLXVector));
     env->hlx_store_va = aligned_ea;
     env->hlx_store_pending = true;
 }

+void HELPER(hlx_load_vec)(CPUHexagonState *env, void *dst_void,
+                          target_ulong ea, uint32_t above, uint32_t below)
+{
+    hlx_load_vec_ra(env, dst_void, ea, above, below, GETPC());
+}
+
+void HELPER(hlx_store_vec)(CPUHexagonState *env, target_ulong ea,
+                           void *src_void, uint32_t above, uint32_t below)
+{
+    hlx_store_vec_ra(env, ea, src_void, above, below, GETPC());
+}
+
 void HELPER(hlx_commit_store)(CPUHexagonState *env)
 {
     target_ulong va = env->hlx_store_va;
diff --git a/target/hexagon/hlx_helper.h b/target/hexagon/hlx_helper.h
new file mode 100644
index 0000000000..ab36cc1049
--- /dev/null
+++ b/target/hexagon/hlx_helper.h
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef HEXAGON_HLX_HELPER_H
+#define HEXAGON_HLX_HELPER_H
+
+#include "cpu.h"
+
+void hlx_load_vec_ra(CPUHexagonState *env, void *dst_void,
+                     target_ulong ea, uint32_t above, uint32_t below,
+                     uintptr_t ra);
+
+void hlx_store_vec_ra(CPUHexagonState *env, target_ulong ea,
+                      void *src_void, uint32_t above, uint32_t below,
+                      uintptr_t ra);
+
+#endif
diff --git a/target/hexagon/macros.h b/target/hexagon/macros.h
index 9187b02e6c..7a93a3441b 100644
--- a/target/hexagon/macros.h
+++ b/target/hexagon/macros.h
@@ -22,6 +22,7 @@
 #include "hex_regs.h"
 #include "reg_fields.h"
 #include "accel/tcg/getpc.h"
+#include "hlx_helper.h"

 #define GET_FIELD(FIELD, REGIN) \
     fEXTRACTU_BITS(REGIN, reg_field_info[FIELD].width, \
@@ -732,8 +733,10 @@ static inline TCGv gen_read_ireg(TCGv result, TCGv val, int shift)
                             EA, tcg_constant_i32(ABOVE), \
                             tcg_constant_i32(BELOW))
 #else
-#define fLOADMML(EA, DST, ABOVE, BELOW) \
-    do { HELPER(hlx_load_vec)(env, &(DST), (EA), (ABOVE), (BELOW)); } while (0)
+#define fLOADMML(EA, DST, ABOVE, BELOW)                                \
+    do {                                                               \
+        hlx_load_vec_ra(env, &(DST), (EA), (ABOVE), (BELOW), GETPC()); \
+    } while (0)
 #endif

 /* The helper logs the store for packet commit. */
@@ -742,8 +745,10 @@ static inline TCGv gen_read_ireg(TCGv result, TCGv val, int shift)
     gen_helper_hlx_store_vec(tcg_env, EA, tcg_constant_ptr((intptr_t)&(SRC)), \
                              tcg_constant_i32(ABOVE), tcg_constant_i32(BELOW))
 #else
-#define fSTOREMML(EA, SRC, ABOVE, BELOW) \
-    do { HELPER(hlx_store_vec)(env, (EA), &(SRC), (ABOVE), (BELOW)); } while (0)
+#define fSTOREMML(EA, SRC, ABOVE, BELOW)                                \
+    do {                                                                \
+        hlx_store_vec_ra(env, (EA), &(SRC), (ABOVE), (BELOW), GETPC()); \
+    } while (0)
 #endif

 /* Helpers receive .new registers in future_LRegs. */