mirror of https://gitlab.com/qemu-project/qemu
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
5311599cdc
In riscv_cpu_do_interrupt() we use the 'cause' value we got out of cs->exception as a shift value. However this value can be larger than 31, which means that "1 << cause" is undefined behaviour, because we do the shift on an 'int' type. This causes the undefined behaviour sanitizer to complain on one of the check-tcg tests: $ UBSAN_OPTIONS=print_stacktrace=1:abort_on_error=1:halt_on_error=1 ./build/clang/qemu-system-riscv64 -M virt -semihosting -display none -device loader,file=build/clang/tests/tcg/riscv64-softmmu/issue1060 ../../target/riscv/cpu_helper.c:1805:38: runtime error: shift exponent 63 is too large for 32-bit type 'int' #0 0x55f2dc026703 in riscv_cpu_do_interrupt /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/clang/../../target/riscv/cpu_helper.c:1805:38 #1 0x55f2dc3d170e in cpu_handle_exception /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/clang/../../accel/tcg/cpu-exec.c:752:9 In this case cause is RISCV_EXCP_SEMIHOST, which is 0x3f. Use 1ULL instead to ensure that the shift is in range. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Fixes: |
21 hours ago | |
---|---|---|
.. | ||
alpha | 4 weeks ago | |
arm | 1 week ago | |
avr | 2 months ago | |
hexagon | 2 months ago | |
hppa | 4 weeks ago | |
i386 | 6 days ago | |
loongarch | 4 weeks ago | |
m68k | 4 weeks ago | |
microblaze | 4 weeks ago | |
mips | 4 weeks ago | |
openrisc | 4 weeks ago | |
ppc | 1 week ago | |
riscv | 21 hours ago | |
rx | 4 weeks ago | |
s390x | 2 weeks ago | |
sh4 | 3 months ago | |
sparc | 4 weeks ago | |
tricore | 2 months ago | |
xtensa | 4 weeks ago | |
Kconfig | 3 months ago | |
meson.build | 3 months ago |