@samitouri / QOSamiQemu / commits / 67db8109f0

hw/intc: riscv_imsic: Skip reset for KVM irqchip

The emulated IMSIC state arrays are only allocated when QEMU handles the interrupt controller state itself. With KVM AIA/APLIC-IMSIC, the interrupt controller state is owned by the KVM in-kernel irqchip, so these emulated state arrays are not allocated. The IMSIC reset handler still clears those arrays unconditionally. This makes qemu_system_reset(), which runs during machine creation, dereference NULL pointers with -machine virt,aia=aplic-imsic and KVM. Skip the emulated IMSIC reset path when the interrupt controller is handled by KVM. The emulated path is unchanged for TCG and for configurations that use QEMU emulation. Fixes: 766391483b ("hw/intc: riscv_imsic: Add reset API to IMSIC") Reviewed-by: Nutty Liu <nutty.liu@hotmail.com> Signed-off-by: Qingwei Hu <qingwei.hu@bytedance.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-ID: <20260615131925.3019370-3-qingwei.hu@bytedance.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>

Qingwei Hu committed Jun 15, 2026 at 21:19 UTC 67db8109f013b78e7ad074296e3efd19aaa21eb5
1 file changed +4
hw/intc/riscv_imsic.c
+4
@@ -347,6 +347,10 @@ static void riscv_imsic_reset_enter(Object *obj, ResetType type)
347 RISCVIMSICState *imsic = RISCV_IMSIC(obj);
348 int i;
349
350 + if (kvm_irqchip_in_kernel()) {
351 + return;
352 + }
353 +
354 memset(imsic->eidelivery, 0, sizeof(uint32_t) * imsic->num_pages);
355 memset(imsic->eithreshold, 0, sizeof(uint32_t) * imsic->num_pages);
356