Skip to content

Commit 43610f3

Browse files
committed
cpus: Build cpu_exec_[un]realizefn() methods once
Now that cpu_exec_realizefn() and cpu_exec_unrealizefn() methods don't use any target specific definition anymore, we can move them to cpu-common.c to be able to build them once. Signed-off-by: Philippe Mathieu-Daudé <[email protected]> Reviewed-by: Richard Henderson <[email protected]> Message-Id: <[email protected]>
1 parent ca05578 commit 43610f3

File tree

2 files changed

+26
-29
lines changed

2 files changed

+26
-29
lines changed

cpu-target.c

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -25,38 +25,9 @@
2525
#include "system/cpus.h"
2626
#include "exec/tswap.h"
2727
#include "exec/replay-core.h"
28-
#include "exec/cpu-common.h"
2928
#include "exec/log.h"
3029
#include "accel/accel-cpu-target.h"
3130
#include "trace/trace-root.h"
32-
#include "qemu/accel.h"
33-
#include "hw/core/cpu.h"
34-
35-
bool cpu_exec_realizefn(CPUState *cpu, Error **errp)
36-
{
37-
if (!accel_cpu_common_realize(cpu, errp)) {
38-
return false;
39-
}
40-
41-
/* Wait until cpu initialization complete before exposing cpu. */
42-
cpu_list_add(cpu);
43-
44-
cpu_vmstate_register(cpu);
45-
46-
return true;
47-
}
48-
49-
void cpu_exec_unrealizefn(CPUState *cpu)
50-
{
51-
cpu_vmstate_unregister(cpu);
52-
53-
cpu_list_remove(cpu);
54-
/*
55-
* Now that the vCPU has been removed from the RCU list, we can call
56-
* accel_cpu_common_unrealize, which may free fields using call_rcu.
57-
*/
58-
accel_cpu_common_unrealize(cpu);
59-
}
6031

6132
char *cpu_model_from_type(const char *typename)
6233
{

hw/core/cpu-common.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,20 @@ static void cpu_common_parse_features(const char *typename, char *features,
193193
}
194194
}
195195

196+
bool cpu_exec_realizefn(CPUState *cpu, Error **errp)
197+
{
198+
if (!accel_cpu_common_realize(cpu, errp)) {
199+
return false;
200+
}
201+
202+
/* Wait until cpu initialization complete before exposing cpu. */
203+
cpu_list_add(cpu);
204+
205+
cpu_vmstate_register(cpu);
206+
207+
return true;
208+
}
209+
196210
static void cpu_common_realizefn(DeviceState *dev, Error **errp)
197211
{
198212
CPUState *cpu = CPU(dev);
@@ -234,6 +248,18 @@ static void cpu_common_unrealizefn(DeviceState *dev)
234248
cpu_exec_unrealizefn(cpu);
235249
}
236250

251+
void cpu_exec_unrealizefn(CPUState *cpu)
252+
{
253+
cpu_vmstate_unregister(cpu);
254+
255+
cpu_list_remove(cpu);
256+
/*
257+
* Now that the vCPU has been removed from the RCU list, we can call
258+
* accel_cpu_common_unrealize, which may free fields using call_rcu.
259+
*/
260+
accel_cpu_common_unrealize(cpu);
261+
}
262+
237263
static void cpu_common_initfn(Object *obj)
238264
{
239265
CPUState *cpu = CPU(obj);

0 commit comments

Comments
 (0)