Commit 398913c47b for qemu.org
commit 398913c47b334d174f235983e002a4bdf6d3d409
Author: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Date: Mon Aug 10 16:48:01 2026 +0200
hw/cpu: Move system-specific cpu_exec_realize() to cpu-system.c
Current cpu_exec_realize() body only contains system-mode
related code. Move that method out of cpu-common.c to
cpu-system.c, removing the system / machine mentions in
this common file. Add an empty stub for user-mode.
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20260811183410.22428-9-philmd@oss.qualcomm.com>
diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c
index cd7c8763cf..4f4c87f33a 100644
--- a/hw/core/cpu-common.c
+++ b/hw/core/cpu-common.c
@@ -33,7 +33,6 @@
#include "exec/log.h"
#include "exec/gdbstub.h"
#include "system/tcg.h"
-#include "hw/core/boards.h"
#include "hw/core/qdev-properties.h"
#include "trace.h"
#ifdef CONFIG_PLUGIN
@@ -246,29 +245,6 @@ bool cpu_common_realize(CPUState *cpu, Error **errp)
return true;
}
-static void cpu_exec_realize(CPUState *cpu, Error **errp)
-{
- Object *machine = qdev_get_machine();
-
- /* qdev_get_machine() can return something that's not TYPE_MACHINE
- * if this is one of the user-only emulators; in that case there's
- * no need to check the ignore_memory_transaction_failures board flag.
- */
- if (object_dynamic_cast(machine, TYPE_MACHINE)) {
- MachineClass *mc = MACHINE_GET_CLASS(machine);
-
- if (mc) {
- cpu->ignore_memory_transaction_failures =
- mc->ignore_memory_transaction_failures;
- }
- }
-
- if (DEVICE(cpu)->hotplugged) {
- cpu_synchronize_post_init(cpu);
- cpu_resume(cpu);
- }
-}
-
static void cpu_common_realizefn(DeviceState *dev, Error **errp)
{
cpu_exec_realize(CPU(dev), errp);
diff --git a/hw/core/cpu-internal.h b/hw/core/cpu-internal.h
index ae6a31bca2..44715b4432 100644
--- a/hw/core/cpu-internal.h
+++ b/hw/core/cpu-internal.h
@@ -15,6 +15,7 @@ void cpu_class_init_props(DeviceClass *dc);
void cpu_exec_class_post_init(CPUClass *cc);
void cpu_exec_init(CPUState *cpu);
+void cpu_exec_realize(CPUState *cpu, Error **errp);
void cpu_vmstate_register(CPUState *cpu);
void cpu_vmstate_unregister(CPUState *cpu);
diff --git a/hw/core/cpu-system.c b/hw/core/cpu-system.c
index 8a9f2fcea8..a64e8c2b68 100644
--- a/hw/core/cpu-system.c
+++ b/hw/core/cpu-system.c
@@ -25,10 +25,12 @@
#include "exec/target_page.h"
#include "system/memory.h"
#include "qemu/target-info.h"
+#include "hw/core/boards.h"
#include "hw/core/qdev.h"
#include "hw/core/qdev-properties.h"
#include "hw/core/sysemu-cpu-ops.h"
#include "migration/vmstate.h"
+#include "system/hw_accel.h"
#include "system/tcg.h"
#include "cpu-internal.h"
@@ -221,6 +223,31 @@ static int cpu_common_pre_load(void *opaque)
return 0;
}
+void cpu_exec_realize(CPUState *cpu, Error **errp)
+{
+ Object *machine = qdev_get_machine();
+
+ /*
+ * qdev_get_machine() can return something that's not TYPE_MACHINE
+ * if this is one of the user-only emulators; in that case there's
+ * no need to check the ignore_memory_transaction_failures board flag.
+ */
+ if (object_dynamic_cast(machine, TYPE_MACHINE)) {
+ MachineClass *mc = MACHINE_GET_CLASS(machine);
+
+ if (mc) {
+ cpu->ignore_memory_transaction_failures =
+ mc->ignore_memory_transaction_failures;
+ }
+ }
+
+ if (DEVICE(cpu)->hotplugged) {
+ cpu_synchronize_post_init(cpu);
+ cpu_resume(cpu);
+ }
+
+}
+
static bool cpu_common_exception_index_needed(void *opaque)
{
CPUState *cpu = opaque;
diff --git a/hw/core/cpu-user.c b/hw/core/cpu-user.c
index c2cb00a85d..1e38c88f9b 100644
--- a/hw/core/cpu-user.c
+++ b/hw/core/cpu-user.c
@@ -38,6 +38,11 @@ void cpu_exec_init(CPUState *cpu)
/* nothing to do */
}
+void cpu_exec_realize(CPUState *cpu, Error **errp)
+{
+ /* nothing to do */
+}
+
void cpu_vmstate_register(CPUState *cpu)
{
assert(qdev_get_vmsd(DEVICE(cpu)) == NULL ||