On 12/18/25 01:31, Philippe Mathieu-Daudé wrote:
All the LD/ST[W,L,Q] variants use the same template, only
modifying the access size used. Unify as a single pair of
LD/ST methods taking a MemOp argument. Thus use the 'm'
suffix for MemOp.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
---
  system/memory_ldst.c.inc | 289 ++++++++-------------------------------
  1 file changed, 58 insertions(+), 231 deletions(-)

diff --git a/system/memory_ldst.c.inc b/system/memory_ldst.c.inc
index 823fc3a7561..e0c0c3f5dca 100644
--- a/system/memory_ldst.c.inc
+++ b/system/memory_ldst.c.inc
@@ -20,39 +20,43 @@
   */
/* warning: addr must be aligned */
-static inline uint32_t glue(address_space_ldl_internal, SUFFIX)(ARG1_DECL,
-    hwaddr addr, MemTxAttrs attrs, MemTxResult *result,
-    enum device_endian endian)
+static inline
+uint64_t glue(address_space_ldm_internal, SUFFIX)(ARG1_DECL, MemOp mop,
+                                                  hwaddr addr,
+                                                  MemTxAttrs attrs,
+                                                  MemTxResult *result,
+                                                  enum device_endian endian)
  {
+    const unsigned size = memop_size(mop);
      uint8_t *ptr;
      uint64_t val;
      MemoryRegion *mr;
-    hwaddr l = 4;
+    hwaddr l = size;
      hwaddr addr1;
      MemTxResult r;
      bool release_lock = false;
RCU_READ_LOCK();
      mr = TRANSLATE(addr, &addr1, &l, false, attrs);
-    if (l < 4 || !memory_access_is_direct(mr, false, attrs)) {
+    if (l < size || !memory_access_is_direct(mr, false, attrs)) {
          release_lock |= prepare_mmio_access(mr);
/* I/O case */
          r = memory_region_dispatch_read(mr, addr1, &val,
-                                        MO_32 | devend_memop(endian), attrs);
+                                        mop | devend_memop(endian), attrs);
      } else {
          /* RAM case */
-        fuzz_dma_read_cb(addr, 4, mr);
+        fuzz_dma_read_cb(addr, size, mr);
          ptr = qemu_map_ram_ptr(mr->ram_block, addr1);
          switch (endian) {
          case DEVICE_LITTLE_ENDIAN:
-            val = ldl_le_p(ptr);
+            val = ldn_le_p(ptr, size);
              break;
          case DEVICE_BIG_ENDIAN:
-            val = ldl_be_p(ptr);
+            val = ldn_be_p(ptr, size);
              break;
          default:
-            val = ldl_p(ptr);
+            val = ldn_p(ptr, size);
              break;
          }
          r = MEMTX_OK;
@@ -67,87 +71,30 @@ static inline uint32_t glue(address_space_ldl_internal, 
SUFFIX)(ARG1_DECL,
      return val;
  }
+/* warning: addr must be aligned */
+static inline uint32_t glue(address_space_ldl_internal, SUFFIX)(ARG1_DECL,
+    hwaddr addr, MemTxAttrs attrs, MemTxResult *result,
+    enum device_endian endian)
+{
+    return glue(address_space_ldm_internal, SUFFIX)(ARG1, MO_32, addr,
+                                                    attrs, result, endian);
+}
+
  /* warning: addr must be aligned */

Do we know why this warning is here?
Do we know why we aren't asserting alignment?

It makes me wonder if the ldn_*_p above shouldn't be qatomic_ld.
And more so for the stores.

But that's an existing problem, not new with the refactor, so
Reviewed-by: Richard Henderson <[email protected]>


r~

Reply via email to