1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Richard Henderson <richard.henderson@linaro.org>
3 Date: Thu, 4 May 2023 11:42:32 +0100
4 Subject: [PATCH] target/arm: Fix vd == vm overlap in sve_ldff1_z
6 If vd == vm, copy vm to scratch, so that we can pre-zero
7 the output and still access the gather indicies.
9 Cc: qemu-stable@nongnu.org
10 Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1612
11 Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
12 (picked up from https://lists.nongnu.org/archive/html/qemu-devel/2023-05/msg00961.html)
13 Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
15 target/arm/tcg/sve_helper.c | 6 ++++++
16 1 file changed, 6 insertions(+)
18 diff --git a/target/arm/tcg/sve_helper.c b/target/arm/tcg/sve_helper.c
19 index ccf5e5beca..0097522470 100644
20 --- a/target/arm/tcg/sve_helper.c
21 +++ b/target/arm/tcg/sve_helper.c
22 @@ -6727,6 +6727,7 @@ void sve_ldff1_z(CPUARMState *env, void *vd, uint64_t *vg, void *vm,
25 target_ulong addr, in_page;
26 + ARMVectorReg scratch;
28 /* Skip to the first true predicate. */
29 reg_off = find_next_active(vg, 0, reg_max, esz);
30 @@ -6736,6 +6737,11 @@ void sve_ldff1_z(CPUARMState *env, void *vd, uint64_t *vg, void *vm,
34 + /* Protect against overlap between vd and vm. */
35 + if (unlikely(vd == vm)) {
36 + vm = memcpy(&scratch, vm, reg_max);
40 * Probe the first element, allowing faults.