From: Qingwei Hu <[email protected]>
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 <[email protected]>
Signed-off-by: Qingwei Hu <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
---
hw/intc/riscv_imsic.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/hw/intc/riscv_imsic.c b/hw/intc/riscv_imsic.c
index 1c86ecdb2c..7e5b5349ba 100644
--- a/hw/intc/riscv_imsic.c
+++ b/hw/intc/riscv_imsic.c
@@ -347,6 +347,10 @@ static void riscv_imsic_reset_enter(Object *obj, ResetType
type)
RISCVIMSICState *imsic = RISCV_IMSIC(obj);
int i;
+ if (kvm_irqchip_in_kernel()) {
+ return;
+ }
+
memset(imsic->eidelivery, 0, sizeof(uint32_t) * imsic->num_pages);
memset(imsic->eithreshold, 0, sizeof(uint32_t) * imsic->num_pages);
--
2.54.0