mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-26 20:03:54 -06:00
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é <philmd@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20250123234415.59850-21-philmd@linaro.org>
This commit is contained in:
parent
ca05578fc8
commit
43610f3184
2 changed files with 26 additions and 29 deletions
29
cpu-target.c
29
cpu-target.c
|
@ -25,38 +25,9 @@
|
||||||
#include "system/cpus.h"
|
#include "system/cpus.h"
|
||||||
#include "exec/tswap.h"
|
#include "exec/tswap.h"
|
||||||
#include "exec/replay-core.h"
|
#include "exec/replay-core.h"
|
||||||
#include "exec/cpu-common.h"
|
|
||||||
#include "exec/log.h"
|
#include "exec/log.h"
|
||||||
#include "accel/accel-cpu-target.h"
|
#include "accel/accel-cpu-target.h"
|
||||||
#include "trace/trace-root.h"
|
#include "trace/trace-root.h"
|
||||||
#include "qemu/accel.h"
|
|
||||||
#include "hw/core/cpu.h"
|
|
||||||
|
|
||||||
bool cpu_exec_realizefn(CPUState *cpu, Error **errp)
|
|
||||||
{
|
|
||||||
if (!accel_cpu_common_realize(cpu, errp)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Wait until cpu initialization complete before exposing cpu. */
|
|
||||||
cpu_list_add(cpu);
|
|
||||||
|
|
||||||
cpu_vmstate_register(cpu);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void cpu_exec_unrealizefn(CPUState *cpu)
|
|
||||||
{
|
|
||||||
cpu_vmstate_unregister(cpu);
|
|
||||||
|
|
||||||
cpu_list_remove(cpu);
|
|
||||||
/*
|
|
||||||
* Now that the vCPU has been removed from the RCU list, we can call
|
|
||||||
* accel_cpu_common_unrealize, which may free fields using call_rcu.
|
|
||||||
*/
|
|
||||||
accel_cpu_common_unrealize(cpu);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *cpu_model_from_type(const char *typename)
|
char *cpu_model_from_type(const char *typename)
|
||||||
{
|
{
|
||||||
|
|
|
@ -193,6 +193,20 @@ static void cpu_common_parse_features(const char *typename, char *features,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool cpu_exec_realizefn(CPUState *cpu, Error **errp)
|
||||||
|
{
|
||||||
|
if (!accel_cpu_common_realize(cpu, errp)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wait until cpu initialization complete before exposing cpu. */
|
||||||
|
cpu_list_add(cpu);
|
||||||
|
|
||||||
|
cpu_vmstate_register(cpu);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static void cpu_common_realizefn(DeviceState *dev, Error **errp)
|
static void cpu_common_realizefn(DeviceState *dev, Error **errp)
|
||||||
{
|
{
|
||||||
CPUState *cpu = CPU(dev);
|
CPUState *cpu = CPU(dev);
|
||||||
|
@ -234,6 +248,18 @@ static void cpu_common_unrealizefn(DeviceState *dev)
|
||||||
cpu_exec_unrealizefn(cpu);
|
cpu_exec_unrealizefn(cpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cpu_exec_unrealizefn(CPUState *cpu)
|
||||||
|
{
|
||||||
|
cpu_vmstate_unregister(cpu);
|
||||||
|
|
||||||
|
cpu_list_remove(cpu);
|
||||||
|
/*
|
||||||
|
* Now that the vCPU has been removed from the RCU list, we can call
|
||||||
|
* accel_cpu_common_unrealize, which may free fields using call_rcu.
|
||||||
|
*/
|
||||||
|
accel_cpu_common_unrealize(cpu);
|
||||||
|
}
|
||||||
|
|
||||||
static void cpu_common_initfn(Object *obj)
|
static void cpu_common_initfn(Object *obj)
|
||||||
{
|
{
|
||||||
CPUState *cpu = CPU(obj);
|
CPUState *cpu = CPU(obj);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue