在 2025/7/25 下午3:22, Philippe Mathieu-Daudé 写道:
On 25/7/25 03:25, 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
logical CPU ID
for kvm_ipi_access_regs and do some check. On KVM use
kvm_get_vcpu_by_id() get vcpu.
Hi,
Sorry
this patch not fix this problem ,
This patch just fix qemu start fail with smp cpu < smp maxcpus on KVM.
e.g '-smp 1,maxcpus=4,sockets=4,cores=1,threads=1'
I 'll send a new patch,
Thanks.
Song Gao.
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;
While here, we could rename s/cpu/cpu_index/,>
if (fd == 0) {
return;
}
- for (cpu = 0; cpu < ipi->num_cpu; cpu++) {
and declare @i here: for (int i = 0; ...).
- 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);