]> www.infradead.org Git - users/dwmw2/qemu.git/commit
hw/arm_sysctl: fix extracting 31th bit of val
authorAnastasia Belova <abelova@astralinux.ru>
Mon, 13 Jan 2025 12:35:32 +0000 (12:35 +0000)
committerPeter Maydell <peter.maydell@linaro.org>
Mon, 13 Jan 2025 12:35:32 +0000 (12:35 +0000)
commit906853e1427a1ff89c64c0ebb6faa9c68f0a5d74
tree0cd7c3d2cc403a96a069247458ba6812db879ff1
parent3214bec13d8d4c40f707d21d8350d04e4123ae97
hw/arm_sysctl: fix extracting 31th bit of val

1 << 31 is casted to uint64_t while bitwise and with val.
So this value may become 0xffffffff80000000 but only
31th "start" bit is required.

This is not possible in practice because the MemoryRegionOps
uses the default max access size of 4 bytes and so none
of the upper bytes of val will be set, but the bitfield
extract API is clearer anyway.

Use the bitfield extract() API instead.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Anastasia Belova <abelova@astralinux.ru>
Message-id: 20241220125429.7552-1-abelova@astralinux.ru
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
[PMM: add clarification to commit message]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
hw/misc/arm_sysctl.c