summary refs log tree commit diff stats
path: root/target/loongarch/cpu.c
diff options
context:
space:
mode:
authorBibo Mao <maobibo@loongson.cn>2025-02-10 14:56:01 +0800
committerBibo Mao <maobibo@loongson.cn>2025-03-05 09:39:17 +0800
commit7bf633c53f66ea9b5666ed246de4122152910f54 (patch)
treeefdb4a9b6184919f5cc993002135989933f5c859 /target/loongarch/cpu.c
parentd32fde20bd334a9fa4efab95583bc596d01a39ea (diff)
downloadfocaccia-qemu-7bf633c53f66ea9b5666ed246de4122152910f54.tar.gz
focaccia-qemu-7bf633c53f66ea9b5666ed246de4122152910f54.zip
hw/loongarch/virt: Add basic cpu plug interface framework
Add basic cpu hotplug interface framework, cpu hotplug interface is
stub function and only framework is added here.

Co-developed-by: Xianglai Li <lixianglai@loongson.cn>
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Diffstat (limited to 'target/loongarch/cpu.c')
-rw-r--r--target/loongarch/cpu.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c
index df76ab66d5..8b99b8def4 100644
--- a/target/loongarch/cpu.c
+++ b/target/loongarch/cpu.c
@@ -647,6 +647,17 @@ static void loongarch_cpu_realizefn(DeviceState *dev, Error **errp)
     lacc->parent_realize(dev, errp);
 }
 
+static void loongarch_cpu_unrealizefn(DeviceState *dev)
+{
+    LoongArchCPUClass *lacc = LOONGARCH_CPU_GET_CLASS(dev);
+
+#ifndef CONFIG_USER_ONLY
+    cpu_remove_sync(CPU(dev));
+#endif
+
+    lacc->parent_unrealize(dev);
+}
+
 static bool loongarch_get_lsx(Object *obj, Error **errp)
 {
     return LOONGARCH_CPU(obj)->lsx != ON_OFF_AUTO_OFF;
@@ -897,6 +908,8 @@ static void loongarch_cpu_class_init(ObjectClass *c, void *data)
     device_class_set_props(dc, loongarch_cpu_properties);
     device_class_set_parent_realize(dc, loongarch_cpu_realizefn,
                                     &lacc->parent_realize);
+    device_class_set_parent_unrealize(dc, loongarch_cpu_unrealizefn,
+                                      &lacc->parent_unrealize);
     resettable_class_set_parent_phases(rc, NULL, loongarch_cpu_reset_hold, NULL,
                                        &lacc->parent_phases);