AI Trajectory


Trajectory: (Expand/Collapse All)
Seq Timestamp Type Name Duration
0/0 2026/06/29 02:52 flow patch-triage
1m Args:
null

Results:
{
  "EnableConfigs": [
    "KVM"
  ],
  "FocusSymbols": [
    "kvm_vcpu_ioctl_interrupt",
    "kvm_eiointc_write",
    "kvm_pch_pic_write",
    "loongarch_ipi_writel",
    "kvm_emu_mmio_write",
    "kvm_dmsintc_set_attr",
    "kvm_eiointc_set_attr",
    "kvm_ipi_set_attr",
    "kvm_pch_pic_set_attr"
  ],
  "Reasoning": "The patch makes functional changes to LoongArch KVM interrupt handling. It modifies `kvm_vcpu_ioctl_interrupt` to return `-EINVAL` if an in-kernel irqchip is used, and updates internal callers to use `kvm_queue_irq` and `kvm_dequeue_irq` directly. It also replaces numerous `kvm_err` calls with `WARN_ONCE` across various KVM exit and interrupt controller handlers. These changes affect reachable core KVM logic and should be fuzzed.",
  "WorthFuzzing": true
}

1/1 2026/06/29 02:52 action read-patch-diff
0m Args:
null

Results:
{
  "PatchDiff": "commit f9387a2e57a70064e3441bbd6daec9807b7cd66f\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate:   Mon Jun 29 02:52:46 2026 +0000\n\n    syz-cluster: applied patch under review\n\ndiff --git a/arch/loongarch/kvm/exit.c b/arch/loongarch/kvm/exit.c\nindex 8572b63478bb98..4ad006e27a4d8d 100644\n--- a/arch/loongarch/kvm/exit.c\n+++ b/arch/loongarch/kvm/exit.c\n@@ -252,7 +252,7 @@ int kvm_complete_iocsr_read(struct kvm_vcpu *vcpu, struct kvm_run *run)\n \t\t*gpr = *(s64 *)run-\u003eiocsr_io.data;\n \t\tbreak;\n \tdefault:\n-\t\tkvm_err(\"Bad IOCSR length: %d, addr is 0x%lx\\n\",\n+\t\tWARN_ONCE(1, \"Bad IOCSR length: %d, addr is 0x%lx\\n\",\n \t\t\t\trun-\u003eiocsr_io.len, vcpu-\u003earch.badv);\n \t\ter = EMULATE_FAIL;\n \t\tbreak;\n@@ -326,7 +326,7 @@ static int kvm_trap_handle_gspr(struct kvm_vcpu *vcpu)\n \n \t/* Rollback PC only if emulation was unsuccessful */\n \tif (er == EMULATE_FAIL) {\n-\t\tkvm_err(\"[%#lx]%s: unsupported gspr instruction 0x%08x\\n\",\n+\t\tWARN_ONCE(1, \"[%#lx]%s: unsupported gspr instruction 0x%08x\\n\",\n \t\t\tcurr_pc, __func__, inst.word);\n \n \t\tkvm_arch_vcpu_dump_regs(vcpu);\n@@ -491,7 +491,7 @@ int kvm_emu_mmio_read(struct kvm_vcpu *vcpu, larch_inst inst)\n \t\treturn EMULATE_DO_MMIO;\n \t}\n \n-\tkvm_err(\"Read not supported Inst=0x%08x @%lx BadVaddr:%#lx\\n\",\n+\tWARN_ONCE(1, \"Read not supported Inst=0x%08x @%lx BadVaddr:%#lx\\n\",\n \t\t\tinst.word, vcpu-\u003earch.pc, vcpu-\u003earch.badv);\n \tkvm_arch_vcpu_dump_regs(vcpu);\n \tvcpu-\u003emmio_needed = 0;\n@@ -529,7 +529,7 @@ int kvm_complete_mmio_read(struct kvm_vcpu *vcpu, struct kvm_run *run)\n \t\t*gpr = *(s64 *)run-\u003emmio.data;\n \t\tbreak;\n \tdefault:\n-\t\tkvm_err(\"Bad MMIO length: %d, addr is 0x%lx\\n\",\n+\t\tWARN_ONCE(1, \"Bad MMIO length: %d, addr is 0x%lx\\n\",\n \t\t\t\trun-\u003emmio.len, vcpu-\u003earch.badv);\n \t\ter = EMULATE_FAIL;\n \t\tbreak;\n@@ -656,7 +656,7 @@ int kvm_emu_mmio_write(struct kvm_vcpu *vcpu, larch_inst inst)\n \t}\n \n \tvcpu-\u003earch.pc = curr_pc;\n-\tkvm_err(\"Write not supported Inst=0x%08x @%lx BadVaddr:%#lx\\n\",\n+\tWARN_ONCE(1, \"Write not supported Inst=0x%08x @%lx BadVaddr:%#lx\\n\",\n \t\t\tinst.word, vcpu-\u003earch.pc, vcpu-\u003earch.badv);\n \tkvm_arch_vcpu_dump_regs(vcpu);\n \t/* Rollback PC if emulation was unsuccessful */\n@@ -748,8 +748,7 @@ static int kvm_handle_fpu_disabled(struct kvm_vcpu *vcpu, int ecode)\n \t * treated as a reserved instruction!\n \t * If FPU already in use, we shouldn't get this at all.\n \t */\n-\tif (WARN_ON(vcpu-\u003earch.aux_inuse \u0026 KVM_LARCH_FPU)) {\n-\t\tkvm_err(\"%s internal error\\n\", __func__);\n+\tif (WARN_ON_ONCE(vcpu-\u003earch.aux_inuse \u0026 KVM_LARCH_FPU)) {\n \t\trun-\u003eexit_reason = KVM_EXIT_INTERNAL_ERROR;\n \t\treturn RESUME_HOST;\n \t}\n@@ -943,7 +942,7 @@ static int kvm_fault_ni(struct kvm_vcpu *vcpu, int ecode)\n \t/* Fetch the instruction */\n \tinst = vcpu-\u003earch.badi;\n \tbadv = vcpu-\u003earch.badv;\n-\tkvm_err(\"ECode: %d PC=%#lx Inst=0x%08x BadVaddr=%#lx ESTAT=%#lx\\n\",\n+\tWARN_ONCE(1, \"ECode: %d PC=%#lx Inst=0x%08x BadVaddr=%#lx ESTAT=%#lx\\n\",\n \t\t\tecode, vcpu-\u003earch.pc, inst, badv, read_gcsr_estat());\n \tkvm_arch_vcpu_dump_regs(vcpu);\n \tkvm_queue_exception(vcpu, EXCCODE_INE, 0);\ndiff --git a/arch/loongarch/kvm/intc/dmsintc.c b/arch/loongarch/kvm/intc/dmsintc.c\nindex de25735ce03946..ed85532247759e 100644\n--- a/arch/loongarch/kvm/intc/dmsintc.c\n+++ b/arch/loongarch/kvm/intc/dmsintc.c\n@@ -47,7 +47,6 @@ void dmsintc_inject_irq(struct kvm_vcpu *vcpu)\n int dmsintc_deliver_msi_to_vcpu(struct kvm *kvm,\n \t\t\t\tstruct kvm_vcpu *vcpu, u32 vector, int level)\n {\n-\tstruct kvm_interrupt vcpu_irq;\n \tstruct dmsintc_state *ds = \u0026vcpu-\u003earch.dmsintc_state;\n \n \tif (!level)\n@@ -57,9 +56,11 @@ int dmsintc_deliver_msi_to_vcpu(struct kvm *kvm,\n \tif (!ds)\n \t\treturn -ENODEV;\n \n-\tvcpu_irq.irq = INT_AVEC;\n+\tif (!kvm_guest_has_msgint(\u0026vcpu-\u003earch))\n+\t\treturn -EINVAL;\n+\n \tset_bit(vector, (unsigned long *)\u0026ds-\u003evector_map);\n-\tkvm_vcpu_ioctl_interrupt(vcpu, \u0026vcpu_irq);\n+\tkvm_queue_irq(vcpu, INT_AVEC);\n \tkvm_vcpu_kick(vcpu);\n \n \treturn 0;\n@@ -114,7 +115,7 @@ static int kvm_dmsintc_ctrl_access(struct kvm_device *dev,\n \t\t}\n \t\tbreak;\n \tdefault:\n-\t\tkvm_err(\"%s: unknown dmsintc register, addr = %d\\n\", __func__, addr);\n+\t\tWARN_ONCE(1, \"%s: unknown dmsintc register, addr = %d\\n\", __func__, addr);\n \t\treturn -ENXIO;\n \t}\n \n@@ -128,7 +129,7 @@ static int kvm_dmsintc_set_attr(struct kvm_device *dev,\n \tcase KVM_DEV_LOONGARCH_DMSINTC_GRP_CTRL:\n \t\treturn kvm_dmsintc_ctrl_access(dev, attr, true);\n \tdefault:\n-\t\tkvm_err(\"%s: unknown group (%d)\\n\", __func__, attr-\u003egroup);\n+\t\tWARN_ONCE(1, \"%s: unknown group (%d)\\n\", __func__, attr-\u003egroup);\n \t\treturn -EINVAL;\n \t}\n }\n@@ -139,13 +140,13 @@ static int kvm_dmsintc_create(struct kvm_device *dev, u32 type)\n \tstruct loongarch_dmsintc *s;\n \n \tif (!dev) {\n-\t\tkvm_err(\"%s: kvm_device ptr is invalid!\\n\", __func__);\n+\t\tWARN_ONCE(1, \"%s: kvm_device ptr is invalid!\\n\", __func__);\n \t\treturn -EINVAL;\n \t}\n \n \tkvm = dev-\u003ekvm;\n \tif (kvm-\u003earch.dmsintc) {\n-\t\tkvm_err(\"%s: LoongArch DMSINTC has already been created!\\n\", __func__);\n+\t\tWARN_ONCE(1, \"%s: LoongArch DMSINTC has already been created!\\n\", __func__);\n \t\treturn -EINVAL;\n \t}\n \ndiff --git a/arch/loongarch/kvm/intc/eiointc.c b/arch/loongarch/kvm/intc/eiointc.c\nindex 2b14485d14a708..681dfb548dbf88 100644\n--- a/arch/loongarch/kvm/intc/eiointc.c\n+++ b/arch/loongarch/kvm/intc/eiointc.c\n@@ -17,7 +17,8 @@ static void eiointc_set_sw_coreisr(struct loongarch_eiointc *s)\n \t\tif (!(s-\u003estatus \u0026 BIT(EIOINTC_ENABLE_INT_ENCODE))) {\n \t\t\tipnum = count_trailing_zeros(ipnum);\n \t\t\tipnum = ipnum \u003c 4 ? ipnum : 0;\n-\t\t}\n+\t\t} else if (ipnum \u003e= LOONGSON_IP_NUM)\n+\t\t\tipnum = 0;\n \n \t\tcpuid = ((u8 *)s-\u003ecoremap)[irq];\n \t\tvcpu = kvm_get_vcpu_by_cpuid(s-\u003ekvm, cpuid);\n@@ -36,18 +37,18 @@ static void eiointc_update_irq(struct loongarch_eiointc *s, int irq, int level)\n {\n \tint ipnum, cpu, found;\n \tstruct kvm_vcpu *vcpu;\n-\tstruct kvm_interrupt vcpu_irq;\n \n \tipnum = (s-\u003eipmap \u003e\u003e (irq / 32 * 8)) \u0026 0xff;\n \tif (!(s-\u003estatus \u0026 BIT(EIOINTC_ENABLE_INT_ENCODE))) {\n \t\tipnum = count_trailing_zeros(ipnum);\n \t\tipnum = ipnum \u003c 4 ? ipnum : 0;\n-\t}\n+\t} else if (ipnum \u003e= LOONGSON_IP_NUM)\n+\t\tipnum = 0;\n \n \tcpu = s-\u003esw_coremap[irq];\n \tvcpu = kvm_get_vcpu_by_id(s-\u003ekvm, cpu);\n \tif (unlikely(vcpu == NULL)) {\n-\t\tkvm_err(\"%s: invalid target cpu: %d\\n\", __func__, cpu);\n+\t\tWARN_ONCE(1, \"%s: invalid target cpu: %d\\n\", __func__, cpu);\n \t\treturn;\n \t}\n \n@@ -67,8 +68,11 @@ static void eiointc_update_irq(struct loongarch_eiointc *s, int irq, int level)\n \tif (found \u003c EIOINTC_IRQS)\n \t\treturn; /* other irq is handling, needn't update parent irq */\n \n-\tvcpu_irq.irq = level ? (INT_HWI0 + ipnum) : -(INT_HWI0 + ipnum);\n-\tkvm_vcpu_ioctl_interrupt(vcpu, \u0026vcpu_irq);\n+\tif (level)\n+\t\tkvm_queue_irq(vcpu, INT_HWI0 + ipnum);\n+\telse\n+\t\tkvm_dequeue_irq(vcpu, INT_HWI0 + ipnum);\n+\tkvm_vcpu_kick(vcpu);\n }\n \n static inline void eiointc_update_sw_coremap(struct loongarch_eiointc *s,\n@@ -165,12 +169,12 @@ static int kvm_eiointc_read(struct kvm_vcpu *vcpu,\n \tstruct loongarch_eiointc *eiointc = vcpu-\u003ekvm-\u003earch.eiointc;\n \n \tif (!eiointc) {\n-\t\tkvm_err(\"%s: eiointc irqchip not valid!\\n\", __func__);\n+\t\tWARN_ONCE(1, \"%s: eiointc irqchip not valid!\\n\", __func__);\n \t\treturn 0;\n \t}\n \n \tif (addr \u0026 (len - 1)) {\n-\t\tkvm_err(\"%s: eiointc not aligned addr %llx len %d\\n\", __func__, addr, len);\n+\t\tWARN_ONCE(1, \"%s: eiointc not aligned addr %llx len %d\\n\", __func__, addr, len);\n \t\treturn 0;\n \t}\n \n@@ -297,12 +301,12 @@ static int kvm_eiointc_write(struct kvm_vcpu *vcpu,\n \tstruct loongarch_eiointc *eiointc = vcpu-\u003ekvm-\u003earch.eiointc;\n \n \tif (!eiointc) {\n-\t\tkvm_err(\"%s: eiointc irqchip not valid!\\n\", __func__);\n+\t\tWARN_ONCE(1, \"%s: eiointc irqchip not valid!\\n\", __func__);\n \t\treturn 0;\n \t}\n \n \tif (addr \u0026 (len - 1)) {\n-\t\tkvm_err(\"%s: eiointc not aligned addr %llx len %d\\n\", __func__, addr, len);\n+\t\tWARN_ONCE(1, \"%s: eiointc not aligned addr %llx len %d\\n\", __func__, addr, len);\n \t\treturn 0;\n \t}\n \n@@ -345,7 +349,7 @@ static int kvm_eiointc_virt_read(struct kvm_vcpu *vcpu,\n \tstruct loongarch_eiointc *eiointc = vcpu-\u003ekvm-\u003earch.eiointc;\n \n \tif (!eiointc) {\n-\t\tkvm_err(\"%s: eiointc irqchip not valid!\\n\", __func__);\n+\t\tWARN_ONCE(1, \"%s: eiointc irqchip not valid!\\n\", __func__);\n \t\treturn 0;\n \t}\n \n@@ -375,7 +379,7 @@ static int kvm_eiointc_virt_write(struct kvm_vcpu *vcpu,\n \tstruct loongarch_eiointc *eiointc = vcpu-\u003ekvm-\u003earch.eiointc;\n \n \tif (!eiointc) {\n-\t\tkvm_err(\"%s: eiointc irqchip not valid!\\n\", __func__);\n+\t\tWARN_ONCE(1, \"%s: eiointc irqchip not valid!\\n\", __func__);\n \t\treturn 0;\n \t}\n \n@@ -502,7 +506,7 @@ static int kvm_eiointc_regs_access(struct kvm_device *dev,\n \t\tp = (void *)s-\u003ecoremap + offset * 4;\n \t\tbreak;\n \tdefault:\n-\t\tkvm_err(\"%s: unknown eiointc register, addr = %d\\n\", __func__, addr);\n+\t\tWARN_ONCE(1, \"%s: unknown eiointc register, addr = %d\\n\", __func__, addr);\n \t\treturn -EINVAL;\n \t}\n \n@@ -546,7 +550,7 @@ static int kvm_eiointc_sw_status_access(struct kvm_device *dev,\n \t\tp = \u0026s-\u003estatus;\n \t\tbreak;\n \tdefault:\n-\t\tkvm_err(\"%s: unknown eiointc register, addr = %d\\n\", __func__, addr);\n+\t\tWARN_ONCE(1, \"%s: unknown eiointc register, addr = %d\\n\", __func__, addr);\n \t\treturn -EINVAL;\n \t}\n \tspin_lock_irqsave(\u0026s-\u003elock, flags);\ndiff --git a/arch/loongarch/kvm/intc/ipi.c b/arch/loongarch/kvm/intc/ipi.c\nindex 4fa0897d7bdb00..eacf2073c60332 100644\n--- a/arch/loongarch/kvm/intc/ipi.c\n+++ b/arch/loongarch/kvm/intc/ipi.c\n@@ -10,16 +10,15 @@\n static void ipi_set(struct kvm_vcpu *vcpu, uint32_t data)\n {\n \tuint32_t status;\n-\tstruct kvm_interrupt irq;\n \n \tspin_lock(\u0026vcpu-\u003earch.ipi_state.lock);\n \tstatus = vcpu-\u003earch.ipi_state.status;\n \tvcpu-\u003earch.ipi_state.status |= data;\n-\tspin_unlock(\u0026vcpu-\u003earch.ipi_state.lock);\n \tif ((status == 0) \u0026\u0026 data) {\n-\t\tirq.irq = LARCH_INT_IPI;\n-\t\tkvm_vcpu_ioctl_interrupt(vcpu, \u0026irq);\n+\t\tkvm_queue_irq(vcpu, LARCH_INT_IPI);\n+\t\tkvm_vcpu_kick(vcpu);\n \t}\n+\tspin_unlock(\u0026vcpu-\u003earch.ipi_state.lock);\n }\n \n static void ipi_send(struct kvm *kvm, uint64_t data)\n@@ -30,7 +29,7 @@ static void ipi_send(struct kvm *kvm, uint64_t data)\n \tcpu = ((data \u0026 0xffffffff) \u003e\u003e 16) \u0026 0x3ff;\n \tvcpu = kvm_get_vcpu_by_cpuid(kvm, cpu);\n \tif (unlikely(vcpu == NULL)) {\n-\t\tkvm_err(\"%s: invalid target cpu: %d\\n\", __func__, cpu);\n+\t\tWARN_ONCE(1, \"%s: invalid target cpu: %d\\n\", __func__, cpu);\n \t\treturn;\n \t}\n \n@@ -40,16 +39,15 @@ static void ipi_send(struct kvm *kvm, uint64_t data)\n static void ipi_clear(struct kvm_vcpu *vcpu, uint64_t data)\n {\n \tuint32_t status;\n-\tstruct kvm_interrupt irq;\n \n \tspin_lock(\u0026vcpu-\u003earch.ipi_state.lock);\n \tvcpu-\u003earch.ipi_state.status \u0026= ~data;\n \tstatus = vcpu-\u003earch.ipi_state.status;\n-\tspin_unlock(\u0026vcpu-\u003earch.ipi_state.lock);\n \tif (status == 0) {\n-\t\tirq.irq = -LARCH_INT_IPI;\n-\t\tkvm_vcpu_ioctl_interrupt(vcpu, \u0026irq);\n+\t\tkvm_dequeue_irq(vcpu, LARCH_INT_IPI);\n+\t\tkvm_vcpu_kick(vcpu);\n \t}\n+\tspin_unlock(\u0026vcpu-\u003earch.ipi_state.lock);\n }\n \n static uint64_t read_mailbox(struct kvm_vcpu *vcpu, int offset, int len)\n@@ -67,11 +65,8 @@ static uint64_t read_mailbox(struct kvm_vcpu *vcpu, int offset, int len)\n \t\treturn data \u0026 0xffff;\n \tcase 4:\n \t\treturn data \u0026 0xffffffff;\n-\tcase 8:\n-\t\treturn data;\n \tdefault:\n-\t\tkvm_err(\"%s: unknown data len: %d\\n\", __func__, len);\n-\t\treturn 0;\n+\t\treturn data;\n \t}\n }\n \n@@ -92,11 +87,9 @@ static void write_mailbox(struct kvm_vcpu *vcpu, int offset, uint64_t data, int\n \tcase 4:\n \t\t*(unsigned int *)pbuf = (unsigned int)data;\n \t\tbreak;\n-\tcase 8:\n+\tdefault:\n \t\t*(unsigned long *)pbuf = (unsigned long)data;\n \t\tbreak;\n-\tdefault:\n-\t\tkvm_err(\"%s: unknown data len: %d\\n\", __func__, len);\n \t}\n \tspin_unlock(\u0026vcpu-\u003earch.ipi_state.lock);\n }\n@@ -110,7 +103,7 @@ static int mail_send(struct kvm *kvm, uint64_t data)\n \tcpu = ((data \u0026 0xffffffff) \u003e\u003e 16) \u0026 0x3ff;\n \tvcpu = kvm_get_vcpu_by_cpuid(kvm, cpu);\n \tif (unlikely(vcpu == NULL)) {\n-\t\tkvm_err(\"%s: invalid target cpu: %d\\n\", __func__, cpu);\n+\t\tWARN_ONCE(1, \"%s: invalid target cpu: %d\\n\", __func__, cpu);\n \t\treturn 0;\n \t}\n \tmailbox = ((data \u0026 0xffffffff) \u003e\u003e 2) \u0026 0x7;\n@@ -144,7 +137,7 @@ static int send_ipi_data(struct kvm_vcpu *vcpu, gpa_t addr, uint64_t data)\n \t\tret = kvm_io_bus_read(vcpu, KVM_IOCSR_BUS, addr, 4, \u0026val);\n \t\tsrcu_read_unlock(\u0026vcpu-\u003ekvm-\u003esrcu, idx);\n \t\tif (unlikely(ret)) {\n-\t\t\tkvm_err(\"%s: : read data from addr %llx failed\\n\", __func__, addr);\n+\t\t\tWARN_ONCE(1, \"%s: : read data from addr %llx failed\\n\", __func__, addr);\n \t\t\treturn 0;\n \t\t}\n \t\t/* Construct the mask by scanning the bit 27-30 */\n@@ -160,7 +153,7 @@ static int send_ipi_data(struct kvm_vcpu *vcpu, gpa_t addr, uint64_t data)\n \tret = kvm_io_bus_write(vcpu, KVM_IOCSR_BUS, addr, 4, \u0026val);\n \tsrcu_read_unlock(\u0026vcpu-\u003ekvm-\u003esrcu, idx);\n \tif (unlikely(ret))\n-\t\tkvm_err(\"%s: : write data to addr %llx failed\\n\", __func__, addr);\n+\t\tWARN_ONCE(1, \"%s: : write data to addr %llx failed\\n\", __func__, addr);\n \n \treturn 0;\n }\n@@ -173,7 +166,7 @@ static int any_send(struct kvm *kvm, uint64_t data)\n \tcpu = ((data \u0026 0xffffffff) \u003e\u003e 16) \u0026 0x3ff;\n \tvcpu = kvm_get_vcpu_by_cpuid(kvm, cpu);\n \tif (unlikely(vcpu == NULL)) {\n-\t\tkvm_err(\"%s: invalid target cpu: %d\\n\", __func__, cpu);\n+\t\tWARN_ONCE(1, \"%s: invalid target cpu: %d\\n\", __func__, cpu);\n \t\treturn 0;\n \t}\n \toffset = data \u0026 0xffff;\n@@ -205,14 +198,14 @@ static int loongarch_ipi_readl(struct kvm_vcpu *vcpu, gpa_t addr, int len, void\n \t\tbreak;\n \tcase IOCSR_IPI_BUF_20 ... IOCSR_IPI_BUF_38 + 7:\n \t\tif (offset + len \u003e IOCSR_IPI_BUF_38 + 8) {\n-\t\t\tkvm_err(\"%s: invalid offset or len: offset = %d, len = %d\\n\",\n+\t\t\tWARN_ONCE(1, \"%s: invalid offset or len: offset = %d, len = %d\\n\",\n \t\t\t\t__func__, offset, len);\n \t\t\tbreak;\n \t\t}\n \t\tres = read_mailbox(vcpu, offset, len);\n \t\tbreak;\n \tdefault:\n-\t\tkvm_err(\"%s: unknown addr: %llx\\n\", __func__, addr);\n+\t\tWARN_ONCE(1, \"%s: unknown addr: %llx\\n\", __func__, addr);\n \t\tbreak;\n \t}\n \t*(uint64_t *)val = res;\n@@ -247,7 +240,7 @@ static int loongarch_ipi_writel(struct kvm_vcpu *vcpu, gpa_t addr, int len, cons\n \t\tbreak;\n \tcase IOCSR_IPI_BUF_20 ... IOCSR_IPI_BUF_38 + 7:\n \t\tif (offset + len \u003e IOCSR_IPI_BUF_38 + 8) {\n-\t\t\tkvm_err(\"%s: invalid offset or len: offset = %d, len = %d\\n\",\n+\t\t\tWARN_ONCE(1, \"%s: invalid offset or len: offset = %d, len = %d\\n\",\n \t\t\t\t__func__, offset, len);\n \t\t\tbreak;\n \t\t}\n@@ -263,7 +256,7 @@ static int loongarch_ipi_writel(struct kvm_vcpu *vcpu, gpa_t addr, int len, cons\n \t\tany_send(vcpu-\u003ekvm, data);\n \t\tbreak;\n \tdefault:\n-\t\tkvm_err(\"%s: unknown addr: %llx\\n\", __func__, addr);\n+\t\tWARN_ONCE(1, \"%s: unknown addr: %llx\\n\", __func__, addr);\n \t\tbreak;\n \t}\n \n@@ -306,7 +299,7 @@ static int kvm_ipi_regs_access(struct kvm_device *dev,\n \n \tvcpu = kvm_get_vcpu_by_id(dev-\u003ekvm, cpu);\n \tif (unlikely(vcpu == NULL)) {\n-\t\tkvm_err(\"%s: invalid target cpu: %d\\n\", __func__, cpu);\n+\t\tWARN_ONCE(1, \"%s: invalid target cpu: %d\\n\", __func__, cpu);\n \t\treturn -EINVAL;\n \t}\n \n@@ -340,7 +333,7 @@ static int kvm_ipi_regs_access(struct kvm_device *dev,\n \t\tlen = 8;\n \t\tbreak;\n \tdefault:\n-\t\tkvm_err(\"%s: unknown ipi register, addr = %d\\n\", __func__, addr);\n+\t\tWARN_ONCE(1, \"%s: unknown ipi register, addr = %d\\n\", __func__, addr);\n \t\treturn -EINVAL;\n \t}\n \n@@ -374,7 +367,7 @@ static int kvm_ipi_get_attr(struct kvm_device *dev,\n \tcase KVM_DEV_LOONGARCH_IPI_GRP_REGS:\n \t\treturn kvm_ipi_regs_access(dev, attr, false);\n \tdefault:\n-\t\tkvm_err(\"%s: unknown group (%d)\\n\", __func__, attr-\u003egroup);\n+\t\tWARN_ONCE(1, \"%s: unknown group (%d)\\n\", __func__, attr-\u003egroup);\n \t\treturn -EINVAL;\n \t}\n }\n@@ -386,7 +379,7 @@ static int kvm_ipi_set_attr(struct kvm_device *dev,\n \tcase KVM_DEV_LOONGARCH_IPI_GRP_REGS:\n \t\treturn kvm_ipi_regs_access(dev, attr, true);\n \tdefault:\n-\t\tkvm_err(\"%s: unknown group (%d)\\n\", __func__, attr-\u003egroup);\n+\t\tWARN_ONCE(1, \"%s: unknown group (%d)\\n\", __func__, attr-\u003egroup);\n \t\treturn -EINVAL;\n \t}\n }\n@@ -399,13 +392,13 @@ static int kvm_ipi_create(struct kvm_device *dev, u32 type)\n \tstruct loongarch_ipi *s;\n \n \tif (!dev) {\n-\t\tkvm_err(\"%s: kvm_device ptr is invalid!\\n\", __func__);\n+\t\tWARN_ONCE(1, \"%s: kvm_device ptr is invalid!\\n\", __func__);\n \t\treturn -EINVAL;\n \t}\n \n \tkvm = dev-\u003ekvm;\n \tif (kvm-\u003earch.ipi) {\n-\t\tkvm_err(\"%s: LoongArch IPI has already been created!\\n\", __func__);\n+\t\tWARN_ONCE(1, \"%s: LoongArch IPI has already been created!\\n\", __func__);\n \t\treturn -EINVAL;\n \t}\n \n@@ -425,7 +418,7 @@ static int kvm_ipi_create(struct kvm_device *dev, u32 type)\n \tret = kvm_io_bus_register_dev(kvm, KVM_IOCSR_BUS, IOCSR_IPI_BASE, IOCSR_IPI_SIZE, device);\n \tmutex_unlock(\u0026kvm-\u003eslots_lock);\n \tif (ret \u003c 0) {\n-\t\tkvm_err(\"%s: Initialize IOCSR dev failed, ret = %d\\n\", __func__, ret);\n+\t\tWARN_ONCE(1, \"%s: Initialize IOCSR dev failed, ret = %d\\n\", __func__, ret);\n \t\tgoto err;\n \t}\n \ndiff --git a/arch/loongarch/kvm/intc/pch_pic.c b/arch/loongarch/kvm/intc/pch_pic.c\nindex 175a630aceb416..299b4db268337b 100644\n--- a/arch/loongarch/kvm/intc/pch_pic.c\n+++ b/arch/loongarch/kvm/intc/pch_pic.c\n@@ -151,12 +151,12 @@ static int kvm_pch_pic_read(struct kvm_vcpu *vcpu,\n \tstruct loongarch_pch_pic *s = vcpu-\u003ekvm-\u003earch.pch_pic;\n \n \tif (!s) {\n-\t\tkvm_err(\"%s: pch pic irqchip not valid!\\n\", __func__);\n+\t\tWARN_ONCE(1, \"%s: pch pic irqchip not valid!\\n\", __func__);\n \t\treturn ret;\n \t}\n \n \tif (addr \u0026 (len - 1)) {\n-\t\tkvm_err(\"%s: pch pic not aligned addr %llx len %d\\n\", __func__, addr, len);\n+\t\tWARN_ONCE(1, \"%s: pch pic not aligned addr %llx len %d\\n\", __func__, addr, len);\n \t\treturn ret;\n \t}\n \n@@ -250,12 +250,12 @@ static int kvm_pch_pic_write(struct kvm_vcpu *vcpu,\n \tstruct loongarch_pch_pic *s = vcpu-\u003ekvm-\u003earch.pch_pic;\n \n \tif (!s) {\n-\t\tkvm_err(\"%s: pch pic irqchip not valid!\\n\", __func__);\n+\t\tWARN_ONCE(1, \"%s: pch pic irqchip not valid!\\n\", __func__);\n \t\treturn ret;\n \t}\n \n \tif (addr \u0026 (len - 1)) {\n-\t\tkvm_err(\"%s: pch pic not aligned addr %llx len %d\\n\", __func__, addr, len);\n+\t\tWARN_ONCE(1, \"%s: pch pic not aligned addr %llx len %d\\n\", __func__, addr, len);\n \t\treturn ret;\n \t}\n \n@@ -390,13 +390,13 @@ static int kvm_pch_pic_set_attr(struct kvm_device *dev,\n \t\t\t\treturn -EFAULT;\n \n \t\t\tif (!dev-\u003ekvm-\u003earch.pch_pic) {\n-\t\t\t\tkvm_err(\"%s: please create pch_pic irqchip first!\\n\", __func__);\n+\t\t\t\tWARN_ONCE(1, \"%s: please create pch_pic irqchip first\\n\", __func__);\n \t\t\t\treturn -ENODEV;\n \t\t\t}\n \n \t\t\treturn kvm_pch_pic_init(dev, addr);\n \t\tdefault:\n-\t\t\tkvm_err(\"%s: unknown group (%d) attr (%lld)\\n\", __func__, attr-\u003egroup,\n+\t\t\tWARN_ONCE(1, \"%s: unknown group (%d) attr (%lld)\\n\", __func__, attr-\u003egroup,\n \t\t\t\t\tattr-\u003eattr);\n \t\t\treturn -EINVAL;\n \t\t}\ndiff --git a/arch/loongarch/kvm/vcpu.c b/arch/loongarch/kvm/vcpu.c\nindex 20c207d80e31ae..265aaad6331572 100644\n--- a/arch/loongarch/kvm/vcpu.c\n+++ b/arch/loongarch/kvm/vcpu.c\n@@ -1465,6 +1465,9 @@ int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu, struct kvm_interrupt *irq)\n \tif (vector \u003e= EXCCODE_INT_NUM)\n \t\treturn -EINVAL;\n \n+\tif (kvm_arch_irqchip_in_kernel(vcpu-\u003ekvm))\n+\t\treturn -EINVAL;\n+\n \tif (!kvm_guest_has_msgint(\u0026vcpu-\u003earch) \u0026\u0026 (vector == INT_AVEC))\n \t\treturn -EINVAL;\n \n@@ -1473,7 +1476,7 @@ int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu, struct kvm_interrupt *irq)\n \telse if (intr \u003c 0)\n \t\tkvm_dequeue_irq(vcpu, -intr);\n \telse {\n-\t\tkvm_err(\"%s: invalid interrupt ioctl %d\\n\", __func__, irq-\u003eirq);\n+\t\tWARN_ONCE(1, \"%s: invalid interrupt ioctl %d\\n\", __func__, irq-\u003eirq);\n \t\treturn -EINVAL;\n \t}\n \n"
}

