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.
qemu/hw/intc
Peter Maydell 335be5bc44 hw/intc/loongarch_extioi: Use set_bit32() and clear_bit32() for s->isr
In extioi_setirq() we try to operate on a bit array stored as an
array of uint32_t using the set_bit() and clear_bit() functions
by casting the pointer to 'unsigned long *'.
This has two problems:
 * the alignment of 'uint32_t' is less than that of 'unsigned long'
   so we pass an insufficiently aligned pointer, which is
   undefined behaviour
 * on big-endian hosts the 64-bit 'unsigned long' will have
   its two halves the wrong way around, and we will produce
   incorrect results

The undefined behaviour is shown by the clang undefined-behaviour
sanitizer when running the loongarch64-virt functional test:

/mnt/nvmedisk/linaro/qemu-from-laptop/qemu/include/qemu/bitops.h:41:5: runtime error: store to misaligned address 0x555559745d9c for type 'unsigned long', which requires 8 byte alignment
0x555559745d9c: note: pointer points here
  ff ff ff ff 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
              ^
    #0 0x555556fb81c4 in set_bit /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/include/qemu/bitops.h:41:9
    #1 0x555556fb81c4 in extioi_setirq /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/clang/../../hw/intc/loongarch_extioi.c:65:9
    #2 0x555556fb6e90 in pch_pic_irq_handler /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/clang/../../hw/intc/loongarch_pch_pic.c:75:5
    #3 0x555556710265 in serial_ioport_write /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/clang/../../hw/char/serial.c

Fix these problems by using set_bit32() and clear_bit32(),
which work with bit arrays stored as an array of uint32_t.

