mirror of https://github.com/xqemu/xqemu.git
exec: call cpu_exec_exit() from a CPU unrealize common function
As cpu_exec_exit() mirrors the cpu_exec_realizefn(), rename it as cpu_exec_unrealizefn(). Create and register a cpu_common_unrealizefn() function for the CPU device class and call cpu_exec_unrealizefn() from this function. Remove cpu_exec_exit() from cpu_common_finalize() (which mirrors init, not realize), and as x86_cpu_unrealizefn() and ppc_cpu_unrealizefn() overwrite the device class unrealize function, add a call to a parent_unrealize pointer. Signed-off-by: Laurent Vivier <lvivier@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
This commit is contained in:
parent
ce5b1bbf62
commit
7bbc124e7e
2
exec.c
2
exec.c
|
@ -596,7 +596,7 @@ AddressSpace *cpu_get_address_space(CPUState *cpu, int asidx)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void cpu_exec_exit(CPUState *cpu)
|
void cpu_exec_unrealizefn(CPUState *cpu)
|
||||||
{
|
{
|
||||||
CPUClass *cc = CPU_GET_CLASS(cpu);
|
CPUClass *cc = CPU_GET_CLASS(cpu);
|
||||||
|
|
||||||
|
|
|
@ -948,7 +948,7 @@ void QEMU_NORETURN cpu_abort(CPUState *cpu, const char *fmt, ...)
|
||||||
GCC_FMT_ATTR(2, 3);
|
GCC_FMT_ATTR(2, 3);
|
||||||
void cpu_exec_initfn(CPUState *cpu);
|
void cpu_exec_initfn(CPUState *cpu);
|
||||||
void cpu_exec_realizefn(CPUState *cpu, Error **errp);
|
void cpu_exec_realizefn(CPUState *cpu, Error **errp);
|
||||||
void cpu_exec_exit(CPUState *cpu);
|
void cpu_exec_unrealizefn(CPUState *cpu);
|
||||||
|
|
||||||
#ifdef CONFIG_SOFTMMU
|
#ifdef CONFIG_SOFTMMU
|
||||||
extern const struct VMStateDescription vmstate_cpu_common;
|
extern const struct VMStateDescription vmstate_cpu_common;
|
||||||
|
|
|
@ -345,6 +345,12 @@ static void cpu_common_realizefn(DeviceState *dev, Error **errp)
|
||||||
trace_init_vcpu(cpu);
|
trace_init_vcpu(cpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void cpu_common_unrealizefn(DeviceState *dev, Error **errp)
|
||||||
|
{
|
||||||
|
CPUState *cpu = CPU(dev);
|
||||||
|
cpu_exec_unrealizefn(cpu);
|
||||||
|
}
|
||||||
|
|
||||||
static void cpu_common_initfn(Object *obj)
|
static void cpu_common_initfn(Object *obj)
|
||||||
{
|
{
|
||||||
CPUState *cpu = CPU(obj);
|
CPUState *cpu = CPU(obj);
|
||||||
|
@ -369,7 +375,6 @@ static void cpu_common_initfn(Object *obj)
|
||||||
static void cpu_common_finalize(Object *obj)
|
static void cpu_common_finalize(Object *obj)
|
||||||
{
|
{
|
||||||
CPUState *cpu = CPU(obj);
|
CPUState *cpu = CPU(obj);
|
||||||
cpu_exec_exit(cpu);
|
|
||||||
g_free(cpu->trace_dstate);
|
g_free(cpu->trace_dstate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -403,6 +408,7 @@ static void cpu_class_init(ObjectClass *klass, void *data)
|
||||||
k->cpu_exec_exit = cpu_common_noop;
|
k->cpu_exec_exit = cpu_common_noop;
|
||||||
k->cpu_exec_interrupt = cpu_common_exec_interrupt;
|
k->cpu_exec_interrupt = cpu_common_exec_interrupt;
|
||||||
dc->realize = cpu_common_realizefn;
|
dc->realize = cpu_common_realizefn;
|
||||||
|
dc->unrealize = cpu_common_unrealizefn;
|
||||||
/*
|
/*
|
||||||
* Reason: CPUs still need special care by board code: wiring up
|
* Reason: CPUs still need special care by board code: wiring up
|
||||||
* IRQs, adding reset handlers, halting non-first CPUs, ...
|
* IRQs, adding reset handlers, halting non-first CPUs, ...
|
||||||
|
|
|
@ -68,6 +68,7 @@ typedef struct X86CPUClass {
|
||||||
const char *model_description;
|
const char *model_description;
|
||||||
|
|
||||||
DeviceRealize parent_realize;
|
DeviceRealize parent_realize;
|
||||||
|
DeviceUnrealize parent_unrealize;
|
||||||
void (*parent_reset)(CPUState *cpu);
|
void (*parent_reset)(CPUState *cpu);
|
||||||
} X86CPUClass;
|
} X86CPUClass;
|
||||||
|
|
||||||
|
|
|
@ -3356,6 +3356,8 @@ out:
|
||||||
static void x86_cpu_unrealizefn(DeviceState *dev, Error **errp)
|
static void x86_cpu_unrealizefn(DeviceState *dev, Error **errp)
|
||||||
{
|
{
|
||||||
X86CPU *cpu = X86_CPU(dev);
|
X86CPU *cpu = X86_CPU(dev);
|
||||||
|
X86CPUClass *xcc = X86_CPU_GET_CLASS(dev);
|
||||||
|
Error *local_err = NULL;
|
||||||
|
|
||||||
#ifndef CONFIG_USER_ONLY
|
#ifndef CONFIG_USER_ONLY
|
||||||
cpu_remove_sync(CPU(dev));
|
cpu_remove_sync(CPU(dev));
|
||||||
|
@ -3366,6 +3368,12 @@ static void x86_cpu_unrealizefn(DeviceState *dev, Error **errp)
|
||||||
object_unparent(OBJECT(cpu->apic_state));
|
object_unparent(OBJECT(cpu->apic_state));
|
||||||
cpu->apic_state = NULL;
|
cpu->apic_state = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xcc->parent_unrealize(dev, &local_err);
|
||||||
|
if (local_err != NULL) {
|
||||||
|
error_propagate(errp, local_err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct BitProperty {
|
typedef struct BitProperty {
|
||||||
|
@ -3640,6 +3648,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
|
||||||
DeviceClass *dc = DEVICE_CLASS(oc);
|
DeviceClass *dc = DEVICE_CLASS(oc);
|
||||||
|
|
||||||
xcc->parent_realize = dc->realize;
|
xcc->parent_realize = dc->realize;
|
||||||
|
xcc->parent_unrealize = dc->unrealize;
|
||||||
dc->realize = x86_cpu_realizefn;
|
dc->realize = x86_cpu_realizefn;
|
||||||
dc->unrealize = x86_cpu_unrealizefn;
|
dc->unrealize = x86_cpu_unrealizefn;
|
||||||
dc->props = x86_cpu_properties;
|
dc->props = x86_cpu_properties;
|
||||||
|
|
|
@ -174,6 +174,7 @@ typedef struct PowerPCCPUClass {
|
||||||
/*< public >*/
|
/*< public >*/
|
||||||
|
|
||||||
DeviceRealize parent_realize;
|
DeviceRealize parent_realize;
|
||||||
|
DeviceUnrealize parent_unrealize;
|
||||||
void (*parent_reset)(CPUState *cpu);
|
void (*parent_reset)(CPUState *cpu);
|
||||||
|
|
||||||
uint32_t pvr;
|
uint32_t pvr;
|
||||||
|
|
|
@ -9906,11 +9906,17 @@ static void ppc_cpu_realizefn(DeviceState *dev, Error **errp)
|
||||||
static void ppc_cpu_unrealizefn(DeviceState *dev, Error **errp)
|
static void ppc_cpu_unrealizefn(DeviceState *dev, Error **errp)
|
||||||
{
|
{
|
||||||
PowerPCCPU *cpu = POWERPC_CPU(dev);
|
PowerPCCPU *cpu = POWERPC_CPU(dev);
|
||||||
|
PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
|
||||||
CPUPPCState *env = &cpu->env;
|
CPUPPCState *env = &cpu->env;
|
||||||
|
Error *local_err = NULL;
|
||||||
opc_handler_t **table, **table_2;
|
opc_handler_t **table, **table_2;
|
||||||
int i, j, k;
|
int i, j, k;
|
||||||
|
|
||||||
cpu_exec_exit(CPU(dev));
|
pcc->parent_unrealize(dev, &local_err);
|
||||||
|
if (local_err != NULL) {
|
||||||
|
error_propagate(errp, local_err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < PPC_CPU_OPCODES_LEN; i++) {
|
for (i = 0; i < PPC_CPU_OPCODES_LEN; i++) {
|
||||||
if (env->opcodes[i] == &invalid_handler) {
|
if (env->opcodes[i] == &invalid_handler) {
|
||||||
|
@ -10521,6 +10527,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data)
|
||||||
DeviceClass *dc = DEVICE_CLASS(oc);
|
DeviceClass *dc = DEVICE_CLASS(oc);
|
||||||
|
|
||||||
pcc->parent_realize = dc->realize;
|
pcc->parent_realize = dc->realize;
|
||||||
|
pcc->parent_unrealize = dc->unrealize;
|
||||||
pcc->pvr_match = ppc_pvr_match_default;
|
pcc->pvr_match = ppc_pvr_match_default;
|
||||||
pcc->interrupts_big_endian = ppc_cpu_interrupts_big_endian_always;
|
pcc->interrupts_big_endian = ppc_cpu_interrupts_big_endian_always;
|
||||||
dc->realize = ppc_cpu_realizefn;
|
dc->realize = ppc_cpu_realizefn;
|
||||||
|
|
Loading…
Reference in New Issue