2/1 2026/06/29 02:52 agent patch-evaluator
1m Model:
gemini-3.1-pro-preview

Args:
null

Results:
{
  "EnableConfigs": [
    "KVM"
  ],
  "FocusSymbols": [
    "kvm_vcpu_ioctl_interrupt",
    "kvm_eiointc_write",
    "kvm_pch_pic_write",
    "loongarch_ipi_writel",
    "kvm_emu_mmio_write",
    "kvm_dmsintc_set_attr",
    "kvm_eiointc_set_attr",
    "kvm_ipi_set_attr",
    "kvm_pch_pic_set_attr"
  ],
  "Reasoning": "The patch makes functional changes to LoongArch KVM interrupt handling. It modifies `kvm_vcpu_ioctl_interrupt` to return `-EINVAL` if an in-kernel irqchip is used, and updates internal callers to use `kvm_queue_irq` and `kvm_dequeue_irq` directly. It also replaces numerous `kvm_err` calls with `WARN_ONCE` across various KVM exit and interrupt controller handlers. These changes affect reachable core KVM logic and should be fuzzed.",
  "WorthFuzzing": true
}

Instruction:
You are an expert Linux kernel maintainer.
Your job is to review a provided patch series and determine
if it makes functional changes to the kernel that should be fuzzed.

IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on your internal knowledge of the kernel. You must actively
use your code access tools to examine the actual source code and confirm any assumptions.

Return WorthFuzzing=false if the patch only contains:
- Modifications to Documentation/, Kconfig files, or code comments.
- Purely decorative changes, such as logging (e.g., pr_err, printk) or tracepoints.
- Changes to numeric constants or macros that do not functionally alter execution flow.
- Code paths that are impossible to reach in virtualized environments like GCE or QEMU,
even when utilizing software-emulated hardware (e.g., usb gadget, mac80211_hwsim).

If it modifies reachable core kernel logic, drivers, or architectures, use your code search
tools to verify the code can be executed, then return WorthFuzzing=true.

When returning WorthFuzzing=true, you MUST ALSO:
1. Extract any specific kernel functions that should be heavily fuzzed into FocusSymbols.
   Avoid listing generic hot-path functions to prevent skewed test distributions.
2. Identify any specific CONFIG_ options required to properly test this new/modified feature.
   Go and look into the Kconfig files and check for ifdefs around the code, do not make assumptions.
   Do not list too generic configs (we already have them enabled). Only list those that
   specifically cover the modified code. List them in the EnableConfigs output array,
   and DO NOT add a 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4").
Prefer calling several tools at the same time to save round-trips.


Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.

