QEMU reboot after inserting no-configuous cpus may start failed
becaue the vcpu context may not have created on KVM, On QEMU side use physical 
CPU ID
for kvm_ipi_access_regs and do some check. On KVM use kvm_get_vcpu_by_cpuid get 
vcpu.

Signed-off-by: Song Gao <gaos...@loongson.cn>
---
 hw/intc/loongarch_ipi_kvm.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/hw/intc/loongarch_ipi_kvm.c b/hw/intc/loongarch_ipi_kvm.c
index 4cb3acc921..1c26fdcb10 100644
--- a/hw/intc/loongarch_ipi_kvm.c
+++ b/hw/intc/loongarch_ipi_kvm.c
@@ -31,6 +31,11 @@ static void kvm_ipi_access_regs(void *opaque, bool write)
 
     for (cpu = 0; cpu < ipi->num_cpu; cpu++) {
         core = &ipi->cpu[cpu];
+        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


Reply via email to