Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
accel/tcg: Fix undefined shift in store_whole_le16
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>
  • Loading branch information
rth7680 committed Jun 6, 2023
1 parent 80bdd58 commit c0dde5f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion accel/tcg/ldst_atomicity.c.inc
Expand Up @@ -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);
}

Expand Down

0 comments on commit c0dde5f

Please sign in to comment.