aboutsummaryrefslogtreecommitdiff
path: root/tests/qtest
diff options
context:
space:
mode:
authorThomas Huth <thuth@redhat.com>2025-08-01 08:01:52 +0200
committerSong Gao <gaosong@loongson.cn>2025-08-28 20:06:27 +0800
commit86bca40402316891b8b9a920c2e3bf8cf37ba9a4 (patch)
treeec08d87899571cadbc02ae64c313d4faedf87578 /tests/qtest
parent96e7448c1f820c56caea8447c01f5227b0c95c79 (diff)
downloadqemu-86bca40402316891b8b9a920c2e3bf8cf37ba9a4.zip
qemu-86bca40402316891b8b9a920c2e3bf8cf37ba9a4.tar.gz
qemu-86bca40402316891b8b9a920c2e3bf8cf37ba9a4.tar.bz2
hw/intc/loongarch_pch_pic: Fix ubsan warning and endianness issue
When booting the Linux kernel from tests/functional/test_loongarch64_virt.py with a QEMU that has been compiled with --enable-ubsan, there is a warning like this: .../hw/intc/loongarch_pch_pic.c:171:46: runtime error: index 512 out of bounds for type 'uint8_t[64]' (aka 'unsigned char[64]') SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior .../hw/intc/loongarch_pch_pic.c:171:46 .../hw/intc/loongarch_pch_pic.c:175:45: runtime error: index 256 out of bounds for type 'uint8_t[64]' (aka 'unsigned char[64]') SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior .../hw/intc/loongarch_pch_pic.c:175:45 It happens because "addr" is added first before substracting the base (PCH_PIC_HTMSI_VEC or PCH_PIC_ROUTE_ENTRY). Additionally, this code looks like it is not endianness safe, since it uses a 64-bit pointer to write values into an array of 8-bit values. Thus rework the code to use the stq_le_p / ldq_le_p helpers here and make sure that we do not create pointers with undefined behavior by accident. Signed-off-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Bibo Mao <maobibo@loongson.cn> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Tested-by: Song Gao <gaosong@loongson.cn> Signed-off-by: Song Gao <gaosong@loongson.cn>
Diffstat (limited to 'tests/qtest')
0 files changed, 0 insertions, 0 deletions