]> git.ipfire.org Git - thirdparty/qemu.git/commit
bitops.h: Define bit operations on 'uint32_t' arrays
authorPeter Maydell <peter.maydell@linaro.org>
Tue, 19 Nov 2024 13:02:06 +0000 (13:02 +0000)
committerMichael Tokarev <mjt@tls.msk.ru>
Thu, 21 Nov 2024 06:16:55 +0000 (09:16 +0300)
commit4de86d2b3073f33c535a91fe6ab3de5f12abc407
treec03592ce3baf624c6dd0c152b99ce7089625060f
parentfc4ca539d06f07848c2d31d4295045a291ae4c0e
bitops.h: Define bit operations on 'uint32_t' arrays

Currently bitops.h defines a set of operations that work on
arbitrary-length bit arrays.  However (largely because they
originally came from the Linux kernel) the bit array storage is an
array of 'unsigned long'.  This is OK for the kernel and even for
parts of QEMU where we don't really care about the underlying storage
format, but it is not good for devices, where we often want to expose
the storage to the guest and so need a type that is not
variably-sized between host OSes.

We already have a workaround for this in the GICv3 model:
arm_gicv3_common.h defines equivalents of the bit operations that
work on uint32_t.  It turns out that we should also be using
something similar in hw/intc/loongarch_extioi.c, which currently
casts a pointer to a uint32_t array to 'unsigned long *' in
extio_setirq(), which is both undefined behaviour and not correct on
a big-endian host.

Define equivalents of the set_bit() function family which work
with a uint32_t array.

(Cc stable because we're about to provide a bugfix to
loongarch_extioi which will depend on this commit.)

Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-id: 20241108135514.4006953-2-peter.maydell@linaro.org
(cherry picked from commit 3d7680fb18c7b17701730589d241a32e85f763a3)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
include/qemu/bitmap.h
include/qemu/bitops.h