QEMU reboot after inserting no-configuous cpus may start failed becaue the vcpu context may not have created on KVM, On QEMU side use logical CPU ID for kvm_ipi_access_regs and do some check. On KVM use kvm_get_vcpu_by_id() get vcpu.
Signed-off-by: Song Gao <gaos...@loongson.cn> --- hw/intc/loongarch_ipi_kvm.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/hw/intc/loongarch_ipi_kvm.c b/hw/intc/loongarch_ipi_kvm.c index 4cb3acc921..d0a2f2343f 100644 --- a/hw/intc/loongarch_ipi_kvm.c +++ b/hw/intc/loongarch_ipi_kvm.c @@ -23,14 +23,19 @@ static void kvm_ipi_access_regs(void *opaque, bool write) LoongarchIPIState *lis = LOONGARCH_IPI(opaque); IPICore *core; uint64_t attr; - int cpu, fd = lis->dev_fd; + int i, cpu, fd = lis->dev_fd; if (fd == 0) { return; } - for (cpu = 0; cpu < ipi->num_cpu; cpu++) { - core = &ipi->cpu[cpu]; + for (i = 0; i < ipi->num_cpu; i++) { + core = &ipi->cpu[i]; + if (core == NULL || core->cpu == NULL) { + continue; + } + cpu = core->cpu->cpu_index; + attr = (cpu << 16) | CORE_STATUS_OFF; kvm_ipi_access_reg(fd, attr, &core->status, write); -- 2.43.0