Prompt:
For your convenience, here is the diff of the changes:
commit f9387a2e57a70064e3441bbd6daec9807b7cd66f
Author: syz-cluster <triage@syzkaller.com>
Date:   Mon Jun 29 02:52:46 2026 +0000

    syz-cluster: applied patch under review

diff --git a/arch/loongarch/kvm/exit.c b/arch/loongarch/kvm/exit.c
index 8572b63478bb98..4ad006e27a4d8d 100644
--- a/arch/loongarch/kvm/exit.c
+++ b/arch/loongarch/kvm/exit.c
@@ -252,7 +252,7 @@ int kvm_complete_iocsr_read(struct kvm_vcpu *vcpu, struct kvm_run *run)
 		*gpr = *(s64 *)run->iocsr_io.data;
 		break;
 	default:
-		kvm_err("Bad IOCSR length: %d, addr is 0x%lx\n",
+		WARN_ONCE(1, "Bad IOCSR length: %d, addr is 0x%lx\n",
 				run->iocsr_io.len, vcpu->arch.badv);
 		er = EMULATE_FAIL;
 		break;
@@ -326,7 +326,7 @@ static int kvm_trap_handle_gspr(struct kvm_vcpu *vcpu)
 
 	/* Rollback PC only if emulation was unsuccessful */
 	if (er == EMULATE_FAIL) {
-		kvm_err("[%#lx]%s: unsupported gspr instruction 0x%08x\n",
+		WARN_ONCE(1, "[%#lx]%s: unsupported gspr instruction 0x%08x\n",
 			curr_pc, __func__, inst.word);
 
 		kvm_arch_vcpu_dump_regs(vcpu);
@@ -491,7 +491,7 @@ int kvm_emu_mmio_read(struct kvm_vcpu *vcpu, larch_inst inst)
 		return EMULATE_DO_MMIO;
 	}
 
-	kvm_err("Read not supported Inst=0x%08x @%lx BadVaddr:%#lx\n",
+	WARN_ONCE(1, "Read not supported Inst=0x%08x @%lx BadVaddr:%#lx\n",
 			inst.word, vcpu->arch.pc, vcpu->arch.badv);
 	kvm_arch_vcpu_dump_regs(vcpu);
 	vcpu->mmio_needed = 0;
@@ -529,7 +529,7 @@ int kvm_complete_mmio_read(struct kvm_vcpu *vcpu, struct kvm_run *run)
 		*gpr = *(s64 *)run->mmio.data;
 		break;
 	default:
-		kvm_err("Bad MMIO length: %d, addr is 0x%lx\n",
+		WARN_ONCE(1, "Bad MMIO length: %d, addr is 0x%lx\n",
 				run->mmio.len, vcpu->arch.badv);
 		er = EMULATE_FAIL;
 		break;
@@ -656,7 +656,7 @@ int kvm_emu_mmio_write(struct kvm_vcpu *vcpu, larch_inst inst)
 	}
 
 	vcpu->arch.pc = curr_pc;
-	kvm_err("Write not supported Inst=0x%08x @%lx BadVaddr:%#lx\n",
+	WARN_ONCE(1, "Write not supported Inst=0x%08x @%lx BadVaddr:%#lx\n",
 			inst.word, vcpu->arch.pc, vcpu->arch.badv);
 	kvm_arch_vcpu_dump_regs(vcpu);
 	/* Rollback PC if emulation was unsuccessful */
@@ -748,8 +748,7 @@ static int kvm_handle_fpu_disabled(struct kvm_vcpu *vcpu, int ecode)
 	 * treated as a reserved instruction!
 	 * If FPU already in use, we shouldn't get this at all.
 	 */
-	if (WARN_ON(vcpu->arch.aux_inuse & KVM_LARCH_FPU)) {
-		kvm_err("%s internal error\n", __func__);
+	if (WARN_ON_ONCE(vcpu->arch.aux_inuse & KVM_LARCH_FPU)) {
 		run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
 		return RESUME_HOST;
 	}
@@ -943,7 +942,7 @@ static int kvm_fault_ni(struct kvm_vcpu *vcpu, int ecode)
 	/* Fetch the instruction */
 	inst = vcpu->arch.badi;
 	badv = vcpu->arch.badv;
-	kvm_err("ECode: %d PC=%#lx Inst=0x%08x BadVaddr=%#lx ESTAT=%#lx\n",
+	WARN_ONCE(1, "ECode: %d PC=%#lx Inst=0x%08x BadVaddr=%#lx ESTAT=%#lx\n",
 			ecode, vcpu->arch.pc, inst, badv, read_gcsr_estat());
 	kvm_arch_vcpu_dump_regs(vcpu);
 	kvm_queue_exception(vcpu, EXCCODE_INE, 0);
diff --git a/arch/loongarch/kvm/intc/dmsintc.c b/arch/loongarch/kvm/intc/dmsintc.c
index de25735ce03946..ed85532247759e 100644
--- a/arch/loongarch/kvm/intc/dmsintc.c
+++ b/arch/loongarch/kvm/intc/dmsintc.c
@@ -47,7 +47,6 @@ void dmsintc_inject_irq(struct kvm_vcpu *vcpu)
 int dmsintc_deliver_msi_to_vcpu(struct kvm *kvm,
 				struct kvm_vcpu *vcpu, u32 vector, int level)
 {
-	struct kvm_interrupt vcpu_irq;
 	struct dmsintc_state *ds = &vcpu->arch.dmsintc_state;
 
 	if (!level)
@@ -57,9 +56,11 @@ int dmsintc_deliver_msi_to_vcpu(struct kvm *kvm,
 	if (!ds)
 		return -ENODEV;
 
-	vcpu_irq.irq = INT_AVEC;
+	if (!kvm_guest_has_msgint(&vcpu->arch))
+		return -EINVAL;
+
 	set_bit(vector, (unsigned long *)&ds->vector_map);
-	kvm_vcpu_ioctl_interrupt(vcpu, &vcpu_irq);
+	kvm_queue_irq(vcpu, INT_AVEC);
 	kvm_vcpu_kick(vcpu);
 
 	return 0;
@@ -114,7 +115,7 @@ static int kvm_dmsintc_ctrl_access(struct kvm_device *dev,
 		}
 		break;
 	default:
-		kvm_err("%s: unknown dmsintc register, addr = %d\n", __func__, addr);
+		WARN_ONCE(1, "%s: unknown dmsintc register, addr = %d\n", __func__, addr);
 		return -ENXIO;
 	}
 
@@ -128,7 +129,7 @@ static int kvm_dmsintc_set_attr(struct kvm_device *dev,
 	case KVM_DEV_LOONGARCH_DMSINTC_GRP_CTRL:
 		return kvm_dmsintc_ctrl_access(dev, attr, true);
 	default:
-		kvm_err("%s: unknown group (%d)\n", __func__, attr->group);
+		WARN_ONCE(1, "%s: unknown group (%d)\n", __func__, attr->group);
 		return -EINVAL;
 	}
 }
@@ -139,13 +140,13 @@ static int kvm_dmsintc_create(struct kvm_device *dev, u32 type)
 	struct loongarch_dmsintc *s;
 
 	if (!dev) {
-		kvm_err("%s: kvm_device ptr is invalid!\n", __func__);
+		WARN_ONCE(1, "%s: kvm_device ptr is invalid!\n", __func__);
 		return -EINVAL;
 	}
 
 	kvm = dev->kvm;
 	if (kvm->arch.dmsintc) {
-		kvm_err("%s: LoongArch DMSINTC has already been created!\n", __func__);
+		WARN_ONCE(1, "%s: LoongArch DMSINTC has already been created!\n", __func__);
 		return -EINVAL;
 	}
 
diff --git a/arch/loongarch/kvm/intc/eiointc.c b/arch/loongarch/kvm/intc/eiointc.c
index 2b14485d14a708..681dfb548dbf88 100644
--- a/arch/loongarch/kvm/intc/eiointc.c
+++ b/arch/loongarch/kvm/intc/eiointc.c
@@ -17,7 +17,8 @@ static void eiointc_set_sw_coreisr(struct loongarch_eiointc *s)
 		if (!(s->status & BIT(EIOINTC_ENABLE_INT_ENCODE))) {
 			ipnum = count_trailing_zeros(ipnum);
 			ipnum = ipnum < 4 ? ipnum : 0;
-		}
+		} else if (ipnum >= LOONGSON_IP_NUM)
+			ipnum = 0;
 
 		cpuid = ((u8 *)s->coremap)[irq];
 		vcpu = kvm_get_vcpu_by_cpuid(s->kvm, cpuid);
@@ -36,18 +37,18 @@ static void eiointc_update_irq(struct loongarch_eiointc *s, int irq, int level)
 {
 	int ipnum, cpu, found;
 	struct kvm_vcpu *vcpu;
-	struct kvm_interrupt vcpu_irq;
 
 	ipnum = (s->ipmap >> (irq / 32 * 8)) & 0xff;
 	if (!(s->status & BIT(EIOINTC_ENABLE_INT_ENCODE))) {
 		ipnum = count_trailing_zeros(ipnum);
 		ipnum = ipnum < 4 ? ipnum : 0;
-	}
+	} else if (ipnum >= LOONGSON_IP_NUM)
+		ipnum = 0;
 
 	cpu = s->sw_coremap[irq];
 	vcpu = kvm_get_vcpu_by_id(s->kvm, cpu);
 	if (unlikely(vcpu == NULL)) {
-		kvm_err("%s: invalid target cpu: %d\n", __func__, cpu);
+		WARN_ONCE(1, "%s: invalid target cpu: %d\n", __func__, cpu);
 		return;
 	}
 
@@ -67,8 +68,11 @@ static void eiointc_update_irq(struct loongarch_eiointc *s, int irq, int level)
 	if (found < EIOINTC_IRQS)
 		return; /* other irq is handling, needn't update parent irq */
 
-	vcpu_irq.irq = level ? (INT_HWI0 + ipnum) : -(INT_HWI0 + ipnum);
-	kvm_vcpu_ioctl_interrupt(vcpu, &vcpu_irq);
+	if (level)
+		kvm_queue_irq(vcpu, INT_HWI0 + ipnum);
+	else
+		kvm_dequeue_irq(vcpu, INT_HWI0 + ipnum);
+	kvm_vcpu_kick(vcpu);
 }
 
 static inline void eiointc_update_sw_coremap(struct loongarch_eiointc *s,
@@ -165,12 +169,12 @@ static int kvm_eiointc_read(struct kvm_vcpu *vcpu,
 	struct loongarch_eiointc *eiointc = vcpu->kvm->arch.eiointc;
 
 	if (!eiointc) {
-		kvm_err("%s: eiointc irqchip not valid!\n", __func__);
+		WARN_ONCE(1, "%s: eiointc irqchip not valid!\n", __func__);
 		return 0;
 	}
 
 	if (addr & (len - 1)) {
-		kvm_err("%s: eiointc not aligned addr %llx len %d\n", __func__, addr, len);
+		WARN_ONCE(1, "%s: eiointc not aligned addr %llx len %d\n", __func__, addr, len);
 		return 0;
 	}
 
@@ -297,12 +301,12 @@ static int kvm_eiointc_write(struct kvm_vcpu *vcpu,
 	struct loongarch_eiointc *eiointc = vcpu->kvm->arch.eiointc;
 
 	if (!eiointc) {
-		kvm_err("%s: eiointc irqchip not valid!\n", __func__);
+		WARN_ONCE(1, "%s: eiointc irqchip not valid!\n", __func__);
 		return 0;
 	}
 
 	if (addr & (len - 1)) {
-		kvm_err("%s: eiointc not aligned addr %llx len %d\n", __func__, addr, len);
+		WARN_ONCE(1, "%s: eiointc not aligned addr %llx len %d\n", __func__, addr, len);
 		return 0;
 	}
 
@@ -345,7 +349,7 @@ static int kvm_eiointc_virt_read(struct kvm_vcpu *vcpu,
 	struct loongarch_eiointc *eiointc = vcpu->kvm->arch.eiointc;
 
 	if (!eiointc) {
-		kvm_err("%s: eiointc irqchip not valid!\n", __func__);
+		WARN_ONCE(1, "%s: eiointc irqchip not valid!\n", __func__);
 		return 0;
 	}
 
@@ -375,7 +379,7 @@ static int kvm_eiointc_virt_write(struct kvm_vcpu *vcpu,
 	struct loongarch_eiointc *eiointc = vcpu->kvm->arch.eiointc;
 
 	if (!eiointc) {
-		kvm_err("%s: eiointc irqchip not valid!\n", __func__);
+		WARN_ONCE(1, "%s: eiointc irqchip not valid!\n", __func__);
 		return 0;
 	}
 
@@ -502,7 +506,7 @@ static int kvm_eiointc_regs_access(struct kvm_device *dev,
 		p = (void *)s->coremap + offset * 4;
 		break;
 	default:
-		kvm_err("%s: unknown eiointc register, addr = %d\n", __func__, addr);
+		WARN_ONCE(1, "%s: unknown eiointc register, addr = %d\n", __func__, addr);
 		return -EINVAL;
 	}
 
@@ -546,7 +550,7 @@ static int kvm_eiointc_sw_status_access(struct kvm_device *dev,
 		p = &s->status;
 		break;
 	default:
-		kvm_err("%s: unknown eiointc register, addr = %d\n", __func__, addr);
+		WARN_ONCE(1, "%s: unknown eiointc register, addr = %d\n", __func__, addr);
 		return -EINVAL;
 	}
 	spin_lock_irqsave(&s->lock, flags);
diff --git a/arch/loongarch/kvm/intc/ipi.c b/arch/loongarch/kvm/intc/ipi.c
index 4fa0897d7bdb00..eacf2073c60332 100644
--- a/arch/loongarch/kvm/intc/ipi.c
+++ b/arch/loongarch/kvm/intc/ipi.c
@@ -10,16 +10,15 @@
 static void ipi_set(struct kvm_vcpu *vcpu, uint32_t data)
 {
 	uint32_t status;
-	struct kvm_interrupt irq;
 
 	spin_lock(&vcpu->arch.ipi_state.lock);
 	status = vcpu->arch.ipi_state.status;
 	vcpu->arch.ipi_state.status |= data;
-	spin_unlock(&vcpu->arch.ipi_state.lock);
 	if ((status == 0) && data) {
-		irq.irq = LARCH_INT_IPI;
-		kvm_vcpu_ioctl_interrupt(vcpu, &irq);
+		kvm_queue_irq(vcpu, LARCH_INT_IPI);
+		kvm_vcpu_kick(vcpu);
 	}
+	spin_unlock(&vcpu->arch.ipi_state.lock);
 }
 
 static void ipi_send(struct kvm *kvm, uint64_t data)
@@ -30,7 +29,7 @@ static void ipi_send(struct kvm *kvm, uint64_t data)
 	cpu = ((data & 0xffffffff) >> 16) & 0x3ff;
 	vcpu = kvm_get_vcpu_by_cpuid(kvm, cpu);
 	if (unlikely(vcpu == NULL)) {
-		kvm_err("%s: invalid target cpu: %d\n", __func__, cpu);
+		WARN_ONCE(1, "%s: invalid target cpu: %d\n", __func__, cpu);
 		return;
 	}
 
@@ -40,16 +39,15 @@ static void ipi_send(struct kvm *kvm, uint64_t data)
 static void ipi_clear(struct kvm_vcpu *vcpu, uint64_t data)
 {
 	uint32_t status;
-	struct kvm_interrupt irq;
 
 	spin_lock(&vcpu->arch.ipi_state.lock);
 	vcpu->arch.ipi_state.status &= ~data;
 	status = vcpu->arch.ipi_state.status;
-	spin_unlock(&vcpu->arch.ipi_state.lock);
 	if (status == 0) {
-		irq.irq = -LARCH_INT_IPI;
-		kvm_vcpu_ioctl_interrupt(vcpu, &irq);
+		kvm_dequeue_irq(vcpu, LARCH_INT_IPI);
+		kvm_vcpu_kick(vcpu);
 	}
+	spin_unlock(&vcpu->arch.ipi_state.lock);
 }
 
 static uint64_t read_mailbox(struct kvm_vcpu *vcpu, int offset, int len)
@@ -67,11 +65,8 @@ static uint64_t read_mailbox(struct kvm_vcpu *vcpu, int offset, int len)
 		return data & 0xffff;
 	case 4:
 		return data & 0xffffffff;
-	case 8:
-		return data;
 	default:
-		kvm_err("%s: unknown data len: %d\n", __func__, len);
-		return 0;
+		return data;
 	}
 }
 
@@ -92,11 +87,9 @@ static void write_mailbox(struct kvm_vcpu *vcpu, int offset, uint64_t data, int
 	case 4:
 		*(unsigned int *)pbuf = (unsigned int)data;
 		break;
-	case 8:
+	default:
 		*(unsigned long *)pbuf = (unsigned long)data;
 		break;
-	default:
-		kvm_err("%s: unknown data len: %d\n", __func__, len);
 	}
 	spin_unlock(&vcpu->arch.ipi_state.lock);
 }
@@ -110,7 +103,7 @@ static int mail_send(struct kvm *kvm, uint64_t data)
 	cpu = ((data & 0xffffffff) >> 16) & 0x3ff;
 	vcpu = kvm_get_vcpu_by_cpuid(kvm, cpu);
 	if (unlikely(vcpu == NULL)) {
-		kvm_err("%s: invalid target cpu: %d\n", __func__, cpu);
+		WARN_ONCE(1, "%s: invalid target cpu: %d\n", __func__, cpu);
 		return 0;
 	}
 	mailbox = ((data & 0xffffffff) >> 2) & 0x7;
@@ -144,7 +137,7 @@ static int send_ipi_data(struct kvm_vcpu *vcpu, gpa_t addr, uint64_t data)
 		ret = kvm_io_bus_read(vcpu, KVM_IOCSR_BUS, addr, 4, &val);
 		srcu_read_unlock(&vcpu->kvm->srcu, idx);
 		if (unlikely(ret)) {
-			kvm_err("%s: : read data from addr %llx failed\n", __func__, addr);
+			WARN_ONCE(1, "%s: : read data from addr %llx failed\n", __func__, addr);
 			return 0;
 		}
 		/* Construct the mask by scanning the bit 27-30 */
@@ -160,7 +153,7 @@ static int send_ipi_data(struct kvm_vcpu *vcpu, gpa_t addr, uint64_t data)
 	ret = kvm_io_bus_write(vcpu, KVM_IOCSR_BUS, addr, 4, &val);
 	srcu_read_unlock(&vcpu->kvm->srcu, idx);
 	if (unlikely(ret))
-		kvm_err("%s: : write data to addr %llx failed\n", __func__, addr);
+		WARN_ONCE(1, "%s: : write data to addr %llx failed\n", __func__, addr);
 
 	return 0;
 }
@@ -173,7 +166,7 @@ static int any_send(struct kvm *kvm, uint64_t data)
 	cpu = ((data & 0xffffffff) >> 16) & 0x3ff;
 	vcpu = kvm_get_vcpu_by_cpuid(kvm, cpu);
 	if (unlikely(vcpu == NULL)) {
-		kvm_err("%s: invalid target cpu: %d\n", __func__, cpu);
+		WARN_ONCE(1, "%s: invalid target cpu: %d\n", __func__, cpu);
 		return 0;
 	}
 	offset = data & 0xffff;
@@ -205,14 +198,14 @@ static int loongarch_ipi_readl(struct kvm_vcpu *vcpu, gpa_t addr, int len, void
 		break;
 	case IOCSR_IPI_BUF_20 ... IOCSR_IPI_BUF_38 + 7:
 		if (offset + len > IOCSR_IPI_BUF_38 + 8) {
-			kvm_err("%s: invalid offset or len: offset = %d, len = %d\n",
+			WARN_ONCE(1, "%s: invalid offset or len: offset = %d, len = %d\n",
 				__func__, offset, len);
 			break;
 		}
 		res = read_mailbox(vcpu, offset, len);
 		break;
 	default:
-		kvm_err("%s: unknown addr: %llx\n", __func__, addr);
+		WARN_ONCE(1, "%s: unknown addr: %llx\n", __func__, addr);
 		break;
 	}
 	*(uint64_t *)val = res;
@@ -247,7 +240,7 @@ static int loongarch_ipi_writel(struct kvm_vcpu *vcpu, gpa_t addr, int len, cons
 		break;
 	case IOCSR_IPI_BUF_20 ... IOCSR_IPI_BUF_38 + 7:
 		if (offset + len > IOCSR_IPI_BUF_38 + 8) {
-			kvm_err("%s: invalid offset or len: offset = %d, len = %d\n",
+			WARN_ONCE(1, "%s: invalid offset or len: offset = %d, len = %d\n",
 				__func__, offset, len);
 			break;
 		}
@@ -263,7 +256,7 @@ static int loongarch_ipi_writel(struct kvm_vcpu *vcpu, gpa_t addr, int len, cons
 		any_send(vcpu->kvm, data);
 		break;
 	default:
-		kvm_err("%s: unknown addr: %llx\n", __func__, addr);
+		WARN_ONCE(1, "%s: unknown addr: %llx\n", __func__, addr);
 		break;
 	}
 
@@ -306,7 +299,7 @@ static int kvm_ipi_regs_access(struct kvm_device *dev,
 
 	vcpu = kvm_get_vcpu_by_id(dev->kvm, cpu);
 	if (unlikely(vcpu == NULL)) {
-		kvm_err("%s: invalid target cpu: %d\n", __func__, cpu);
+		WARN_ONCE(1, "%s: invalid target cpu: %d\n", __func__, cpu);
 		return -EINVAL;
 	}
 
@@ -340,7 +333,7 @@ static int kvm_ipi_regs_access(struct kvm_device *dev,
 		len = 8;
 		break;
 	default:
-		kvm_err("%s: unknown ipi register, addr = %d\n", __func__, addr);
+		WARN_ONCE(1, "%s: unknown ipi register, addr = %d\n", __func__, addr);
 		return -EINVAL;
 	}
 
@@ -374,7 +367,7 @@ static int kvm_ipi_get_attr(struct kvm_device *dev,
 	case KVM_DEV_LOONGARCH_IPI_GRP_REGS:
 		return kvm_ipi_regs_access(dev, attr, false);
 	default:
-		kvm_err("%s: unknown group (%d)\n", __func__, attr->group);
+		WARN_ONCE(1, "%s: unknown group (%d)\n", __func__, attr->group);
 		return -EINVAL;
 	}
 }
@@ -386,7 +379,7 @@ static int kvm_ipi_set_attr(struct kvm_device *dev,
 	case KVM_DEV_LOONGARCH_IPI_GRP_REGS:
 		return kvm_ipi_regs_access(dev, attr, true);
 	default:
-		kvm_err("%s: unknown group (%d)\n", __func__, attr->group);
+		WARN_ONCE(1, "%s: unknown group (%d)\n", __func__, attr->group);
 		return -EINVAL;
 	}
 }
@@ -399,13 +392,13 @@ static int kvm_ipi_create(struct kvm_device *dev, u32 type)
 	struct loongarch_ipi *s;
 
 	if (!dev) {
-		kvm_err("%s: kvm_device ptr is invalid!\n", __func__);
+		WARN_ONCE(1, "%s: kvm_device ptr is invalid!\n", __func__);
 		return -EINVAL;
 	}
 
 	kvm = dev->kvm;
 	if (kvm->arch.ipi) {
-		kvm_err("%s: LoongArch IPI has already been created!\n", __func__);
+		WARN_ONCE(1, "%s: LoongArch IPI has already been created!\n", __func__);
 		return -EINVAL;
 	}
 
@@ -425,7 +418,7 @@ static int kvm_ipi_create(struct kvm_device *dev, u32 type)
 	ret = kvm_io_bus_register_dev(kvm, KVM_IOCSR_BUS, IOCSR_IPI_BASE, IOCSR_IPI_SIZE, device);
 	mutex_unlock(&kvm->slots_lock);
 	if (ret < 0) {
-		kvm_err("%s: Initialize IOCSR dev failed, ret = %d\n", __func__, ret);
+		WARN_ONCE(1, "%s: Initialize IOCSR dev failed, ret = %d\n", __func__, ret);
 		goto err;
 	}
 
diff --git a/arch/loongarch/kvm/intc/pch_pic.c b/arch/loongarch/kvm/intc/pch_pic.c
index 175a630aceb416..299b4db268337b 100644
--- a/arch/loongarch/kvm/intc/pch_pic.c
+++ b/arch/loongarch/kvm/intc/pch_pic.c
@@ -151,12 +151,12 @@ static int kvm_pch_pic_read(struct kvm_vcpu *vcpu,
 	struct loongarch_pch_pic *s = vcpu->kvm->arch.pch_pic;
 
 	if (!s) {
-		kvm_err("%s: pch pic irqchip not valid!\n", __func__);
+		WARN_ONCE(1, "%s: pch pic irqchip not valid!\n", __func__);
 		return ret;
 	}
 
 	if (addr & (len - 1)) {
-		kvm_err("%s: pch pic not aligned addr %llx len %d\n", __func__, addr, len);
+		WARN_ONCE(1, "%s: pch pic not aligned addr %llx len %d\n", __func__, addr, len);
 		return ret;
 	}
 
@@ -250,12 +250,12 @@ static int kvm_pch_pic_write(struct kvm_vcpu *vcpu,
 	struct loongarch_pch_pic *s = vcpu->kvm->arch.pch_pic;
 
 	if (!s) {
-		kvm_err("%s: pch pic irqchip not valid!\n", __func__);
+		WARN_ONCE(1, "%s: pch pic irqchip not valid!\n", __func__);
 		return ret;
 	}
 
 	if (addr & (len - 1)) {
-		kvm_err("%s: pch pic not aligned addr %llx len %d\n", __func__, addr, len);
+		WARN_ONCE(1, "%s: pch pic not aligned addr %llx len %d\n", __func__, addr, len);
 		return ret;
 	}
 
@@ -390,13 +390,13 @@ static int kvm_pch_pic_set_attr(struct kvm_device *dev,
 				return -EFAULT;
 
 			if (!dev->kvm->arch.pch_pic) {
-				kvm_err("%s: please create pch_pic irqchip first!\n", __func__);
+				WARN_ONCE(1, "%s: please create pch_pic irqchip first\n", __func__);
 				return -ENODEV;
 			}
 
 			return kvm_pch_pic_init(dev, addr);
 		default:
-			kvm_err("%s: unknown group (%d) attr (%lld)\n", __func__, attr->group,
+			WARN_ONCE(1, "%s: unknown group (%d) attr (%lld)\n", __func__, attr->group,
 					attr->attr);
 			return -EINVAL;
 		}
diff --git a/arch/loongarch/kvm/vcpu.c b/arch/loongarch/kvm/vcpu.c
index 20c207d80e31ae..265aaad6331572 100644
--- a/arch/loongarch/kvm/vcpu.c
+++ b/arch/loongarch/kvm/vcpu.c
@@ -1465,6 +1465,9 @@ int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu, struct kvm_interrupt *irq)
 	if (vector >= EXCCODE_INT_NUM)
 		return -EINVAL;
 
+	if (kvm_arch_irqchip_in_kernel(vcpu->kvm))
+		return -EINVAL;
+
 	if (!kvm_guest_has_msgint(&vcpu->arch) && (vector == INT_AVEC))
 		return -EINVAL;
 
@@ -1473,7 +1476,7 @@ int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu, struct kvm_interrupt *irq)
 	else if (intr < 0)
 		kvm_dequeue_irq(vcpu, -intr);
 	else {
-		kvm_err("%s: invalid interrupt ioctl %d\n", __func__, irq->irq);
+		WARN_ONCE(1, "%s: invalid interrupt ioctl %d\n", __func__, irq->irq);
 		return -EINVAL;
 	}
 

3/2 2026/06/29 02:52 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 10443
							output: 34
							thoughts: 1390
						

Thoughts:
**Analyzing the LoongArch KVM Interrupt Patch**

Okay, so I've got this patch that's been thrown my way, and it's making some pretty significant changes within the `arch/loongarch/kvm/` directory.  First observation: they've swapped out `kvm_err` for `WARN_ONCE(1, ...)` in a lot of places. That's a good initial clue - potentially indicating a shift from fatal error handling to more recoverable or debug-oriented warnings, a common refactor.

Now, let's dive into the core changes because this looks like interrupt handling got an overhaul. It's touching `dmsintc_deliver_msi_to_vcpu`, `eiointc_set_sw_coreisr`, `eiointc_update_irq`, `ipi_set`, `ipi_clear`, and, critically, `kvm_vcpu_ioctl_interrupt`.  Alright, let's step through them one by one.

Looking at `kvm_vcpu_ioctl_interrupt`, I see a new check: `if (kvm_arch_irqchip_in_kernel(vcpu->kvm)) return -EINVAL;`. This is interesting.  It's effectively disabling this path if the KVM interrupt controller is in kernel space, implying this particular ioctl is not the correct mechanism in that configuration. That's a key distinction and important context to understand. Also, I see the code is checking for `kvm_guest_has_msgint`, which is expected.

Moving on to `dmsintc_deliver_msi_to_vcpu`, it now directly uses `kvm_queue_irq` and `kvm_vcpu_kick` instead of calling `kvm_vcpu_ioctl_interrupt`. It also has the `kvm_guest_has_msgint` check. This is consistent with what I observed in the ioctl function. They are moving away from the ioctl path when an interrupt controller is in kernel space.

`eiointc_update_irq` is similar, using `kvm_queue_irq`, `kvm_dequeue_irq`, and `kvm_vcpu_kick`. Again, it replaces the original call to `kvm_vcpu_ioctl_interrupt` with direct queue manipulation.

Finally, in `ipi_set`, they've streamlined it. They now directly use `kvm_queue_irq`, `kvm_vcpu_kick` and improved the locking.

So, the pattern is clear: this patch is refactoring interrupt delivery.  The key change seems to be bypassing the `kvm_vcpu_ioctl_interrupt` path and using the direct queuing mechanism (`kvm_queue_irq`, `kvm_dequeue_irq`) when the interrupt controller is handled by the kernel. This is a crucial distinction.

Now, the question is, *can* this be reached? This is LoongArch KVM code.  It definitely requires a LoongArch host running KVM. I need to be sure the relevant configurations are enabled (`CONFIG_KVM` and `CONFIG_LOONGARCH`).  But my immediate concern is: Could this be tested on standard fuzzing environments? Since the code paths are guarded by the above config, it needs to run on a LoongArch host machine.



4/2 2026/06/29 02:53 tool grepper
0m Args:
{
  "Expression": "config KVM",
  "PathPrefix": "arch/loongarch/kvm/Kconfig"
}

Results:
{
  "Output": "arch/loongarch/kvm/Kconfig=18=if VIRTUALIZATION\narch/loongarch/kvm/Kconfig-19-\narch/loongarch/kvm/Kconfig:20:config KVM\narch/loongarch/kvm/Kconfig-21-\ttristate \"Kernel-based Virtual Machine (KVM) support\"\n"
}

5/2 2026/06/29 02:53 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 12699
							output: 33
							thoughts: 51
						

Thoughts:
Okay, let's see, the core here is clearly centered around `CONFIG_KVM`. That's the primary focus. I need to understand how the architecture interfaces with KVM.

Let's dive into the `arch/loongarch/kvm/Makefile`. That file should give me the crucial build information. I want to see how components like `exit.c`, `intc/dmsintc.c` and others are built, how they're incorporated into the overall KVM framework for LoongArch. The Makefile will reveal the dependencies and how the pieces fit together.



6/2 2026/06/29 02:53 tool grepper
0m Args:
{
  "Expression": "exit.o",
  "PathPrefix": "arch/loongarch/kvm/Makefile"
}

Results:
{
  "Output": "arch/loongarch/kvm/Makefile=10=obj-y += switch.o\narch/loongarch/kvm/Makefile-11-\narch/loongarch/kvm/Makefile:12:kvm-y += exit.o\narch/loongarch/kvm/Makefile-13-kvm-y += interrupt.o\n--\narch/loongarch/kvm/Makefile=24=kvm-y += irqfd.o\narch/loongarch/kvm/Makefile-25-\narch/loongarch/kvm/Makefile:26:CFLAGS_exit.o\t+= $(call cc-disable-warning, override-init)\n"
}

7/2 2026/06/29 02:53 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 13080
							output: 36
							thoughts: 33
						

Thoughts:
Okay, here's my interpretation of those thoughts, crafted with the understanding that I'm discussing this with a fellow expert:

**KVM Integration Analysis**

Alright, so the KVM module, I know it comes into play specifically when `CONFIG_KVM` is defined. This points me directly to the build configuration and I can infer that's the trigger. This is the first thing I'll confirm. But to get a more concrete understanding of its integration, I'll need to dig into the relevant source files. I'm thinking specifically about areas where the interrupt controller logic interacts with the virtualization layer. I need to understand how the interrupt mechanism is adapted for the KVM environment. I'll need to check the interrupt controller implementation, which is often crucial to understand how virtual machines deal with interrupts. I'll start with `intc/dmsintc.c`, and I'll likely need to broaden my search as I go, perhaps looking at other files in that directory or other related ones.



8/2 2026/06/29 02:53 tool grepper
0m Args:
{
  "Expression": "dmsintc.o",
  "PathPrefix": "arch/loongarch/kvm/Makefile"
}

Results:
{
  "Output": "arch/loongarch/kvm/Makefile=20=kvm-y += intc/ipi.o\narch/loongarch/kvm/Makefile:21:kvm-y += intc/dmsintc.o\narch/loongarch/kvm/Makefile-22-kvm-y += intc/eiointc.o\n"
}

9/2 2026/06/29 02:53 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 13457
							output: 42
							thoughts: 443
						

Thoughts:
**My Analysis of Interrupt Handling Functions**

Okay, so I've confirmed that `CONFIG_KVM` is the base configuration I need to be concerned with. Now, the real task is to figure out the critical functions that handle interrupts within the KVM framework. I need to zero in on the relevant code for my current analysis.

I've initially identified a set of functions that *seem* promising, and that I should analyze further. They are: `kvm_vcpu_ioctl_interrupt`, `dmsintc_deliver_msi_to_vcpu`, `eiointc_update_irq`, `ipi_set`, `ipi_clear`, `kvm_dmsintc_ctrl_access`, `kvm_eiointc_read`, `kvm_eiointc_write`, `kvm_eiointc_virt_read`, `kvm_eiointc_virt_write`, `kvm_eiointc_regs_access`, `kvm_eiointc_sw_status_access`, `kvm_ipi_regs_access`, `kvm_pch_pic_read`, `kvm_pch_pic_write`, and `kvm_pch_pic_set_attr`.

After a quick review, I think `kvm_vcpu_ioctl_interrupt` has the highest potential as a core symbol. It seems like it would be central to how interrupts are injected into a vCPU. In addition to this, I've selected `kvm_dmsintc_ctrl_access`, `kvm_eiointc_read`, `kvm_eiointc_write`, `kvm_ipi_regs_access`, `kvm_pch_pic_read`, and `kvm_pch_pic_write` as related functions that warrant further investigation.

I'm now going to focus on these selected functions: `kvm_vcpu_ioctl_interrupt`, `dmsintc_deliver_msi_to_vcpu`, `eiointc_update_irq`, `ipi_set`, `ipi_clear`, `kvm_eiointc_read`, `kvm_eiointc_write`, `kvm_ipi_regs_access`, `kvm_pch_pic_read`, and `kvm_pch_pic_write`.

My next step is to determine the visibility of `kvm_vcpu_ioctl_interrupt`. Is it a static function, or is it exported and available for use outside of its defining module? That'll give me a strong indication of where to focus my initial efforts.



10/2 2026/06/29 02:53 tool grepper
0m Args:
{
  "Expression": "kvm_vcpu_ioctl_interrupt",
  "PathPrefix": "arch/loongarch/kvm/vcpu.c"
}

Results:
{
  "Output": "arch/loongarch/kvm/vcpu.c=1425=void kvm_lose_fpu(struct kvm_vcpu *vcpu)\n--\narch/loongarch/kvm/vcpu.c-1459-\narch/loongarch/kvm/vcpu.c:1460:int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu, struct kvm_interrupt *irq)\narch/loongarch/kvm/vcpu.c-1461-{\n--\narch/loongarch/kvm/vcpu.c=1488=long kvm_arch_vcpu_unlocked_ioctl(struct file *filp, unsigned int ioctl,\n--\narch/loongarch/kvm/vcpu.c-1501-\narch/loongarch/kvm/vcpu.c:1502:\t\treturn kvm_vcpu_ioctl_interrupt(vcpu, \u0026irq);\narch/loongarch/kvm/vcpu.c-1503-\t}\n"
}

11/2 2026/06/29 02:53 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 14790
							output: 52
							thoughts: 38
						

Thoughts:
Okay, here's my take on those thoughts, tailored for an expert audience:

**Analyzing the ioctl Handler**

Right, an ioctl handler... that's usually a pretty good place to start digging. It's often the front door for external interactions with this module, and a great place to understand the intended behavior. My initial thought is to trace the execution flow and consider the implications of whatever actions this ioctl triggers.

Let's see... the most immediately relevant function called within it appears to be `dmsintc_deliver_msi_to_vcpu`. This is an interesting name. Sounds like this ioctl is designed to inject Message Signaled Interrupts (MSIs) to a virtual CPU (vCPU). I should examine that function very carefully, as MSIs are a critical part of how hardware interacts with the OS. It will likely detail how that MSI is constructed, how its target vCPU is selected, and how the injection itself is handled. This is likely the core functionality I need to understand.



12/2 2026/06/29 02:53 tool grepper
0m Args:
{
  "Expression": "dmsintc_deliver_msi_to_vcpu",
  "PathPrefix": "arch/loongarch/kvm/intc/dmsintc.c"
}

Results:
{
  "Output": "arch/loongarch/kvm/intc/dmsintc.c=11=void dmsintc_inject_irq(struct kvm_vcpu *vcpu)\n--\narch/loongarch/kvm/intc/dmsintc.c-46-\narch/loongarch/kvm/intc/dmsintc.c:47:int dmsintc_deliver_msi_to_vcpu(struct kvm *kvm,\narch/loongarch/kvm/intc/dmsintc.c-48-\t\t\t\tstruct kvm_vcpu *vcpu, u32 vector, int level)\n--\narch/loongarch/kvm/intc/dmsintc.c=69=int dmsintc_set_irq(struct kvm *kvm, u64 addr, int data, int level)\n--\narch/loongarch/kvm/intc/dmsintc.c-81-\narch/loongarch/kvm/intc/dmsintc.c:82:\treturn dmsintc_deliver_msi_to_vcpu(kvm, vcpu, irq, level);\narch/loongarch/kvm/intc/dmsintc.c-83-}\n"
}

13/2 2026/06/29 02:53 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 15418
							output: 47
							thoughts: 32
						

Thoughts:
Okay, here's my interpretation of those thoughts, framed as a first-person summary, keeping in mind my expertise:

**Checking the Interrupt Control Flow**

Alright, so the function in question here is `dmsintc_set_irq`. I need to figure out how this is interacting with the interrupt system. My immediate next step is to examine `eiointc_update_irq`. This likely holds the key to understanding how interrupts are actually enabled or disabled, or how their status is being handled at a lower level. Knowing how `dmsintc_set_irq` interfaces with the actual interrupt controller update function is crucial for understanding the overall interrupt flow. I need to see how the change in interrupt state that is set by `dmsintc_set_irq` is propagated and applied. I suspect a dependency, but I need to see the code to understand how it works.



14/2 2026/06/29 02:53 tool grepper
0m Args:
{
  "Expression": "eiointc_update_irq",
  "PathPrefix": "arch/loongarch/kvm/intc/eiointc.c"
}

Results:
{
  "Output": "arch/loongarch/kvm/intc/eiointc.c=10=static void eiointc_set_sw_coreisr(struct loongarch_eiointc *s)\n--\narch/loongarch/kvm/intc/eiointc.c-35-\narch/loongarch/kvm/intc/eiointc.c:36:static void eiointc_update_irq(struct loongarch_eiointc *s, int irq, int level)\narch/loongarch/kvm/intc/eiointc.c-37-{\n--\narch/loongarch/kvm/intc/eiointc.c=78=static inline void eiointc_update_sw_coremap(struct loongarch_eiointc *s,\n--\narch/loongarch/kvm/intc/eiointc.c-102-\t\t\t/* lower irq at old cpu and raise irq at new cpu */\narch/loongarch/kvm/intc/eiointc.c:103:\t\t\teiointc_update_irq(s, irq + i, 0);\narch/loongarch/kvm/intc/eiointc.c-104-\t\t\ts-\u003esw_coremap[irq + i] = cpu;\narch/loongarch/kvm/intc/eiointc.c:105:\t\t\teiointc_update_irq(s, irq + i, 1);\narch/loongarch/kvm/intc/eiointc.c-106-\t\t} else {\n--\narch/loongarch/kvm/intc/eiointc.c=112=void eiointc_set_irq(struct loongarch_eiointc *s, int irq, int level)\n--\narch/loongarch/kvm/intc/eiointc.c-118-\tlevel ? __set_bit(irq, isr) : __clear_bit(irq, isr);\narch/loongarch/kvm/intc/eiointc.c:119:\teiointc_update_irq(s, irq, level);\narch/loongarch/kvm/intc/eiointc.c-120-\tspin_unlock_irqrestore(\u0026s-\u003elock, flags);\n--\narch/loongarch/kvm/intc/eiointc.c=207=static int loongarch_eiointc_write(struct kvm_vcpu *vcpu,\n--\narch/loongarch/kvm/intc/eiointc.c-247-\t\t\tirq = __ffs(data);\narch/loongarch/kvm/intc/eiointc.c:248:\t\t\teiointc_update_irq(s, irq + index * 64, 1);\narch/loongarch/kvm/intc/eiointc.c-249-\t\t\tdata \u0026= ~BIT_ULL(irq);\n--\narch/loongarch/kvm/intc/eiointc.c-257-\t\t\tirq = __ffs(data);\narch/loongarch/kvm/intc/eiointc.c:258:\t\t\teiointc_update_irq(s, irq + index * 64, 0);\narch/loongarch/kvm/intc/eiointc.c-259-\t\t\tdata \u0026= ~BIT_ULL(irq);\n--\narch/loongarch/kvm/intc/eiointc.c-277-\t\t\tirq = __ffs(data);\narch/loongarch/kvm/intc/eiointc.c:278:\t\t\teiointc_update_irq(s, irq + index * 64, 0);\narch/loongarch/kvm/intc/eiointc.c-279-\t\t\tdata \u0026= ~BIT_ULL(irq);\n"
}

15/2 2026/06/29 02:53 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 16702
							output: 38
							thoughts: 43
						

Thoughts:
Okay, here's my take on those thoughts, framed as my own:

**Analyzing Interrupt Controller Interactions**

Alright, so `eiointc_set_irq` and `loongarch_eiointc_write` seem to be doing their jobs pretty well. They're both cleanly designed and performing their intended functions. Now, let's take a closer look at the inter-processor interrupt (IPI) mechanism, specifically `ipi_set` and `ipi_clear`. I need to understand how these functions interact with the interrupt controller setup, ensuring there aren't any race conditions or unintended consequences in how IPIs are signaled and acknowledged across the system. This seems like the logical next step in evaluating the overall interrupt management.



16/2 2026/06/29 02:53 tool grepper
0m Args:
{
  "Expression": "ipi_set",
  "PathPrefix": "arch/loongarch/kvm/intc/ipi.c"
}

Results:
{
  "Output": "arch/loongarch/kvm/intc/ipi.c-9-\narch/loongarch/kvm/intc/ipi.c:10:static void ipi_set(struct kvm_vcpu *vcpu, uint32_t data)\narch/loongarch/kvm/intc/ipi.c-11-{\n--\narch/loongarch/kvm/intc/ipi.c=24=static void ipi_send(struct kvm *kvm, uint64_t data)\n--\narch/loongarch/kvm/intc/ipi.c-35-\narch/loongarch/kvm/intc/ipi.c:36:\tipi_set(vcpu, BIT(data \u0026 0x1f));\narch/loongarch/kvm/intc/ipi.c-37-}\n--\narch/loongarch/kvm/intc/ipi.c=216=static int loongarch_ipi_writel(struct kvm_vcpu *vcpu, gpa_t addr, int len, const void *val)\n--\narch/loongarch/kvm/intc/ipi.c-234-\tcase IOCSR_IPI_SET:\narch/loongarch/kvm/intc/ipi.c:235:\t\tipi_set(vcpu, data);\narch/loongarch/kvm/intc/ipi.c-236-\t\tbreak;\n--\narch/loongarch/kvm/intc/ipi.c=363=static int kvm_ipi_get_attr(struct kvm_device *dev,\n--\narch/loongarch/kvm/intc/ipi.c-374-\narch/loongarch/kvm/intc/ipi.c:375:static int kvm_ipi_set_attr(struct kvm_device *dev,\narch/loongarch/kvm/intc/ipi.c-376-\t\t\tstruct kvm_device_attr *attr)\n--\narch/loongarch/kvm/intc/ipi.c=450=static struct kvm_device_ops kvm_ipi_dev_ops = {\n--\narch/loongarch/kvm/intc/ipi.c-453-\t.destroy = kvm_ipi_destroy,\narch/loongarch/kvm/intc/ipi.c:454:\t.set_attr = kvm_ipi_set_attr,\narch/loongarch/kvm/intc/ipi.c-455-\t.get_attr = kvm_ipi_get_attr,\n"
}

17/2 2026/06/29 02:53 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 17589
							output: 47
							thoughts: 44
						

Thoughts:
Okay, here's my take on those thoughts, framed as an expert's self-reflection:

**Deep Dive on Inter-Processor Interrupts (IPIs) in the LoongArch Architecture**

Hmm, `loongarch_ipi_writel`... that's a solid starting point for getting a handle on the IPI mechanisms within this architecture. It's a natural function to focus on when tracing how IPIs are *written* or generated. I need to understand the write process.

My immediate next step, given the context of IPIs, should definitely be to look closely at the related functions that handle the *reading* and *writing* of the interrupt controller. Therefore, let's also take a look at both `kvm_eiointc_read` and `kvm_eiointc_write`. I suspect these will provide crucial insights into how the virtualized interrupt controller is managed. It makes sense to see how the kernel interacts with the hardware, especially in a KVM context. The interaction of these routines is key to understanding how IPIs are effectively handled across the system.



18/2 2026/06/29 02:53 tool grepper
0m Args:
{
  "Expression": "kvm_eiointc_read",
  "PathPrefix": "arch/loongarch/kvm/intc/eiointc.c"
}

Results:
{
  "Output": "arch/loongarch/kvm/intc/eiointc.c=123=static int loongarch_eiointc_read(struct kvm_vcpu *vcpu, struct loongarch_eiointc *s,\n--\narch/loongarch/kvm/intc/eiointc.c-163-\narch/loongarch/kvm/intc/eiointc.c:164:static int kvm_eiointc_read(struct kvm_vcpu *vcpu,\narch/loongarch/kvm/intc/eiointc.c-165-\t\t\tstruct kvm_io_device *dev,\n--\narch/loongarch/kvm/intc/eiointc.c=338=static const struct kvm_io_device_ops kvm_eiointc_ops = {\narch/loongarch/kvm/intc/eiointc.c:339:\t.read\t= kvm_eiointc_read,\narch/loongarch/kvm/intc/eiointc.c-340-\t.write\t= kvm_eiointc_write,\n"
}

19/2 2026/06/29 02:53 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 18222
							output: 45
							thoughts: 56
						

Thoughts:
Here's my summary, as the expert:

**Investigating Interrupt Controller Operations in KVM**

Okay, so I'm looking at how the I/O operations are handled within KVM. Specifically, I see that `kvm_eiointc_read` and `kvm_eiointc_write` have been registered as I/O device operations. This is good; that's the starting point. My next move is to understand the bigger picture. I need to see how these interrupt controller functions relate to other parts of the system. I'm going to quickly check how the Peripheral Component Hub (PCH) Programmable Interrupt Controller (PIC) operations are implemented. I'm going to look at the `kvm_pch_pic_read` and `kvm_pch_pic_write` functions next. I want to see if the architecture follows similar structures, or if there are interesting differences in the management of interrupts. Understanding these PIC accessors will give me context for any potential issues or optimizations I might identify.



20/2 2026/06/29 02:53 tool grepper
0m Args:
{
  "Expression": "kvm_pch_pic_read",
  "PathPrefix": "arch/loongarch/kvm/intc/pch_pic.c"
}

Results:
{
  "Output": "arch/loongarch/kvm/intc/pch_pic.c=86=static int loongarch_pch_pic_read(struct loongarch_pch_pic *s, gpa_t addr, int len, void *val)\n--\narch/loongarch/kvm/intc/pch_pic.c-145-\narch/loongarch/kvm/intc/pch_pic.c:146:static int kvm_pch_pic_read(struct kvm_vcpu *vcpu,\narch/loongarch/kvm/intc/pch_pic.c-147-\t\t\tstruct kvm_io_device *dev,\n--\narch/loongarch/kvm/intc/pch_pic.c=269=static const struct kvm_io_device_ops kvm_pch_pic_ops = {\narch/loongarch/kvm/intc/pch_pic.c:270:\t.read\t= kvm_pch_pic_read,\narch/loongarch/kvm/intc/pch_pic.c-271-\t.write\t= kvm_pch_pic_write,\n"
}

21/2 2026/06/29 02:53 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 18836
							output: 49
							thoughts: 179
						

Thoughts:
**Focusing on Interrupt Operations**

Okay, so I'm thinking about these operations, and it's clicking that they're all related to I/O device operations, which is important. This means the symbols I should be focusing on are the ones dealing with interrupt handling. Let's make a mental note of these: `kvm_vcpu_ioctl_interrupt`, `dmsintc_set_irq`, `loongarch_eiointc_write`, `loongarch_ipi_writel`, `kvm_eiointc_read`, `kvm_eiointc_write`, `kvm_pch_pic_read`, `kvm_pch_pic_write`, `kvm_dmsintc_set_attr`, `kvm_eiointc_set_attr`, `kvm_ipi_set_attr`, and `kvm_pch_pic_set_attr`. They seem to cover a range of interrupt controllers and methods.

Now, let's start by digging into `kvm_dmsintc_set_attr` and see what it's doing. Time to delve into the details.



22/2 2026/06/29 02:53 tool grepper
0m Args:
{
  "Expression": "kvm_dmsintc_set_attr",
  "PathPrefix": "arch/loongarch/kvm/intc/dmsintc.c"
}

Results:
{
  "Output": "arch/loongarch/kvm/intc/dmsintc.c=85=static int kvm_dmsintc_ctrl_access(struct kvm_device *dev,\n--\narch/loongarch/kvm/intc/dmsintc.c-124-\narch/loongarch/kvm/intc/dmsintc.c:125:static int kvm_dmsintc_set_attr(struct kvm_device *dev,\narch/loongarch/kvm/intc/dmsintc.c-126-\t\t\t\tstruct kvm_device_attr *attr)\n--\narch/loongarch/kvm/intc/dmsintc.c=173=static struct kvm_device_ops kvm_dmsintc_dev_ops = {\n--\narch/loongarch/kvm/intc/dmsintc.c-176-\t.destroy = kvm_dmsintc_destroy,\narch/loongarch/kvm/intc/dmsintc.c:177:\t.set_attr = kvm_dmsintc_set_attr,\narch/loongarch/kvm/intc/dmsintc.c-178-};\n"
}

23/2 2026/06/29 02:53 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 19636
							output: 34
							thoughts: 240
						

Thoughts:
**Refining the Fuzzing Focus**

Okay, so these are solid starting points for the fuzzing campaign. We have a good list of functions to target.

Now, let's refine the list of focus symbols. I'm thinking we should zero in on:

*   `kvm_vcpu_ioctl_interrupt`
*   `kvm_dmsintc_set_attr`
*   `kvm_eiointc_set_attr`
*   `kvm_ipi_set_attr`
*   `kvm_pch_pic_set_attr`
*   `kvm_eiointc_read`
*   `kvm_eiointc_write`
*   `kvm_pch_pic_read`
*   `kvm_pch_pic_write`
*   `loongarch_ipi_writel`
*   `loongarch_eiointc_write`

Next, I need to make sure we have the correct configuration set. Clearly, we need `CONFIG_KVM` enabled, that's a no-brainer. Hold on a second, we're targeting LoongArch, but we don't need to specify `CONFIG_LOONGARCH` explicitly, as it's implied by the path. However, it's probably prudent to include `CONFIG_KVM` to make sure KVM is definitely enabled.

Let's do a quick scan to make sure we haven't missed any other crucial configurations that might impact the fuzzing setup.



24/2 2026/06/29 02:53 tool grepper
0m Args:
{
  "Expression": "config KVM",
  "PathPrefix": "arch/loongarch/kvm/Kconfig"
}

Results:
{
  "Output": "arch/loongarch/kvm/Kconfig=18=if VIRTUALIZATION\narch/loongarch/kvm/Kconfig-19-\narch/loongarch/kvm/Kconfig:20:config KVM\narch/loongarch/kvm/Kconfig-21-\ttristate \"Kernel-based Virtual Machine (KVM) support\"\n"
}

25/2 2026/06/29 02:53 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 20350
							output: 258
							thoughts: 968
						

Thoughts:
**KVM Code Review and Prioritization for Fuzzing**

Alright, KVM is the only hypervisor in question here, so let's get down to brass tacks. I'm reviewing these changes, and it's clear the patch is swapping out `kvm_err` with `WARN_ONCE(1, ...)` in a comprehensive list of functions. We're talking about a significant number of core KVM components, including:

*   Interrupt handling (`kvm_complete_iocsr_read`, `kvm_trap_handle_gspr`, and a whole slew of `kvm_dmsintc`, `kvm_eiointc`, `kvm_ipi`, and `kvm_pch_pic` functions).
*   MMIO and memory emulation (`kvm_emu_mmio_read`, `kvm_complete_mmio_read`, `kvm_emu_mmio_write`, `kvm_fault_ni`).
*   Even `ipi_send`, `read_mailbox`, and `write_mailbox` are impacted, indicating potential inter-VM communication effects.

Additionally, `WARN_ON` is being converted to `WARN_ON_ONCE` in `kvm_handle_fpu_disabled`, which is a minor, but important change.

Crucially, there's a functional shift in how interrupts are queued, replacing direct calls to `kvm_vcpu_ioctl_interrupt` with `kvm_queue_irq` and `kvm_dequeue_irq` in several interrupt delivery paths, like `dmsintc_deliver_msi_to_vcpu`, `eiointc_set_sw_coreisr`, `eiointc_update_irq`, `ipi_set`, and `ipi_clear`. The new logic adds a specific `-EINVAL` return if `kvm_arch_irqchip_in_kernel(vcpu->kvm)` is true within `kvm_vcpu_ioctl_interrupt`.

This interrupt queueing change, and the conditional return, is precisely the kind of thing that screams "fuzz me!" – it's ripe for uncovering potential race conditions or unexpected behavior due to the different interrupt handling paths.

I've identified the following as focus symbols for fuzzing:
`kvm_vcpu_ioctl_interrupt`
`kvm_dmsintc_set_attr`
`kvm_eiointc_set_attr`
`kvm_ipi_set_attr`
`kvm_pch_pic_set_attr`
`kvm_eiointc_read`
`kvm_eiointc_write`
`kvm_pch_pic_read`
`kvm_pch_pic_write`
`loongarch_ipi_writel`
`loongarch_eiointc_write`
`kvm_complete_iocsr_read`
`kvm_trap_handle_gspr`
`kvm_emu_mmio_read`
`kvm_complete_mmio_read`
`kvm_emu_mmio_write`
`kvm_fault_ni`

After evaluating them, I’ll focus the initial fuzzing campaign on these key functions:
`kvm_vcpu_ioctl_interrupt`
`kvm_eiointc_write`
`kvm_pch_pic_write`
`loongarch_ipi_writel`
`kvm_emu_mmio_write`
`kvm_dmsintc_set_attr`
`kvm_eiointc_set_attr`
`kvm_ipi_set_attr`
`kvm_pch_pic_set_attr`

I'll set the fuzzing results now.



26/2 2026/06/29 02:53 tool set-results
0m Args:
{
  "EnableConfigs": [
    "KVM"
  ],
  "FocusSymbols": [
    "kvm_vcpu_ioctl_interrupt",
    "kvm_eiointc_write",
    "kvm_pch_pic_write",
    "loongarch_ipi_writel",
    "kvm_emu_mmio_write",
    "kvm_dmsintc_set_attr",
    "kvm_eiointc_set_attr",
    "kvm_ipi_set_attr",
    "kvm_pch_pic_set_attr"
  ],
  "Reasoning": "The patch makes functional changes to LoongArch KVM interrupt handling. It modifies `kvm_vcpu_ioctl_interrupt` to return `-EINVAL` if an in-kernel irqchip is used, and updates internal callers to use `kvm_queue_irq` and `kvm_dequeue_irq` directly. It also replaces numerous `kvm_err` calls with `WARN_ONCE` across various KVM exit and interrupt controller handlers. These changes affect reachable core KVM logic and should be fuzzed.",
  "WorthFuzzing": true
}

Results:
{
  "EnableConfigs": [
    "KVM"
  ],
  "FocusSymbols": [
    "kvm_vcpu_ioctl_interrupt",
    "kvm_eiointc_write",
    "kvm_pch_pic_write",
    "loongarch_ipi_writel",
    "kvm_emu_mmio_write",
    "kvm_dmsintc_set_attr",
    "kvm_eiointc_set_attr",
    "kvm_ipi_set_attr",
    "kvm_pch_pic_set_attr"
  ],
  "Reasoning": "The patch makes functional changes to LoongArch KVM interrupt handling. It modifies `kvm_vcpu_ioctl_interrupt` to return `-EINVAL` if an in-kernel irqchip is used, and updates internal callers to use `kvm_queue_irq` and `kvm_dequeue_irq` directly. It also replaces numerous `kvm_err` calls with `WARN_ONCE` across various KVM exit and interrupt controller handlers. These changes affect reachable core KVM logic and should be fuzzed.",
  "WorthFuzzing": true
}

LLM Calls Summary:
Total Calls Total Tokens Avg Tokens Total Duration (Seconds) Avg Duration (Seconds)
Tool Calls Summary:
Total Calls Total Duration (Seconds) Avg Duration (Seconds)