]> 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:12:42 +0000 (09:12 +0300)
commit9b52d9bacce4b188af7b65f933ab2e3a0715986d
tree072d8a6e89115847548822c9454e5386d995595c
parent9b381a2a15a4f450e4979ef9afcb0cf27a3016af
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