On 2025/7/23 上午9:40, Song Gao wrote:
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;
Can we use another variable since cpu is used in loop sentence already?
     for (cpu = 0; cpu < ipi->num_cpu; cpu++)
Here modification with cpu will change loop sentence flow.

Or direct use attr = (core->cpu->cpu_index << 16) | CORE_STATUS_OFF;

Regards
Bibo Mao
+
          attr = (cpu << 16) | CORE_STATUS_OFF;
          kvm_ipi_access_reg(fd, attr, &core->status, write);


Reply via email to