Cc: qemu-stable@nongnu.org
Fixes: cbff2db1e9 ("hw/intc: Add LoongArch extioi interrupt controller(EIOINTC)")
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Bibo Mao <maobibo@loongson.cn>
Message-id: 20241108135514.4006953-4-peter.maydell@linaro.org
2 weeks ago
..
Kconfig hw/intc/loongarch_ipi: Add loongarch IPI support 4 months ago
allwinner-a10-pic.c hw: Use device_class_set_legacy_reset() instead of opencoding 3 months ago
apic.c hw/intc/apic: fix memory leak 9 months ago
apic_common.c hw: Use device_class_set_legacy_reset() instead of opencoding 3 months ago
arm_gic.c hw/intc/arm_gic: fix spurious level triggered interrupts 3 months ago
arm_gic_common.c hw, target: Add ResetType argument to hold and exit phase methods 7 months ago
arm_gic_kvm.c target/arm: kvm: require KVM_CAP_DEVICE_CTRL 1 month ago
arm_gicv2m.c arm tcg cpus: Fix Lesser GPL version number 4 years ago
arm_gicv3.c hw/intc/arm_gicv3: Implement NMI interrupt priority 7 months ago
arm_gicv3_common.c hw, target: Add ResetType argument to hold and exit phase methods 7 months ago
arm_gicv3_cpuif.c hw/intc/arm_gicv3_cpuif: Add cast to match the documentation 2 months ago
arm_gicv3_cpuif_common.c hw/intc/arm_gicv3: Extract gicv3_set_gicv3state from arm_gicv3_cpuif.c 3 years ago
arm_gicv3_dist.c hw/intc/arm_gicv3: Implement GICD_INMIR 7 months ago
arm_gicv3_its.c hw, target: Add ResetType argument to hold and exit phase methods 7 months ago
arm_gicv3_its_common.c hw, target: Add ResetType argument to hold and exit phase methods 7 months ago
arm_gicv3_its_kvm.c hw, target: Add ResetType argument to hold and exit phase methods 7 months ago
arm_gicv3_kvm.c hw, target: Add ResetType argument to hold and exit phase methods 7 months ago
arm_gicv3_redist.c hw/intc/arm_gicv3: Implement NMI interrupt priority 7 months ago
armv7m_nvic.c hw: Use device_class_set_legacy_reset() instead of opencoding 3 months ago
aspeed_intc.c hw: Use device_class_set_legacy_reset() instead of opencoding 3 months ago
aspeed_vic.c hw: Use device_class_set_legacy_reset() instead of opencoding 3 months ago
bcm2835_ic.c hw: Use device_class_set_legacy_reset() instead of opencoding 3 months ago
bcm2836_control.c hw: Use device_class_set_legacy_reset() instead of opencoding 3 months ago
exynos4210_combiner.c hw: Use device_class_set_legacy_reset() instead of opencoding 3 months ago
exynos4210_gic.c Misc cleanups 3 years ago
gic_internal.h hw/intc/arm_gic: Fix deactivation of SPI lines 6 months ago
gicv3_internal.h hw/intc/arm_gicv3: Handle icv_nmiar1_read() for icc_nmiar1_read() 7 months ago
goldfish_pic.c hw: Use device_class_set_legacy_reset() instead of opencoding 3 months ago
grlib_irqmp.c hw: Use device_class_set_legacy_reset() instead of opencoding 3 months ago
heathrow_pic.c hw: Use device_class_set_legacy_reset() instead of opencoding 3 months ago
i8259.c hw: Use device_class_set_legacy_reset() instead of opencoding 3 months ago
i8259_common.c hw/intc: Avoid using Monitor in INTERRUPT_STATS_PROVIDER::print_info() 6 months ago
imx_avic.c hw: Use device_class_set_legacy_reset() instead of opencoding 3 months ago
imx_gpcv2.c hw: Use device_class_set_legacy_reset() instead of opencoding 3 months ago
intc.c
ioapic-stub.c i386: select correct components for no-board build 7 months ago
ioapic.c hw: Use device_class_set_legacy_reset() instead of opencoding 3 months ago
ioapic_common.c hw/intc: Avoid using Monitor in INTERRUPT_STATS_PROVIDER::print_info() 6 months ago
ioapic_internal.h hw: Move ioapic*.h to intc/ 2 years ago
kvm_irqcount.c hw/intc: Extract the IRQ counting functions into a separate file 2 years ago
loongarch_extioi.c hw/intc/loongarch_extioi: Use set_bit32() and clear_bit32() for s->isr 2 weeks ago
loongarch_ipi.c hw/intc/loongarch_ipi: Add loongarch IPI support 4 months ago
loongarch_pch_msi.c hw/intc/loongarch_pch_msi: add irq number property 2 years ago
loongarch_pch_pic.c hw: Use device_class_set_legacy_reset() instead of opencoding 3 months ago
loongson_ipi.c hw/intc/loongson_ipi: Remove unused headers 3 months ago
loongson_ipi_common.c hw/intc/loongson_ipi: Move common code to loongson_ipi_common.c 4 months ago
loongson_liointc.c hw/other: spelling fixes 1 year ago
m68k_irqc.c hw: Use device_class_set_legacy_reset() instead of opencoding 3 months ago
meson.build hw/intc: Remove TYPE_ETRAX_FS_PIC device 3 months ago
mips_gic.c accel/tcg: Replace CPUState.env_ptr with cpu_env() 1 year ago
omap_intc.c hw/intc/omap_intc: Remove now-unnecessary abstract base class 2 months ago
ompic.c hw/intc: Constify VMState 11 months ago
openpic.c hw/intc/openpic: Avoid taking address of out-of-bounds array index 2 weeks ago
openpic_kvm.c hw: Use device_class_set_legacy_reset() instead of opencoding 3 months ago
pl190.c hw: Use device_class_set_legacy_reset() instead of opencoding 3 months ago
pnv_xive.c hw/ppc: Avoid using Monitor in pnv_xive_pic_print_info() 6 months ago
pnv_xive2.c ppc/xive2: Dump the VP-group and crowd tables with 'info pic' 1 month ago
pnv_xive2_regs.h pnv/xive2: Enable VST NVG and NVC index compression 4 months ago
pnv_xive_regs.h ppc/xive: Handle END triggers between chips with MMIOs 1 year ago
ppc-uic.c hw: Use device_class_set_legacy_reset() instead of opencoding 3 months ago
realview_gic.c
riscv_aclint.c hw/intc: Constify VMState 11 months ago
riscv_aplic.c hw/intc/riscv_aplic: Check and update pending when write sourcecfg 1 month ago
riscv_imsic.c hw/intc: riscv-imsic: Fix interrupt state updates. 2 months ago
rx_icu.c hw/intc: Constify VMState 11 months ago
s390_flic.c hw: Use device_class_set_legacy_reset() instead of opencoding 3 months ago
s390_flic_kvm.c hw: Use device_class_set_legacy_reset() instead of opencoding 3 months ago
sh_intc.c hw/intc/sh_intc: Remove unneeded local variable initialisers 3 years ago
sifive_plic.c hw/intc: Don't clear pending bits on IRQ lowering 1 month ago
slavio_intctl.c hw: Use device_class_set_legacy_reset() instead of opencoding 3 months ago
spapr_xive.c hw/ppc: Avoid using Monitor in SpaprInterruptControllerClass::print_info() 6 months ago
spapr_xive_kvm.c ppc/xive: Fix ESB length overflow on 32-bit hosts 1 month ago
trace-events aspeed/intc: Add AST2700 support 6 months ago
trace.h trace: switch position of headers to what Meson requires 4 years ago
vgic_common.h
xics.c ppc/spapr: remove deprecated machine pseries-2.9 1 month ago
xics_kvm.c Remove qemu-common.h include from most units 3 years ago
xics_pnv.c non-virt: Fix Lesser GPL version number 4 years ago
xics_spapr.c hw/ppc: Avoid using Monitor in SpaprInterruptControllerClass::print_info() 6 months ago
xilinx_intc.c hw/intc/xilinx_intc: Use 'XpsIntc' typedef instead of 'struct xlx_pic' 2 years ago
xive.c pnv/xive2: TIMA CI ops using alternative offsets or byte lengths 1 month ago
xive2.c pnv/xive2: TIMA support for 8-byte OS context push for PHYP 1 month ago
xlnx-pmu-iomod-intc.c hw: Use device_class_set_legacy_reset() instead of opencoding 3 months ago
xlnx-zynqmp-ipi.c hw: Use device_class_set_legacy_reset() instead of opencoding 3 months ago