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>
Philippe Mathieu-Daudé committed
Aug 10, 2026 at 16:48 UTC
398913c47b334d174f235983e002a4bdf6d3d409
4 files changed
+33
-24
hw/core/cpu-common.c
-24
@@ -33,7 +33,6 @@
33
#include "exec/log.h"
34
#include "exec/gdbstub.h"
35
#include "system/tcg.h"
36
-#include "hw/core/boards.h"
36
#include "hw/core/qdev-properties.h"
37
#include "trace.h"
38
#ifdef CONFIG_PLUGIN
@@ -246,29 +245,6 @@ bool cpu_common_realize(CPUState *cpu, Error **errp)
245
return true;
246
}
247
249
-static void cpu_exec_realize(CPUState *cpu, Error **errp)
250
-{
251
- Object *machine = qdev_get_machine();
252
-
253
- /* qdev_get_machine() can return something that's not TYPE_MACHINE
254
- * if this is one of the user-only emulators; in that case there's
255
- * no need to check the ignore_memory_transaction_failures board flag.
256
- */
257
- if (object_dynamic_cast(machine, TYPE_MACHINE)) {
258
- MachineClass *mc = MACHINE_GET_CLASS(machine);
259
-
260
- if (mc) {
261
- cpu->ignore_memory_transaction_failures =
262
- mc->ignore_memory_transaction_failures;
263
- }
264
- }
265
-
266
- if (DEVICE(cpu)->hotplugged) {
267
- cpu_synchronize_post_init(cpu);
268
- cpu_resume(cpu);
269
- }
270
-}
271
-
248
static void cpu_common_realizefn(DeviceState *dev, Error **errp)
249
{
250
cpu_exec_realize(CPU(dev), errp);
hw/core/cpu-internal.h
+1
@@ -15,6 +15,7 @@ void cpu_class_init_props(DeviceClass *dc);
15
void cpu_exec_class_post_init(CPUClass *cc);
16
17
void cpu_exec_init(CPUState *cpu);
18
+void cpu_exec_realize(CPUState *cpu, Error **errp);
19
20
void cpu_vmstate_register(CPUState *cpu);
21
void cpu_vmstate_unregister(CPUState *cpu);
hw/core/cpu-system.c
+27
@@ -25,10 +25,12 @@
25
#include "exec/target_page.h"
26
#include "system/memory.h"
27
#include "qemu/target-info.h"
28
+#include "hw/core/boards.h"
29
#include "hw/core/qdev.h"
30
#include "hw/core/qdev-properties.h"
31
#include "hw/core/sysemu-cpu-ops.h"
32
#include "migration/vmstate.h"
33
+#include "system/hw_accel.h"
34
#include "system/tcg.h"
35
#include "cpu-internal.h"
36
@@ -221,6 +223,31 @@ static int cpu_common_pre_load(void *opaque)
223
return 0;
224
}
225
226
+void cpu_exec_realize(CPUState *cpu, Error **errp)
227
+{
228
+ Object *machine = qdev_get_machine();
229
+
230
+ /*
231
+ * qdev_get_machine() can return something that's not TYPE_MACHINE
232
+ * if this is one of the user-only emulators; in that case there's
233
+ * no need to check the ignore_memory_transaction_failures board flag.
234
+ */
235
+ if (object_dynamic_cast(machine, TYPE_MACHINE)) {
236
+ MachineClass *mc = MACHINE_GET_CLASS(machine);
237
+
238
+ if (mc) {
239
+ cpu->ignore_memory_transaction_failures =
240
+ mc->ignore_memory_transaction_failures;
241
+ }
242
+ }
243
+
244
+ if (DEVICE(cpu)->hotplugged) {
245
+ cpu_synchronize_post_init(cpu);
246
+ cpu_resume(cpu);
247
+ }
248
+
249
+}
250
+
251
static bool cpu_common_exception_index_needed(void *opaque)
252
{
253
CPUState *cpu = opaque;
hw/core/cpu-user.c
+5
@@ -38,6 +38,11 @@ void cpu_exec_init(CPUState *cpu)
38
/* nothing to do */
39
}
40
41
+void cpu_exec_realize(CPUState *cpu, Error **errp)
42
+{
43
+ /* nothing to do */
44
+}
45
+
46
void cpu_vmstate_register(CPUState *cpu)
47
{
48
assert(qdev_get_vmsd(DEVICE(cpu)) == NULL ||