]> git.proxmox.com Git - mirror_qemu.git/commitdiff
accel/tcg: Fix undefined shift in store_whole_le16
authorRichard Henderson <richard.henderson@linaro.org>
Tue, 6 Jun 2023 17:16:29 +0000 (10:16 -0700)
committerRichard Henderson <richard.henderson@linaro.org>
Tue, 6 Jun 2023 19:11:02 +0000 (12:11 -0700)
The computation is documented as unused in this case,
but triggers an ubsan error:

../accel/tcg/ldst_atomicity.c.inc:837:33: runtime error: shift exponent -32 is negative
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../accel/tcg/ldst_atomicity.c.inc:837:33 in

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20230606171629.98157-1-richard.henderson@linaro.org>

accel/tcg/ldst_atomicity.c.inc

index 2514899408c6532294accc911ff64d0d329a071e..de70531a7a048257f1e46537b79a25670cc69f69 100644 (file)
@@ -833,7 +833,9 @@ static uint64_t store_whole_le16(void *pv, int size, Int128 val_le)
     }
     store_atom_insert_al16(pv - o, v, m);
 
-    /* Unused if sz <= 64. */
+    if (sz <= 64) {
+        return 0;
+    }
     return int128_gethi(val_le) >> (sz - 64);
 }