To enable kvm_irqchip_in_kernel option on LoongArch virt machine platform, property irqchip-in-kernel is added on irqchips including ExtIOI, IPI, PCH_PCI and PCH_MSI irqchip.
If property irqchip-in-kernel is set, there is special operations with irqchips in such fields: 1. During irqchip object realization, kvm_create_device() is used here to create irqchip in KVM kernel. 2. Add pre_save and post_load function, where register states can be get and set from KVM kernel. 3. Interrupt injection to kernel, IRQ line intterupt is injected with API kvm_set_irq() and MSI intterrupt is injected with API kvm_irqchip_send_msi(). Bibo Mao (15): hw/intc/loongarch_extioi: Add irqchip-in-kernel property hw/intc/loongarch_extioi: Add irqchip-in-kernel realize function hw/intc/loongarch_extioi: Add irqchip-in-kernel save/restore function hw/intc/loongarch_ipi: Add irqchip-in-kernel property hw/intc/loongarch_ipi: Add irqchip-in-kernel realize function hw/intc/loongson_ipi: Add load and save interface with ipi_common class hw/intc/loongarch_ipi: Add irqchip-in-kernel save/restore function hw/intc/loongarch_pch_msi: Add irqchip-in-kernel property hw/intc/loongarch_pch_msi: Inject MSI interrupt to kernel hw/intc/loongarch_pch: Add irqchip-in-kernel property hw/intc/loongarch_pch: Add irqchip-in-kernel realize function hw/intc/loongarch_pch: Add irqchip-in-kernel save/restore function hw/intc/loongarch_pch: Inject irq line interrupt to kernel target/loongarch: Report error with split kernel_irqchip option hw/loongarch/virt: Add kvm_irqchip_in_kernel support hw/intc/loongarch_extioi.c | 35 ++++++ hw/intc/loongarch_extioi_kvm.c | 146 +++++++++++++++++++++++++ hw/intc/loongarch_ipi.c | 41 +++++++ hw/intc/loongarch_ipi_kvm.c | 83 ++++++++++++++ hw/intc/loongarch_pch_msi.c | 17 +++ hw/intc/loongarch_pch_pic.c | 50 +++++++++ hw/intc/loongarch_pic_kvm.c | 96 ++++++++++++++++ hw/intc/loongson_ipi_common.c | 28 +++++ hw/intc/meson.build | 6 + hw/loongarch/virt.c | 15 +++ include/hw/intc/loongarch_extioi.h | 6 + include/hw/intc/loongarch_ipi.h | 6 + include/hw/intc/loongarch_pch_msi.h | 1 + include/hw/intc/loongarch_pch_pic.h | 6 + include/hw/intc/loongarch_pic_common.h | 1 + include/hw/intc/loongson_ipi_common.h | 2 + target/loongarch/cpu.h | 1 + target/loongarch/kvm/kvm.c | 23 +++- 18 files changed, 562 insertions(+), 1 deletion(-) create mode 100644 hw/intc/loongarch_extioi_kvm.c create mode 100644 hw/intc/loongarch_ipi_kvm.c create mode 100644 hw/intc/loongarch_pic_kvm.c -- 2.39.3