hw/loongarch/virt: Register reset interface with cpu plug callback

With cpu hotplug is implemented on LoongArch virt machine, reset
interface with hot-added CPU should be registered. Otherwise there
will be problem if system reboots after cpu is hot-added.

Now register reset interface with CPU plug callback, so that all
cold/hot added CPUs let their reset interface registered. And remove
reset interface with CPU unplug callback.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Tested-by: Song Gao <gaosong@loongson.cn>
Message-ID: <20250906070200.3749326-4-maobibo@loongson.cn>
Signed-off-by: Song Gao <gaosong@loongson.cn>
This commit is contained in:
Bibo Mao
2025-09-18 17:39:57 +08:00
committed by Song Gao
parent 6ca2df47c9
commit cb5ee0017f
2 changed files with 2 additions and 13 deletions
-13
View File
@@ -350,13 +350,6 @@ static int64_t load_kernel_info(struct loongarch_boot_info *info)
return kernel_entry;
}
static void reset_load_elf(void *opaque)
{
LoongArchCPU *cpu = opaque;
cpu_reset(CPU(cpu));
}
static void fw_cfg_add_kernel_info(struct loongarch_boot_info *info,
FWCfgState *fw_cfg)
{
@@ -439,12 +432,6 @@ static void loongarch_direct_kernel_boot(MachineState *ms,
void loongarch_load_kernel(MachineState *ms, struct loongarch_boot_info *info)
{
LoongArchVirtMachineState *lvms = LOONGARCH_VIRT_MACHINE(ms);
int i;
/* register reset function */
for (i = 0; i < ms->smp.cpus; i++) {
qemu_register_reset(reset_load_elf, LOONGARCH_CPU(qemu_get_cpu(i)));
}
info->kernel_filename = ms->kernel_filename;
info->kernel_cmdline = ms->kernel_cmdline;
+2
View File
@@ -1014,6 +1014,7 @@ static void virt_cpu_unplug(HotplugHandler *hotplug_dev,
/* Notify acpi ged CPU removed */
hotplug_handler_unplug(HOTPLUG_HANDLER(lvms->acpi_ged), dev, &error_abort);
qemu_unregister_resettable(OBJECT(dev));
cpu_slot = virt_find_cpu_slot(MACHINE(lvms), cpu->phy_id);
cpu_slot->cpu = NULL;
}
@@ -1038,6 +1039,7 @@ static void virt_cpu_plug(HotplugHandler *hotplug_dev,
&error_abort);
}
qemu_register_resettable(OBJECT(dev));
cpu_slot = virt_find_cpu_slot(MACHINE(lvms), cpu->phy_id);
cpu_slot->cpu = CPU(dev);
}