Skip to contentSkip to conversation

target/arm: Fix vd == vm overlap in sve_ldff1_z

PATCH Applied Richard Henderson 2 participants 3 messages May 4, 2023 – May 15, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/arm: Fix vd == vm overlap in sve_ldff1_z

If vd == vm, copy vm to scratch, so that we can pre-zero the output and still access the gather indicies.

Cc: [email protected]
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1612

---
 target/arm/tcg/sve_helper.c | 6 ++++++
 1 file changed, 6 insertions(+)
target/arm/tcg/sve_helper.c +6 -0
index ccf5e5beca..0097522470 100644
@@ -6727,6 +6727,7 @@ void sve_ldff1_z(CPUARMState *env, void *vd, uint64_t *vg, void *vm,
     intptr_t reg_off;
     SVEHostPage info;
     target_ulong addr, in_page;
+    ARMVectorReg scratch;
 
     /* Skip to the first true predicate.  */
     reg_off = find_next_active(vg, 0, reg_max, esz);
@@ -6736,6 +6737,11 @@ void sve_ldff1_z(CPUARMState *env, void *vd, uint64_t *vg, void *vm,
         return;
     }
 
+    /* Protect against overlap between vd and vm. */
+    if (unlikely(vd == vm)) {
+        vm = memcpy(&scratch, vm, reg_max);
+    }
+
     /*
      * Probe the first element, allowing faults.
      */
Signature · 1 line
2.34.1
#1 lore raw

Ping.

r~

Quoted 34 lines · Richard Henderson

If vd == vm, copy vm to scratch, so that we can pre-zero the output and still access the gather indicies.

Cc: [email protected]
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1612

---
  target/arm/tcg/sve_helper.c | 6 ++++++
  1 file changed, 6 insertions(+)
target/arm/tcg/sve_helper.c +6 -0
index ccf5e5beca..0097522470 100644
@@ -6727,6 +6727,7 @@ void sve_ldff1_z(CPUARMState *env, void *vd, uint64_t *vg, void *vm,
      intptr_t reg_off;
      SVEHostPage info;
      target_ulong addr, in_page;
+    ARMVectorReg scratch;
 
      /* Skip to the first true predicate.  */
      reg_off = find_next_active(vg, 0, reg_max, esz);
@@ -6736,6 +6737,11 @@ void sve_ldff1_z(CPUARMState *env, void *vd, uint64_t *vg, void *vm,
          return;
      }
 
+    /* Protect against overlap between vd and vm. */
+    if (unlikely(vd == vm)) {
+        vm = memcpy(&scratch, vm, reg_max);
+    }
+
      /*
       * Probe the first element, allowing faults.
       */