Split cpu_exec_init() into an init and a realize part
cover Split cpu_exec_init() into an init and a realize part
Since commit 42ecaba ("target-i386: Call cpu_exec_init() on realize"), , commit 6dd0f83 ("target-ppc: Move cpu_exec_init() call to realize function"), and commit c6644fc ("s390x/cpu: Get rid of side effects when creating a vcpu"), cpu_exec_init() has been moved to realize function for some architectures to implement CPU htoplug. This allows any failures from cpu_exec_init() to be handled appropriately.
This series tries to do the same work for all the other CPUs.
But as the ARM Virtual Machine ("virt") needs the "memory" property of the CPU in the machine init function (the "memory" property is created in cpu_exec_init() we want to move to the realize part), split cpu_exec_init() in two parts: a realize part (cpu_exec_realize(), adding the CPU in the environment) and an init part (cpu_exec_init(), initializing the CPU, like adding the "memory" property).
For target-i386, target-s390 and target-ppc, we move back the cpu_exec_init() into the init part, and put the cpu_exec_realize() into the realize part. For all the other CPUs, we add the cpu_exec_realize() function into the realize part.
This also allows to remove all the "cannot_destroy_with_object_finalize_yet" properties from the CPU device class.
Laurent Vivier (19):
exec: split cpu_exec_init()
target-i386: move back cpu_exec_init() to init
target-ppc: move back cpu_exec_init() to init
target-s390: move back cpu_exec_init() to init
target-arm: move cpu_exec_realize() to realize function
target-alpha: move cpu_exec_realize() to realize function
target-cris: move cpu_exec_realize() to realize function
target-lm32: move cpu_exec_realize() to realize function
target-m68k: move cpu_exec_realize() to realize function
target-microblaze: move cpu_exec_realize() to realize function
target-mips: move cpu_exec_realize() to realize function
target-moxie: move cpu_exec_realize() to realize function
target-openrisc: move cpu_exec_realize() to realize function
target-sh4: move cpu_exec_realize() to realize function
target-sparc: move cpu_exec_realize() to realize function
target-tilegx: move cpu_exec_realize() to realize function
target-tricore: move cpu_exec_realize() to realize function
target-unicore32: move cpu_exec_realize() to realize function
target-xtensa: move cpu_exec_realize() to realize function
exec.c | 8 +++++--- include/exec/exec-all.h | 1 + target-alpha/cpu.c | 14 +++++++------- target-arm/cpu.c | 18 +++++++----------- target-cris/cpu.c | 14 +++++++------- target-i386/cpu.c | 12 ++++++------ target-lm32/cpu.c | 14 +++++++------- target-m68k/cpu.c | 14 +++++++------- target-microblaze/cpu.c | 13 +++++++------ target-mips/cpu.c | 14 +++++++------- target-moxie/cpu.c | 14 +++++++------- target-openrisc/cpu.c | 14 +++++++------- target-ppc/translate_init.c | 3 ++- target-s390x/cpu.c | 9 ++------- target-sh4/cpu.c | 14 +++++++------- target-sparc/cpu.c | 17 +++++++++-------- target-tilegx/cpu.c | 14 +++++++------- target-tricore/cpu.c | 14 +++++++------- target-unicore32/cpu.c | 17 +++++++++-------- target-xtensa/cpu.c | 14 +++++++------- 20 files changed, 125 insertions(+), 127 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/19 exec: split cpu_exec_init()
Extract the realize part to cpu_exec_realize(), update all calls to cpu_exec_init() to add cpu_exec_realize() to have no functionnal change.
Put in cpu_exec_init() what initializes the CPU, in cpu_exec_realize() what adds it to the environment.
--- exec.c | 8 +++++--- include/exec/exec-all.h | 1 + target-alpha/cpu.c | 1 + target-arm/cpu.c | 1 + target-cris/cpu.c | 1 + target-i386/cpu.c | 1 + target-lm32/cpu.c | 1 + target-m68k/cpu.c | 1 + target-microblaze/cpu.c | 1 + target-mips/cpu.c | 1 + target-moxie/cpu.c | 1 + target-openrisc/cpu.c | 1 + target-ppc/translate_init.c | 5 +++++ target-s390x/cpu.c | 4 ++++ target-sh4/cpu.c | 1 + target-sparc/cpu.c | 1 + target-tilegx/cpu.c | 1 + target-tricore/cpu.c | 1 + target-unicore32/cpu.c | 1 + target-xtensa/cpu.c | 1 + 20 files changed, 31 insertions(+), 3 deletions(-)
exec.c +5 -3
@@ -614,9 +614,6 @@ void cpu_exec_exit(CPUState *cpu)void cpu_exec_init (CPUState *cpu,Error **errp) { - CPUClass *cc ATTRIBUTE_UNUSED = CPU_GET_CLASS(cpu); - Error *local_err ATTRIBUTE_UNUSED = NULL; - cpu->as =NULL ; cpu->num_ases =0 ;
@@ -637,6 +634,11 @@ void cpu_exec_init(CPUState *cpu, Error **errp) cpu->memory = system_memory;object_ref (OBJECT (cpu->memory));#endif +} + +void cpu_exec_realize (CPUState *cpu,Error **errp) +{ + CPUClass *cc ATTRIBUTE_UNUSED = CPU_GET_CLASS(cpu);cpu_list_add (cpu);
include/exec/exec-all.h +1 -0
@@ -58,6 +58,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, int cflags);void cpu_exec_init (CPUState *cpu,Error **errp); +void cpu_exec_realize (CPUState *cpu,Error **errp); void QEMU_NORETURN cpu_loop_exit(CPUState *cpu); void QEMU_NORETURN cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc);
target-alpha/cpu.c +1 -0
@@ -267,6 +267,7 @@ static void alpha_cpu_initfn(Object *obj) cs->env_ptr = env;cpu_exec_init (cs, &error_abort); +cpu_exec_realize (cs, &error_abort);tlb_flush (cs,1 );alpha_translate_init ();
target-arm/cpu.c +1 -0
@@ -445,6 +445,7 @@ static void arm_cpu_initfn(Object *obj) cs->env_ptr = &cpu->env;cpu_exec_init (cs, &error_abort); +cpu_exec_realize (cs, &error_abort); cpu->cp_regs =g_hash_table_new_full (g_int_hash, g_int_equal, g_free, g_free);
target-cris/cpu.c +1 -0
@@ -188,6 +188,7 @@ static void cris_cpu_initfn(Object *obj) cs->env_ptr = env;cpu_exec_init (cs, &error_abort); +cpu_exec_realize (cs, &error_abort); env->pregs[PR_VR ] = ccc->vr;
target-i386/cpu.c +1 -0
@@ -3159,6 +3159,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp) } }cpu_exec_init (cs, &error_abort); +cpu_exec_realize (cs, &error_abort);if (tcg_enabled ()) {tcg_x86_init ();
target-lm32/cpu.c +1 -0
@@ -161,6 +161,7 @@ static void lm32_cpu_initfn(Object *obj) cs->env_ptr = env;cpu_exec_init (cs, &error_abort); +cpu_exec_realize (cs, &error_abort); env->flags =0 ;
target-m68k/cpu.c +1 -0
@@ -177,6 +177,7 @@ static void m68k_cpu_initfn(Object *obj) cs->env_ptr = env;cpu_exec_init (cs, &error_abort); +cpu_exec_realize (cs, &error_abort);if (tcg_enabled () && !inited) { inited = true;
target-microblaze/cpu.c +1 -0
@@ -200,6 +200,7 @@ static void mb_cpu_initfn(Object *obj) cs->env_ptr = env;cpu_exec_init (cs, &error_abort); +cpu_exec_realize (cs, &error_abort);set_float_rounding_mode (float_round_nearest_even, &env->fp_status);
target-mips/cpu.c +1 -0
@@ -139,6 +139,7 @@ static void mips_cpu_initfn(Object *obj) cs->env_ptr = env;cpu_exec_init (cs, &error_abort); +cpu_exec_realize (cs, &error_abort);if (tcg_enabled ()) {mips_tcg_init ();
target-moxie/cpu.c +1 -0
@@ -76,6 +76,7 @@ static void moxie_cpu_initfn(Object *obj) cs->env_ptr = &cpu->env;cpu_exec_init (cs, &error_abort); +cpu_exec_realize (cs, &error_abort);if (tcg_enabled () && !inited) { inited =1 ;
target-openrisc/cpu.c +1 -0
@@ -96,6 +96,7 @@ static void openrisc_cpu_initfn(Object *obj) cs->env_ptr = &cpu->env;cpu_exec_init (cs, &error_abort); +cpu_exec_realize (cs, &error_abort);#ifndef CONFIG_USER_ONLY cpu_openrisc_mmu_init (cpu);
target-ppc/translate_init.c +5 -0
@@ -9683,6 +9683,11 @@ static void ppc_cpu_realizefn(DeviceState *dev, Error **errp)error_propagate (errp, local_err);return ; } +cpu_exec_realize (cs, &local_err); +if (local_err !=NULL ) { +error_propagate (errp, local_err); +return ; + }#if !defined(CONFIG_USER_ONLY ) cpu->cpu_dt_id = (cs->cpu_index / smp_threads) * max_smt
target-s390x/cpu.c +4 -0
@@ -211,6 +211,10 @@ static void s390_cpu_realizefn(DeviceState *dev, Error **errp)if (err !=NULL ) { goto out; } +cpu_exec_realize (cs, &err); +if (err !=NULL ) { + goto out; + } scc->next_cpu_id++;#if !defined(CONFIG_USER_ONLY )
target-sh4/cpu.c +1 -0
@@ -259,6 +259,7 @@ static void superh_cpu_initfn(Object *obj) cs->env_ptr = env;cpu_exec_init (cs, &error_abort); +cpu_exec_realize (cs, &error_abort); env->movcal_backup_tail = &(env->movcal_backup);
target-sparc/cpu.c +1 -0
@@ -815,6 +815,7 @@ static void sparc_cpu_initfn(Object *obj) cs->env_ptr = env;cpu_exec_init (cs, &error_abort); +cpu_exec_realize (cs, &error_abort);if (tcg_enabled ()) {gen_intermediate_code_init (env);
target-tilegx/cpu.c +1 -0
@@ -108,6 +108,7 @@ static void tilegx_cpu_initfn(Object *obj) cs->env_ptr = env;cpu_exec_init (cs, &error_abort); +cpu_exec_realize (cs, &error_abort);if (tcg_enabled () && !tcg_initialized) { tcg_initialized = true;
target-tricore/cpu.c +1 -0
@@ -96,6 +96,7 @@ static void tricore_cpu_initfn(Object *obj) cs->env_ptr = env;cpu_exec_init (cs, &error_abort); +cpu_exec_realize (cs, &error_abort);if (tcg_enabled ()) {tricore_tcg_init ();
target-unicore32/cpu.c +1 -0
@@ -117,6 +117,7 @@ static void uc32_cpu_initfn(Object *obj) cs->env_ptr = env;cpu_exec_init (cs, &error_abort); +cpu_exec_realize (cs, &error_abort);#ifdef CONFIG_USER_ONLY env->uncached_asr =ASR_MODE_USER ;
target-xtensa/cpu.c +1 -0
@@ -118,6 +118,7 @@ static void xtensa_cpu_initfn(Object *obj) cs->env_ptr = env; env->config = xcc->config;cpu_exec_init (cs, &error_abort); +cpu_exec_realize (cs, &error_abort);if (tcg_enabled () && !tcg_inited) { tcg_inited = true;
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH 01/19] exec: split cpu_exec_init()
Quoted 47 lines · Laurent Vivier
Extract the realize part to
cpu_exec_realize(), update all calls tocpu_exec_init()to addcpu_exec_realize()to have no functionnal change.Put in
cpu_exec_init()what initializes the CPU, incpu_exec_realize()what adds it to the environment.CC Paolo Bonzini <[email protected]>Signed-off-by Laurent Vivier <[email protected]>--- exec.c | 8 +++++--- include/exec/exec-all.h | 1 + target-alpha/cpu.c | 1 + target-arm/cpu.c | 1 + target-cris/cpu.c | 1 + target-i386/cpu.c | 1 + target-lm32/cpu.c | 1 + target-m68k/cpu.c | 1 + target-microblaze/cpu.c | 1 + target-mips/cpu.c | 1 + target-moxie/cpu.c | 1 + target-openrisc/cpu.c | 1 + target-ppc/translate_init.c | 5 +++++ target-s390x/cpu.c | 4 ++++ target-sh4/cpu.c | 1 + target-sparc/cpu.c | 1 + target-tilegx/cpu.c | 1 + target-tricore/cpu.c | 1 + target-unicore32/cpu.c | 1 + target-xtensa/cpu.c | 1 + 20 files changed, 31 insertions(+), 3 deletions(-)exec.c +0
-3@@ -614,9 +614,6 @@ void cpu_exec_exit(CPUState *cpu)void cpu_exec_init (CPUState *cpu,Error **errp) { - CPUClass *cc ATTRIBUTE_UNUSED = CPU_GET_CLASS(cpu); - Error *local_err ATTRIBUTE_UNUSED = NULL; - cpu->as =NULL ; cpu->num_ases =0 ;
exec.c void cpu_exec_init(CPUState *cpu, Error **errp) · line 643
Quoted 10 lines
exec.c +5
-0@@ -637,6 +634,11 @@ void cpu_exec_init(CPUState *cpu, Error **errp) cpu->memory = system_memory;object_ref (OBJECT (cpu->memory));#endif +} + +void cpu_exec_realize (CPUState *cpu,Error **errp) +{ + CPUClass *cc ATTRIBUTE_UNUSED = CPU_GET_CLASS(cpu);cpu_list_add (cpu);
I think cpu_list_add() needs to be in init, because this is where we set cpu->cpu_index, and (after patch 5) target-arm assumes that cpu_index has been set by init but before realize. So I guess we should do it in init and then roll back in the destructor?
thanks
-- PMM
Re: [Qemu-devel] [PATCH 01/19] exec: split cpu_exec_init()
Quoted 57 lines · Peter Maydell
Quoted 56 lines · Laurent Vivier
Extract the realize part to
cpu_exec_realize(), update all calls tocpu_exec_init()to addcpu_exec_realize()to have no functionnal change.Put in
cpu_exec_init()what initializes the CPU, incpu_exec_realize()what adds it to the environment.CC Paolo Bonzini <[email protected]>Signed-off-by Laurent Vivier <[email protected]>--- exec.c | 8 +++++--- include/exec/exec-all.h | 1 + target-alpha/cpu.c | 1 + target-arm/cpu.c | 1 + target-cris/cpu.c | 1 + target-i386/cpu.c | 1 + target-lm32/cpu.c | 1 + target-m68k/cpu.c | 1 + target-microblaze/cpu.c | 1 + target-mips/cpu.c | 1 + target-moxie/cpu.c | 1 + target-openrisc/cpu.c | 1 + target-ppc/translate_init.c | 5 +++++ target-s390x/cpu.c | 4 ++++ target-sh4/cpu.c | 1 + target-sparc/cpu.c | 1 + target-tilegx/cpu.c | 1 + target-tricore/cpu.c | 1 + target-unicore32/cpu.c | 1 + target-xtensa/cpu.c | 1 + 20 files changed, 31 insertions(+), 3 deletions(-)exec.c +5
-3@@ -614,9 +614,6 @@ void cpu_exec_exit(CPUState *cpu)void cpu_exec_init (CPUState *cpu,Error **errp) { - CPUClass *cc ATTRIBUTE_UNUSED = CPU_GET_CLASS(cpu); - Error *local_err ATTRIBUTE_UNUSED = NULL; - cpu->as =NULL ; cpu->num_ases =0 ;@@ -637,6 +634,11 @@ void cpu_exec_init(CPUState *cpu, Error **errp) cpu->memory = system_memory;object_ref (OBJECT (cpu->memory));#endif +} + +void cpu_exec_realize (CPUState *cpu,Error **errp) +{ + CPUClass *cc ATTRIBUTE_UNUSED = CPU_GET_CLASS(cpu);
Quoted 7 lines
exec.c void cpu_exec_init(CPUState *cpu, Error **errp) · line 643
Quoted 1 line
exec.c +0
-0cpu_list_add (cpu);I think
cpu_list_add()needs to be in init, because this is where we setcpu->cpu_index, and (after patch 5) target-arm assumes thatcpu_indexhas been set by init but before realize. So I guess we should do it in init and then roll back in the destructor?
instance_init is supposed to have no side-effects, that's the main reason cpu_exec_init() was moved to realize. qmp_device_list_properties(), for example, creates new objects to query the available properties. query-cpu-model-expansion and related commands will probably be implemented by many architectures by instantiating actual objects.
Signature · 1 line
Eduardo
Re: [Qemu-devel] [PATCH 01/19] exec: split cpu_exec_init()
In reply to Peter MaydellQuoted 57 lines · Peter Maydell
Quoted 56 lines · Laurent Vivier
Extract the realize part to
cpu_exec_realize(), update all calls tocpu_exec_init()to addcpu_exec_realize()to have no functionnal change.Put in
cpu_exec_init()what initializes the CPU, incpu_exec_realize()what adds it to the environment.CC Paolo Bonzini <[email protected]>Signed-off-by Laurent Vivier <[email protected]>--- exec.c | 8 +++++--- include/exec/exec-all.h | 1 + target-alpha/cpu.c | 1 + target-arm/cpu.c | 1 + target-cris/cpu.c | 1 + target-i386/cpu.c | 1 + target-lm32/cpu.c | 1 + target-m68k/cpu.c | 1 + target-microblaze/cpu.c | 1 + target-mips/cpu.c | 1 + target-moxie/cpu.c | 1 + target-openrisc/cpu.c | 1 + target-ppc/translate_init.c | 5 +++++ target-s390x/cpu.c | 4 ++++ target-sh4/cpu.c | 1 + target-sparc/cpu.c | 1 + target-tilegx/cpu.c | 1 + target-tricore/cpu.c | 1 + target-unicore32/cpu.c | 1 + target-xtensa/cpu.c | 1 + 20 files changed, 31 insertions(+), 3 deletions(-)exec.c +5
-3@@ -614,9 +614,6 @@ void cpu_exec_exit(CPUState *cpu)void cpu_exec_init (CPUState *cpu,Error **errp) { - CPUClass *cc ATTRIBUTE_UNUSED = CPU_GET_CLASS(cpu); - Error *local_err ATTRIBUTE_UNUSED = NULL; - cpu->as =NULL ; cpu->num_ases =0 ;@@ -637,6 +634,11 @@ void cpu_exec_init(CPUState *cpu, Error **errp) cpu->memory = system_memory;object_ref (OBJECT (cpu->memory));#endif +} + +void cpu_exec_realize (CPUState *cpu,Error **errp) +{ + CPUClass *cc ATTRIBUTE_UNUSED = CPU_GET_CLASS(cpu);
Quoted 7 lines
exec.c void cpu_exec_init(CPUState *cpu, Error **errp) · line 643
Quoted 1 line
exec.c +0
-0cpu_list_add (cpu);I think
cpu_list_add()needs to be in init, because this is where we setcpu->cpu_index, and (after patch 5) target-arm assumes thatcpu_indexhas been set by init but before realize. So I guess we should do it in init and then roll back in the destructor?
I think in some case cpu_list_add() can fail (no more index available), it's why it has to be in realize. In the case of hotplug we must not kill the machine.
See "5a790cc cpu: Add Error argument to cpu_exec_init()"
Laurent
Re: [Qemu-devel] [PATCH 01/19] exec: split cpu_exec_init()
In reply to Peter MaydellQuoted 57 lines · Peter Maydell
Quoted 56 lines · Laurent Vivier
Extract the realize part to
cpu_exec_realize(), update all calls tocpu_exec_init()to addcpu_exec_realize()to have no functionnal change.Put in
cpu_exec_init()what initializes the CPU, incpu_exec_realize()what adds it to the environment.CC Paolo Bonzini <[email protected]>Signed-off-by Laurent Vivier <[email protected]>--- exec.c | 8 +++++--- include/exec/exec-all.h | 1 + target-alpha/cpu.c | 1 + target-arm/cpu.c | 1 + target-cris/cpu.c | 1 + target-i386/cpu.c | 1 + target-lm32/cpu.c | 1 + target-m68k/cpu.c | 1 + target-microblaze/cpu.c | 1 + target-mips/cpu.c | 1 + target-moxie/cpu.c | 1 + target-openrisc/cpu.c | 1 + target-ppc/translate_init.c | 5 +++++ target-s390x/cpu.c | 4 ++++ target-sh4/cpu.c | 1 + target-sparc/cpu.c | 1 + target-tilegx/cpu.c | 1 + target-tricore/cpu.c | 1 + target-unicore32/cpu.c | 1 + target-xtensa/cpu.c | 1 + 20 files changed, 31 insertions(+), 3 deletions(-)exec.c +5
-3@@ -614,9 +614,6 @@ void cpu_exec_exit(CPUState *cpu)void cpu_exec_init (CPUState *cpu,Error **errp) { - CPUClass *cc ATTRIBUTE_UNUSED = CPU_GET_CLASS(cpu); - Error *local_err ATTRIBUTE_UNUSED = NULL; - cpu->as =NULL ; cpu->num_ases =0 ;@@ -637,6 +634,11 @@ void cpu_exec_init(CPUState *cpu, Error **errp) cpu->memory = system_memory;object_ref (OBJECT (cpu->memory));#endif +} + +void cpu_exec_realize (CPUState *cpu,Error **errp) +{ + CPUClass *cc ATTRIBUTE_UNUSED = CPU_GET_CLASS(cpu);
Quoted 7 lines
exec.c void cpu_exec_init(CPUState *cpu, Error **errp) · line 643
Quoted 1 line
exec.c +0
-0cpu_list_add (cpu);I think
cpu_list_add()needs to be in init, because this is where we setcpu->cpu_index, and (after patch 5) target-arm assumes thatcpu_indexhas been set by init but before realize. So I guess we should do it in init and then roll back in the destructor?
That will need to be fixed on the ARM side then. The whole new cpu_index assignment model (which allows cross-platform hotplug) relies on it not being fixed until realize() time.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [PATCH 01/19] exec: split cpu_exec_init()
Quoted 10 lines · David Gibson
Quoted 5 lines · Peter Maydell
I think
cpu_list_add()needs to be in init, because this is where we setcpu->cpu_index, and (after patch 5) target-arm assumes thatcpu_indexhas been set by init but before realize. So I guess we should do it in init and then roll back in the destructor?That will need to be fixed on the ARM side then. The whole new
cpu_indexassignment model (which allows cross-platform hotplug) relies on it not being fixed untilrealize()time.
OK. I guess we need to audit all the code that can get called between init and realize, which is a bit tedious. Is there anything else we need to look for other than use of cpu_index ?
thanks
-- PMM
PATCH 2/19 target-i386: move back cpu_exec_init() to init
In reply to Laurent VivierWe have now the cpu_exec_realize() in realize,
so the init part must be in init.
I've removed the cannot_destroy_with_object_finalize_yet field as cpu_exec_init() is not called by x86_cpu_initfn() anymore (tested with QOM command provided by commit 4c315c27 with "athlon-x86_64-cpu")
--- target-i386/cpu.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
target-i386/cpu.c +6 -7
@@ -3158,8 +3158,11 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp) cpu->phys_bits =32 ; } } -cpu_exec_init (cs, &error_abort); -cpu_exec_realize (cs, &error_abort); +cpu_exec_realize (cs, &local_err); +if (local_err !=NULL ) { +error_propagate (errp, local_err); +return ; + }if (tcg_enabled ()) {tcg_x86_init ();
@@ -3365,6 +3368,7 @@ static void x86_cpu_initfn(Object *obj)FeatureWord w; cs->env_ptr = env; +cpu_exec_init (cs, &error_abort); object_property_add(obj, "family", "int", x86_cpuid_version_get_family,
@@ -3538,11 +3542,6 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) cc->cpu_exec_exit = x86_cpu_exec_exit; dc->cannot_instantiate_with_device_add_yet = false; -/* -* Reason: x86_cpu_initfn() calls cpu_exec_init(), which saves the -* object in cpus -> dangling pointer after final object_unref(). -*/ - dc->cannot_destroy_with_object_finalize_yet = true; }static const TypeInfo x86_cpu_type_info = {
Signature · 1 line
2.7.4
PATCH 3/19 target-ppc: move back cpu_exec_init() to init
In reply to Laurent VivierWe have now the cpu_exec_realize() in realize,
so the init part must be in init
--- target-ppc/translate_init.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
target-ppc/translate_init.c +1 -5
@@ -9678,11 +9678,6 @@ static void ppc_cpu_realizefn(DeviceState *dev, Error **errp) }#endif -cpu_exec_init (cs, &local_err); -if (local_err !=NULL ) { -error_propagate (errp, local_err); -return ; - }cpu_exec_realize (cs, &local_err);if (local_err !=NULL ) {error_propagate (errp, local_err);
@@ -10439,6 +10434,7 @@ static void ppc_cpu_initfn(Object *obj)CPUPPCState *env = &cpu->env; cs->env_ptr = env; +cpu_exec_init (cs, &error_abort); env->msr_mask = pcc->msr_mask; env->mmu_model = pcc->mmu_model;
Signature · 1 line
2.7.4
PATCH 4/19 target-s390: move back cpu_exec_init() to init
In reply to Laurent VivierWe have now the cpu_exec_realize() in realize,
so the init part must be in init.
I've removed the cannot_destroy_with_object_finalize_yet field as it should be removed by commit c6644fc.
(tested with QOM command provided by commit 4c315c27 with "z890.3-s390-cpu")
--- target-s390x/cpu.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
target-s390x/cpu.c +1 -10
@@ -207,10 +207,6 @@ static void s390_cpu_realizefn(DeviceState *dev, Error **errp) goto out; } -cpu_exec_init (cs, &err); -if (err !=NULL ) { - goto out; - }cpu_exec_realize (cs, &err);if (err !=NULL ) { goto out;
@@ -293,6 +289,7 @@ static void s390_cpu_initfn(Object *obj) cs->env_ptr = env; cs->halted =1 ; cs->exception_index =EXCP_HLT ; +cpu_exec_init (cs, &error_abort);object_property_add (OBJECT (cpu),"id" ,"int64_t" , s390x_cpu_get_id, s390x_cpu_set_id,NULL ,NULL ,NULL );s390_cpu_model_register_props (obj);
@@ -444,12 +441,6 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_core_xml_file ="s390x-core64.xml" ; cc->gdb_arch_name = s390_gdb_arch_name; -/* -* Reason: s390_cpu_realizefn() calls cpu_exec_init(), which saves -* the object in cpus -> dangling pointer after final -* object_unref(). -*/ - dc->cannot_destroy_with_object_finalize_yet = true;s390_cpu_model_class_register_props (oc); }
Signature · 1 line
2.7.4
PATCH 5/19 target-arm: move cpu_exec_realize() to realize function
In reply to Laurent VivierI've removed the cannot_destroy_with_object_finalize_yet field as cpu_exec_init() is not called by arm_cpu_initfn() anymore (tested with QOM command provided by commit 4c315c27 with
"arm1026-arm-cpu")
--- target-arm/cpu.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-)
target-arm/cpu.c +7 -12
@@ -445,7 +445,6 @@ static void arm_cpu_initfn(Object *obj) cs->env_ptr = &cpu->env;cpu_exec_init (cs, &error_abort); -cpu_exec_realize (cs, &error_abort); cpu->cp_regs =g_hash_table_new_full (g_int_hash, g_int_equal, g_free, g_free);
@@ -577,6 +576,13 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)ARMCPU *cpu =ARM_CPU (dev);ARMCPUClass *acc =ARM_CPU_GET_CLASS (dev);CPUARMState *env = &cpu->env; +Error *local_err =NULL ; + +cpu_exec_realize (cs, &local_err); +if (local_err !=NULL ) { +error_propagate (errp, local_err); +return ; + }/* Some features automatically imply others: */ if (arm_feature (env,ARM_FEATURE_V8 )) {
@@ -1534,17 +1540,6 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->debug_check_watchpoint = arm_debug_check_watchpoint; cc->disas_set_info = arm_disas_set_info; - -/* -* Reason: arm_cpu_initfn() calls cpu_exec_init(), which saves -* the object in cpus -> dangling pointer after final -* object_unref(). -* -* Once this is fixed, the devices that create ARM CPUs should be -* updated not to set cannot_destroy_with_object_finalize_yet, -* unless they still screw up something else. -*/ - dc->cannot_destroy_with_object_finalize_yet = true; }static void cpu_register (const ARMCPUInfo *info)
Signature · 1 line
2.7.4
Re: [Qemu-arm] [PATCH 05/19] target-arm: move cpu_exec_realize() to realize function
Quoted 2 lines · Laurent Vivier
I've removed the
cannot_destroy_with_object_finalize_yetfield ascpu_exec_init()is not called byarm_cpu_initfn()anymore
I think this (and most of the similar commit messages following) needs a slight reword. A function called 'cpu_exec_init()' is still called from the initfn, it's just the unsafe things it used to do have been moved to cpu_exec_realize().
Quoted 54 lines
(tested with QOM command provided by commit
4c315c27with
"arm1026-arm-cpu")CC Peter Maydell <[email protected]>Signed-off-by Laurent Vivier <[email protected]>--- target-arm/cpu.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-)target-arm/cpu.c +7
-12@@ -445,7 +445,6 @@ static void arm_cpu_initfn(Object *obj) cs->env_ptr = &cpu->env;cpu_exec_init (cs, &error_abort); -cpu_exec_realize (cs, &error_abort); cpu->cp_regs =g_hash_table_new_full (g_int_hash, g_int_equal, g_free, g_free);@@ -577,6 +576,13 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)ARMCPU *cpu =ARM_CPU (dev);ARMCPUClass *acc =ARM_CPU_GET_CLASS (dev);CPUARMState *env = &cpu->env; +Error *local_err =NULL ; + +cpu_exec_realize (cs, &local_err); +if (local_err !=NULL ) { +error_propagate (errp, local_err); +return ; + }/* Some features automatically imply others: */ if (arm_feature (env,ARM_FEATURE_V8 )) {@@ -1534,17 +1540,6 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->debug_check_watchpoint = arm_debug_check_watchpoint; cc->disas_set_info = arm_disas_set_info; - -/* -* Reason: arm_cpu_initfn() calls cpu_exec_init(), which saves -* the object in cpus -> dangling pointer after final -* object_unref(). -* -* Once this is fixed, the devices that create ARM CPUs should be -* updated not to set cannot_destroy_with_object_finalize_yet, -* unless they still screw up something else. -*/ - dc->cannot_destroy_with_object_finalize_yet = true; }static void cpu_register (const ARMCPUInfo *info)
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
PATCH 6/19 target-alpha: move cpu_exec_realize() to realize function
In reply to Laurent VivierI've removed the cannot_destroy_with_object_finalize_yet field as cpu_exec_init() is not called by alpha_cpu_initfn() anymore (tested with QOM command provided by commit 4c315c27 with
"pca56-alpha-cpu")
--- target-alpha/cpu.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
target-alpha/cpu.c +7 -8
@@ -59,6 +59,13 @@ static void alpha_cpu_realizefn(DeviceState *dev, Error **errp) {CPUState *cs =CPU (dev);AlphaCPUClass *acc =ALPHA_CPU_GET_CLASS (dev); +Error *local_err =NULL ; + +cpu_exec_realize (cs, &local_err); +if (local_err !=NULL ) { +error_propagate (errp, local_err); +return ; + }qemu_init_vcpu (cs);
@@ -267,7 +274,6 @@ static void alpha_cpu_initfn(Object *obj) cs->env_ptr = env;cpu_exec_init (cs, &error_abort); -cpu_exec_realize (cs, &error_abort);tlb_flush (cs,1 );alpha_translate_init ();
@@ -310,13 +316,6 @@ static void alpha_cpu_class_init(ObjectClass *oc, void *data) cc->disas_set_info = alpha_cpu_disas_set_info; cc->gdb_num_core_regs =67 ; - -/* -* Reason: alpha_cpu_initfn() calls cpu_exec_init(), which saves -* the object in cpus -> dangling pointer after final -* object_unref(). -*/ - dc->cannot_destroy_with_object_finalize_yet = true; }static const TypeInfo alpha_cpu_type_info = {
Signature · 1 line
2.7.4
PATCH 7/19 target-cris: move cpu_exec_realize() to realize function
In reply to Laurent VivierI've removed the cannot_destroy_with_object_finalize_yet field as cpu_exec_init() is not called by cris_cpu_initfn() anymore (tested with QOM command provided by commit 4c315c27 with
"crisv17-cris-cpu")
--- target-cris/cpu.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
target-cris/cpu.c +7 -8
@@ -142,6 +142,13 @@ static void cris_cpu_realizefn(DeviceState *dev, Error **errp) {CPUState *cs =CPU (dev);CRISCPUClass *ccc =CRIS_CPU_GET_CLASS (dev); +Error *local_err =NULL ; + +cpu_exec_realize (cs, &local_err); +if (local_err !=NULL ) { +error_propagate (errp, local_err); +return ; + }cpu_reset (cs);qemu_init_vcpu (cs);
@@ -188,7 +195,6 @@ static void cris_cpu_initfn(Object *obj) cs->env_ptr = env;cpu_exec_init (cs, &error_abort); -cpu_exec_realize (cs, &error_abort); env->pregs[PR_VR ] = ccc->vr;
@@ -327,13 +333,6 @@ static void cris_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_stop_before_watchpoint = true; cc->disas_set_info = cris_disas_set_info; - -/* -* Reason: cris_cpu_initfn() calls cpu_exec_init(), which saves -* the object in cpus -> dangling pointer after final -* object_unref(). -*/ - dc->cannot_destroy_with_object_finalize_yet = true; }static const TypeInfo cris_cpu_type_info = {
Signature · 1 line
2.7.4
PATCH 8/19 target-lm32: move cpu_exec_realize() to realize function
In reply to Laurent VivierI've removed the cannot_destroy_with_object_finalize_yet field as cpu_exec_init() is not called by lm32_cpu_initfn() anymore (tested with QOM command provided by commit 4c315c27 with
"lm32-full-lm32-cpu")
--- target-lm32/cpu.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
target-lm32/cpu.c +7 -8
@@ -144,6 +144,13 @@ static void lm32_cpu_realizefn(DeviceState *dev, Error **errp) {CPUState *cs =CPU (dev);LM32CPUClass *lcc =LM32_CPU_GET_CLASS (dev); +Error *local_err =NULL ; + +cpu_exec_realize (cs, &local_err); +if (local_err !=NULL ) { +error_propagate (errp, local_err); +return ; + }cpu_reset (cs);
@@ -161,7 +168,6 @@ static void lm32_cpu_initfn(Object *obj) cs->env_ptr = env;cpu_exec_init (cs, &error_abort); -cpu_exec_realize (cs, &error_abort); env->flags =0 ;
@@ -286,13 +292,6 @@ static void lm32_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_stop_before_watchpoint = true; cc->debug_excp_handler = lm32_debug_excp_handler; cc->disas_set_info = lm32_cpu_disas_set_info; - -/* -* Reason: lm32_cpu_initfn() calls cpu_exec_init(), which saves -* the object in cpus -> dangling pointer after final -* object_unref(). -*/ - dc->cannot_destroy_with_object_finalize_yet = true; }static void lm32_register_cpu_type (const LM32CPUInfo *info)
Signature · 1 line
2.7.4
PATCH 9/19 target-m68k: move cpu_exec_realize() to realize function
In reply to Laurent VivierI've removed the cannot_destroy_with_object_finalize_yet field as cpu_exec_init() is not called by m68k_cpu_initfn() anymore (tested with QOM command provided by commit 4c315c27 with
"any-m68k-cpu")
--- target-m68k/cpu.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
target-m68k/cpu.c +7 -8
@@ -159,6 +159,13 @@ static void m68k_cpu_realizefn(DeviceState *dev, Error **errp)CPUState *cs =CPU (dev);M68kCPU *cpu =M68K_CPU (dev);M68kCPUClass *mcc =M68K_CPU_GET_CLASS (dev); +Error *local_err =NULL ; + +cpu_exec_realize (cs, &local_err); +if (local_err !=NULL ) { +error_propagate (errp, local_err); +return ; + }m68k_cpu_init_gdb (cpu);
@@ -177,7 +184,6 @@ static void m68k_cpu_initfn(Object *obj) cs->env_ptr = env;cpu_exec_init (cs, &error_abort); -cpu_exec_realize (cs, &error_abort);if (tcg_enabled () && !inited) { inited = true;
@@ -223,13 +229,6 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data) cc->gdb_core_xml_file ="cf-core.xml" ; dc->vmsd = &vmstate_m68k_cpu; - -/* -* Reason: m68k_cpu_initfn() calls cpu_exec_init(), which saves -* the object in cpus -> dangling pointer after final -* object_unref(). -*/ - dc->cannot_destroy_with_object_finalize_yet = true; }static void register_cpu_type (const M68kCPUInfo *info)
Signature · 1 line
2.7.4
PATCH 10/19 target-microblaze: move cpu_exec_realize() to realize function
In reply to Laurent VivierI've removed the cannot_destroy_with_object_finalize_yet field as cpu_exec_init() is not called by mb_cpu_initfn() anymore (tested with QOM command provided by commit 4c315c27 with
"microblaze-cpu")
--- target-microblaze/cpu.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
target-microblaze/cpu.c +7 -7
@@ -138,6 +138,13 @@ static void mb_cpu_realizefn(DeviceState *dev, Error **errp)CPUMBState *env = &cpu->env;uint8_t version_code =0 ;int i =0 ; +Error *local_err =NULL ; + +cpu_exec_realize (cs, &local_err); +if (local_err !=NULL ) { +error_propagate (errp, local_err); +return ; + }qemu_init_vcpu (cs);
@@ -200,7 +207,6 @@ static void mb_cpu_initfn(Object *obj) cs->env_ptr = env;cpu_exec_init (cs, &error_abort); -cpu_exec_realize (cs, &error_abort);set_float_rounding_mode (float_round_nearest_even, &env->fp_status);
@@ -268,12 +274,6 @@ static void mb_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_num_core_regs =32 +5 ; cc->disas_set_info = mb_disas_set_info; - -/* -* Reason: mb_cpu_initfn() calls cpu_exec_init(), which saves the -* object in cpus -> dangling pointer after final object_unref(). -*/ - dc->cannot_destroy_with_object_finalize_yet = true; }static const TypeInfo mb_cpu_type_info = {
Signature · 1 line
2.7.4
PATCH 11/19 target-mips: move cpu_exec_realize() to realize function
In reply to Laurent VivierI've removed the cannot_destroy_with_object_finalize_yet field as cpu_exec_init() is not called by mips_cpu_initfn() anymore (tested with QOM command provided by commit 4c315c27 with
"mips-cpu")
--- target-mips/cpu.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
target-mips/cpu.c +7 -8
@@ -124,6 +124,13 @@ static void mips_cpu_realizefn(DeviceState *dev, Error **errp) {CPUState *cs =CPU (dev);MIPSCPUClass *mcc =MIPS_CPU_GET_CLASS (dev); +Error *local_err =NULL ; + +cpu_exec_realize (cs, &local_err); +if (local_err !=NULL ) { +error_propagate (errp, local_err); +return ; + }cpu_reset (cs);qemu_init_vcpu (cs);
@@ -139,7 +146,6 @@ static void mips_cpu_initfn(Object *obj) cs->env_ptr = env;cpu_exec_init (cs, &error_abort); -cpu_exec_realize (cs, &error_abort);if (tcg_enabled ()) {mips_tcg_init ();
@@ -178,13 +184,6 @@ static void mips_cpu_class_init(ObjectClass *c, void *data) cc->gdb_num_core_regs =73 ; cc->gdb_stop_before_watchpoint = true; - -/* -* Reason: mips_cpu_initfn() calls cpu_exec_init(), which saves -* the object in cpus -> dangling pointer after final -* object_unref(). -*/ - dc->cannot_destroy_with_object_finalize_yet = true; }static const TypeInfo mips_cpu_type_info = {
Signature · 1 line
2.7.4
PATCH 12/19 target-moxie: move cpu_exec_realize() to realize function
In reply to Laurent VivierI've removed the cannot_destroy_with_object_finalize_yet field as cpu_exec_init() is not called by moxie_cpu_initfn() anymore (tested with QOM command provided by commit 4c315c27 with
"moxie-cpu")
--- target-moxie/cpu.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
target-moxie/cpu.c +7 -8
@@ -61,6 +61,13 @@ static void moxie_cpu_realizefn(DeviceState *dev, Error **errp) {CPUState *cs =CPU (dev);MoxieCPUClass *mcc =MOXIE_CPU_GET_CLASS (dev); +Error *local_err =NULL ; + +cpu_exec_realize (cs, &local_err); +if (local_err !=NULL ) { +error_propagate (errp, local_err); +return ; + }qemu_init_vcpu (cs);cpu_reset (cs);
@@ -76,7 +83,6 @@ static void moxie_cpu_initfn(Object *obj) cs->env_ptr = &cpu->env;cpu_exec_init (cs, &error_abort); -cpu_exec_realize (cs, &error_abort);if (tcg_enabled () && !inited) { inited =1 ;
@@ -125,13 +131,6 @@ static void moxie_cpu_class_init(ObjectClass *oc, void *data) cc->vmsd = &vmstate_moxie_cpu;#endif cc->disas_set_info = moxie_cpu_disas_set_info; - -/* -* Reason: moxie_cpu_initfn() calls cpu_exec_init(), which saves -* the object in cpus -> dangling pointer after final -* object_unref(). -*/ - dc->cannot_destroy_with_object_finalize_yet = true; }static void moxielite_initfn (Object *obj)
Signature · 1 line
2.7.4
PATCH 13/19 target-openrisc: move cpu_exec_realize() to realize function
In reply to Laurent VivierI've removed the cannot_destroy_with_object_finalize_yet field as cpu_exec_init() is not called by openrisc_cpu_initfn() anymore (tested with QOM command provided by commit 4c315c27 with
"or1200-or32-cpu")
--- target-openrisc/cpu.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
target-openrisc/cpu.c +7 -8
@@ -81,6 +81,13 @@ static void openrisc_cpu_realizefn(DeviceState *dev, Error **errp) {CPUState *cs =CPU (dev);OpenRISCCPUClass *occ =OPENRISC_CPU_GET_CLASS (dev); +Error *local_err =NULL ; + +cpu_exec_realize (cs, &local_err); +if (local_err !=NULL ) { +error_propagate (errp, local_err); +return ; + }qemu_init_vcpu (cs);cpu_reset (cs);
@@ -96,7 +103,6 @@ static void openrisc_cpu_initfn(Object *obj) cs->env_ptr = &cpu->env;cpu_exec_init (cs, &error_abort); -cpu_exec_realize (cs, &error_abort);#ifndef CONFIG_USER_ONLY cpu_openrisc_mmu_init (cpu);
@@ -181,13 +187,6 @@ static void openrisc_cpu_class_init(ObjectClass *oc, void *data) dc->vmsd = &vmstate_openrisc_cpu;#endif cc->gdb_num_core_regs =32 +3 ; - -/* -* Reason: openrisc_cpu_initfn() calls cpu_exec_init(), which saves -* the object in cpus -> dangling pointer after final -* object_unref(). -*/ - dc->cannot_destroy_with_object_finalize_yet = true; }static void cpu_register (const OpenRISCCPUInfo *info)
Signature · 1 line
2.7.4
PATCH 14/19 target-sh4: move cpu_exec_realize() to realize function
In reply to Laurent VivierI've removed the cannot_destroy_with_object_finalize_yet field as cpu_exec_init() is not called by superh_cpu_initfn() anymore (tested with QOM command provided by commit 4c315c27 with
"sh7750r-superh-cpu")
--- target-sh4/cpu.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
target-sh4/cpu.c +7 -8
@@ -244,6 +244,13 @@ static void superh_cpu_realizefn(DeviceState *dev, Error **errp) {CPUState *cs =CPU (dev);SuperHCPUClass *scc =SUPERH_CPU_GET_CLASS (dev); +Error *local_err =NULL ; + +cpu_exec_realize (cs, &local_err); +if (local_err !=NULL ) { +error_propagate (errp, local_err); +return ; + }cpu_reset (cs);qemu_init_vcpu (cs);
@@ -259,7 +266,6 @@ static void superh_cpu_initfn(Object *obj) cs->env_ptr = env;cpu_exec_init (cs, &error_abort); -cpu_exec_realize (cs, &error_abort); env->movcal_backup_tail = &(env->movcal_backup);
@@ -304,13 +310,6 @@ static void superh_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_num_core_regs =59 ; dc->vmsd = &vmstate_sh_cpu; - -/* -* Reason: superh_cpu_initfn() calls cpu_exec_init(), which saves -* the object in cpus -> dangling pointer after final -* object_unref(). -*/ - dc->cannot_destroy_with_object_finalize_yet = true; }static const TypeInfo superh_cpu_type_info = {
Signature · 1 line
2.7.4
PATCH 15/19 target-sparc: move cpu_exec_realize() to realize function
In reply to Laurent VivierI've removed the cannot_destroy_with_object_finalize_yet field as cpu_exec_init() is not called by sparc_cpu_initfn() anymore (tested with QOM command provided by commit 4c315c27 with
"sparc-cpu")
--- target-sparc/cpu.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
target-sparc/cpu.c +9 -9
@@ -792,7 +792,9 @@ static bool sparc_cpu_has_work(CPUState *cs)static void sparc_cpu_realizefn (DeviceState *dev,Error **errp) { +CPUState *cs =CPU (dev);SPARCCPUClass *scc =SPARC_CPU_GET_CLASS (dev); +Error *local_err =NULL ;#if defined(CONFIG_USER_ONLY )SPARCCPU *cpu =SPARC_CPU (dev);CPUSPARCState *env = &cpu->env;
@@ -802,7 +804,13 @@ static void sparc_cpu_realizefn(DeviceState *dev, Error **errp) }#endif -qemu_init_vcpu (CPU (dev)); +cpu_exec_realize (cs, &local_err); +if (local_err !=NULL ) { +error_propagate (errp, local_err); +return ; + } + +qemu_init_vcpu (cs); scc->parent_realize (dev, errp); }
@@ -815,7 +823,6 @@ static void sparc_cpu_initfn(Object *obj) cs->env_ptr = env;cpu_exec_init (cs, &error_abort); -cpu_exec_realize (cs, &error_abort);if (tcg_enabled ()) {gen_intermediate_code_init (env);
@@ -868,13 +875,6 @@ static void sparc_cpu_class_init(ObjectClass *oc, void *data)#else cc->gdb_num_core_regs =72 ;#endif - -/* -* Reason: sparc_cpu_initfn() calls cpu_exec_init(), which saves -* the object in cpus -> dangling pointer after final -* object_unref(). -*/ - dc->cannot_destroy_with_object_finalize_yet = true; }static const TypeInfo sparc_cpu_type_info = {
Signature · 1 line
2.7.4
PATCH 16/19 target-tilegx: move cpu_exec_realize() to realize function
In reply to Laurent VivierI've removed the cannot_destroy_with_object_finalize_yet field as cpu_exec_init() is not called by tilegx_cpu_initfn() anymore (not tested with QOM command as tilegx is only available in linux-user
mode)
--- target-tilegx/cpu.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
target-tilegx/cpu.c +7 -8
@@ -92,6 +92,13 @@ static void tilegx_cpu_realizefn(DeviceState *dev, Error **errp) {CPUState *cs =CPU (dev);TileGXCPUClass *tcc =TILEGX_CPU_GET_CLASS (dev); +Error *local_err =NULL ; + +cpu_exec_realize (cs, &local_err); +if (local_err !=NULL ) { +error_propagate (errp, local_err); +return ; + }cpu_reset (cs);qemu_init_vcpu (cs);
@@ -108,7 +115,6 @@ static void tilegx_cpu_initfn(Object *obj) cs->env_ptr = env;cpu_exec_init (cs, &error_abort); -cpu_exec_realize (cs, &error_abort);if (tcg_enabled () && !tcg_initialized) { tcg_initialized = true;
@@ -163,13 +169,6 @@ static void tilegx_cpu_class_init(ObjectClass *oc, void *data) cc->set_pc = tilegx_cpu_set_pc; cc->handle_mmu_fault = tilegx_cpu_handle_mmu_fault; cc->gdb_num_core_regs =0 ; - -/* -* Reason: tilegx_cpu_initfn() calls cpu_exec_init(), which saves -* the object in cpus -> dangling pointer after final -* object_unref(). -*/ - dc->cannot_destroy_with_object_finalize_yet = true; }static const TypeInfo tilegx_cpu_type_info = {
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH 16/19] target-tilegx: move cpu_exec_realize() to realize function
Quoted 5 lines · Laurent Vivier
I've removed the
cannot_destroy_with_object_finalize_yetfield ascpu_exec_init()is not called bytilegx_cpu_initfn()anymore (not tested with QOM command as tilegx is only available in linux-user
mode)
For master branch, I can not find cpu_exec_realize in total source code, I am not quite sure whether it is ok or not.
And in honest, now, tilegx-linux-user is not implemented completely, the floating point insns are not supported by our main branch (which should be one of main feature for tilegx) -- which I should try.
Thanks.
Quoted 47 lines
CC Chen Gang <[email protected]>Signed-off-by Laurent Vivier <[email protected]>--- target-tilegx/cpu.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)target-tilegx/cpu.c +7
-8@@ -92,6 +92,13 @@ static void tilegx_cpu_realizefn(DeviceState *dev, Error **errp) {CPUState *cs =CPU (dev);TileGXCPUClass *tcc =TILEGX_CPU_GET_CLASS (dev); +Error *local_err =NULL ; + +cpu_exec_realize (cs, &local_err); +if (local_err !=NULL ) { +error_propagate (errp, local_err); +return ; + }cpu_reset (cs);qemu_init_vcpu (cs);@@ -108,7 +115,6 @@ static void tilegx_cpu_initfn(Object *obj) cs->env_ptr = env;cpu_exec_init (cs, &error_abort); -cpu_exec_realize (cs, &error_abort);if (tcg_enabled () && !tcg_initialized) { tcg_initialized = true;@@ -163,13 +169,6 @@ static void tilegx_cpu_class_init(ObjectClass *oc, void *data) cc->set_pc = tilegx_cpu_set_pc; cc->handle_mmu_fault = tilegx_cpu_handle_mmu_fault; cc->gdb_num_core_regs =0 ; - -/* -* Reason: tilegx_cpu_initfn() calls cpu_exec_init(), which saves -* the object in cpus -> dangling pointer after final -* object_unref(). -*/ - dc->cannot_destroy_with_object_finalize_yet = true; }static const TypeInfo tilegx_cpu_type_info = {
Signature · 8 lines
Chen Gang (陈刚) Managing Natural Environments is the Duty of Human Beings. -- Chen Gang (陈刚) Managing Natural Environments is the Duty of Human Beings.
Re: [Qemu-devel] [PATCH 16/19] target-tilegx: move cpu_exec_realize() to realize function
Quoted 11 lines · Chen Gang
Quoted 5 lines · Laurent Vivier
I've removed the
cannot_destroy_with_object_finalize_yetfield ascpu_exec_init()is not called bytilegx_cpu_initfn()anymore (not tested with QOM command as tilegx is only available in linux-user
mode)For master branch, I can not find
cpu_exec_realizein total source code, I am not quite sure whether it is ok or not.
It's a new function introduced in the first patch of this series. The old cpu_exec_init() was split into cpu_exec_init() which contains things which are safe at init time, and cpu_exec_realize() which is supposed to be called at realize() time.
Quoted 55 lines
And in honest, now, tilegx-linux-user is not implemented completely, the floating point insns are not supported by our main branch (which should be one of main feature for tilegx) -- which I should try.
Thanks.
Quoted 47 lines
CC Chen Gang <[email protected]>Signed-off-by Laurent Vivier <[email protected]>--- target-tilegx/cpu.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)target-tilegx/cpu.c +7
-8@@ -92,6 +92,13 @@ static void tilegx_cpu_realizefn(DeviceState *dev, Error **errp) {CPUState *cs =CPU (dev);TileGXCPUClass *tcc =TILEGX_CPU_GET_CLASS (dev); +Error *local_err =NULL ; + +cpu_exec_realize (cs, &local_err); +if (local_err !=NULL ) { +error_propagate (errp, local_err); +return ; + }cpu_reset (cs);qemu_init_vcpu (cs);@@ -108,7 +115,6 @@ static void tilegx_cpu_initfn(Object *obj) cs->env_ptr = env;cpu_exec_init (cs, &error_abort); -cpu_exec_realize (cs, &error_abort);if (tcg_enabled () && !tcg_initialized) { tcg_initialized = true;@@ -163,13 +169,6 @@ static void tilegx_cpu_class_init(ObjectClass *oc, void *data) cc->set_pc = tilegx_cpu_set_pc; cc->handle_mmu_fault = tilegx_cpu_handle_mmu_fault; cc->gdb_num_core_regs =0 ; - -/* -* Reason: tilegx_cpu_initfn() calls cpu_exec_init(), which saves -* the object in cpus -> dangling pointer after final -* object_unref(). -*/ - dc->cannot_destroy_with_object_finalize_yet = true; }static const TypeInfo tilegx_cpu_type_info = {
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [PATCH 16/19] target-tilegx: move cpu_exec_realize() to realize function
In reply to Chen GangQuoted 11 lines · Chen Gang
Quoted 5 lines · Laurent Vivier
I've removed the
cannot_destroy_with_object_finalize_yetfield ascpu_exec_init()is not called bytilegx_cpu_initfn()anymore (not tested with QOM command as tilegx is only available in linux-user
mode)For master branch, I can not find
cpu_exec_realizein total source code, I am not quite sure whether it is ok or not.
See PATCH 1/19 exec: split cpu_exec_init()
Thanks,
Laurent
PATCH 17/19 target-tricore: move cpu_exec_realize() to realize function
In reply to Laurent VivierI've removed the cannot_destroy_with_object_finalize_yet field as cpu_exec_init() is not called by tricore_cpu_initfn() anymore (tested with QOM command provided by commit 4c315c27 with
"tc1796-tricore-cpu")
--- target-tricore/cpu.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
target-tricore/cpu.c +7 -8
@@ -69,6 +69,13 @@ static void tricore_cpu_realizefn(DeviceState *dev, Error **errp)TriCoreCPU *cpu =TRICORE_CPU (dev);TriCoreCPUClass *tcc =TRICORE_CPU_GET_CLASS (dev);CPUTriCoreState *env = &cpu->env; +Error *local_err =NULL ; + +cpu_exec_realize (cs, &local_err); +if (local_err !=NULL ) { +error_propagate (errp, local_err); +return ; + }/* Some features automatically imply others */ if (tricore_feature (env,TRICORE_FEATURE_161 )) {
@@ -96,7 +103,6 @@ static void tricore_cpu_initfn(Object *obj) cs->env_ptr = env;cpu_exec_init (cs, &error_abort); -cpu_exec_realize (cs, &error_abort);if (tcg_enabled ()) {tricore_tcg_init ();
@@ -173,13 +179,6 @@ static void tricore_cpu_class_init(ObjectClass *c, void *data) cc->dump_state = tricore_cpu_dump_state; cc->set_pc = tricore_cpu_set_pc; cc->synchronize_from_tb = tricore_cpu_synchronize_from_tb; - -/* -* Reason: tricore_cpu_initfn() calls cpu_exec_init(), which saves -* the object in cpus -> dangling pointer after final -* object_unref(). -*/ - dc->cannot_destroy_with_object_finalize_yet = true; }static void cpu_register (const TriCoreCPUInfo *info)
Signature · 1 line
2.7.4
PATCH 18/19 target-unicore32: move cpu_exec_realize() to realize function
In reply to Laurent VivierI've removed the cannot_destroy_with_object_finalize_yet field as cpu_exec_init() is not called by uc32_cpu_initfn() anymore (tested with QOM command provided by commit 4c315c27 with
"any-unicore32-cpu")
--- target-unicore32/cpu.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
target-unicore32/cpu.c +9 -9
@@ -101,9 +101,17 @@ static const UniCore32CPUInfo uc32_cpus[] = {static void uc32_cpu_realizefn (DeviceState *dev,Error **errp) { +CPUState *cs =CPU (dev);UniCore32CPUClass *ucc =UNICORE32_CPU_GET_CLASS (dev); +Error *local_err =NULL ; -qemu_init_vcpu (CPU (dev)); +cpu_exec_realize (cs, &local_err); +if (local_err !=NULL ) { +error_propagate (errp, local_err); +return ; + } + +qemu_init_vcpu (cs); ucc->parent_realize (dev, errp); }
@@ -117,7 +125,6 @@ static void uc32_cpu_initfn(Object *obj) cs->env_ptr = env;cpu_exec_init (cs, &error_abort); -cpu_exec_realize (cs, &error_abort);#ifdef CONFIG_USER_ONLY env->uncached_asr =ASR_MODE_USER ;
@@ -161,13 +168,6 @@ static void uc32_cpu_class_init(ObjectClass *oc, void *data) cc->get_phys_page_debug = uc32_cpu_get_phys_page_debug;#endif dc->vmsd = &vmstate_uc32_cpu; - -/* -* Reason: uc32_cpu_initfn() calls cpu_exec_init(), which saves -* the object in cpus -> dangling pointer after final -* object_unref(). -*/ - dc->cannot_destroy_with_object_finalize_yet = true; }static void uc32_register_cpu_type (const UniCore32CPUInfo *info)
Signature · 1 line
2.7.4
PATCH 19/19 target-xtensa: move cpu_exec_realize() to realize function
In reply to Laurent VivierI've removed the cannot_destroy_with_object_finalize_yet field as cpu_exec_init() is not called by xtensa_cpu_initfn() anymore (tested with QOM command provided by commit 4c315c27 with
"dc233c-xtensa-cpu")
--- target-xtensa/cpu.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
target-xtensa/cpu.c +7 -8
@@ -99,6 +99,13 @@ static void xtensa_cpu_realizefn(DeviceState *dev, Error **errp) {CPUState *cs =CPU (dev);XtensaCPUClass *xcc =XTENSA_CPU_GET_CLASS (dev); +Error *local_err =NULL ; + +cpu_exec_realize (cs, &local_err); +if (local_err !=NULL ) { +error_propagate (errp, local_err); +return ; + } cs->gdb_num_regs = xcc->config->gdb_regmap.num_regs;
@@ -118,7 +125,6 @@ static void xtensa_cpu_initfn(Object *obj) cs->env_ptr = env; env->config = xcc->config;cpu_exec_init (cs, &error_abort); -cpu_exec_realize (cs, &error_abort);if (tcg_enabled () && !tcg_inited) { tcg_inited = true;
@@ -159,13 +165,6 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void *data)#endif cc->debug_excp_handler = xtensa_breakpoint_handler; dc->vmsd = &vmstate_xtensa_cpu; - -/* -* Reason: xtensa_cpu_initfn() calls cpu_exec_init(), which saves -* the object in cpus -> dangling pointer after final -* object_unref(). -*/ - dc->cannot_destroy_with_object_finalize_yet = true; }static const TypeInfo xtensa_cpu_type_info = {
Signature · 1 line
2.7.4
Quoted 16 lines · Laurent Vivier
Since commit 42ecaba ("target-i386: Call
cpu_exec_init()on realize"), , commit 6dd0f83 ("target-ppc: Movecpu_exec_init()call to realize function"), and commit c6644fc ("s390x/cpu: Get rid of side effects when creating a vcpu"),cpu_exec_init()has been moved to realize function for some architectures to implement CPU htoplug. This allows any failures fromcpu_exec_init()to be handled appropriately.This series tries to do the same work for all the other CPUs.
But as the ARM Virtual Machine ("virt") needs the "memory" property of the CPU in the machine init function (the "memory" property is created in
cpu_exec_init()we want to move to the realize part), splitcpu_exec_init()in two parts: a realize part (cpu_exec_realize(), adding the CPU in the environment) and an init part (cpu_exec_init(), initializing the CPU, like adding the "memory" property).
Quoted 7 lines
For target-i386, target-s390 and target-ppc, we move back the
cpu_exec_init()into the init part, and put thecpu_exec_realize()into the realize part. For all the other CPUs, we add thecpu_exec_realize()function into the realize part.This also allows to remove all the "
cannot_destroy_with_object_finalize_yet" properties from the CPU device class.
At some point following this we should remove the Error** argument from cpu_exec_init() : init isn't permitted to fail and indeed cpu_exec_init() never does, so the argument is unneeded.
If realize fails do we correctly release the reference we take on cpu->memory in cpu_exec_init()?
thanks
-- PMM
Quoted 22 lines · Peter Maydell
Quoted 21 lines · Laurent Vivier
Since commit 42ecaba ("target-i386: Call
cpu_exec_init()on realize"), , commit 6dd0f83 ("target-ppc: Movecpu_exec_init()call to realize function"), and commit c6644fc ("s390x/cpu: Get rid of side effects when creating a vcpu"),cpu_exec_init()has been moved to realize function for some architectures to implement CPU htoplug. This allows any failures fromcpu_exec_init()to be handled appropriately.This series tries to do the same work for all the other CPUs.
But as the ARM Virtual Machine ("virt") needs the "memory" property of the CPU in the machine init function (the "memory" property is created in
cpu_exec_init()we want to move to the realize part), splitcpu_exec_init()in two parts: a realize part (cpu_exec_realize(), adding the CPU in the environment) and an init part (cpu_exec_init(), initializing the CPU, like adding the "memory" property).For target-i386, target-s390 and target-ppc, we move back the
cpu_exec_init()into the init part, and put thecpu_exec_realize()into the realize part. For all the other CPUs, we add thecpu_exec_realize()function into the realize part.
Quoted 6 lines
Quoted 2 lines
This also allows to remove all the "
cannot_destroy_with_object_finalize_yet" properties from the CPU device class.At some point following this we should remove the Error** argument from
cpu_exec_init(): init isn't permitted to fail and indeedcpu_exec_init()never does, so the argument is unneeded.
I agree.
Quoted 2 lines
If realize fails do we correctly release the reference we take on
cpu->memoryincpu_exec_init()?
Because of OBJ_PROP_LINK_UNREF_ON_RELEASE, I think the reference is decreased when the object is released.
Laurent
Quoted 7 lines · Laurent Vivier
Since commit 42ecaba ("target-i386: Call
cpu_exec_init()on realize"), , commit 6dd0f83 ("target-ppc: Movecpu_exec_init()call to realize function"), and commit c6644fc ("s390x/cpu: Get rid of side effects when creating a vcpu"),cpu_exec_init()has been moved to realize function for some architectures to implement CPU htoplug. This allows any failures fromcpu_exec_init()to be handled appropriately.
Quoted 8 lines
This series tries to do the same work for all the other CPUs.
But as the ARM Virtual Machine ("virt") needs the "memory" property of the CPU in the machine init function (the "memory" property is created in
cpu_exec_init()we want to move to the realize part), splitcpu_exec_init()in two parts: a realize part (cpu_exec_realize(), adding the CPU in the environment) and an init part (cpu_exec_init(), initializing the CPU, like adding the "memory" property).
Instead of requiring each subclass to call both the init and realize functions at the right moment, why don't we move the code that needs to run at instance_init time to cpu_common_initfn()? (TYPE_CPU's instance_init)
cpu_common_initfn() runs before the subclasses' instance_init functions. But if we need anything to run _after_ subclasses' instance_init functions, we can also make TYPE_CPU implement a instance_post_init function.
Quoted 55 lines
For target-i386, target-s390 and target-ppc, we move back the
cpu_exec_init()into the init part, and put thecpu_exec_realize()into the realize part. For all the other CPUs, we add thecpu_exec_realize()function into the realize part.This also allows to remove all the "
cannot_destroy_with_object_finalize_yet" properties from the CPU device class.Laurent Vivier (19):
exec: splitcpu_exec_init()
target-i386: move backcpu_exec_init()to init
target-ppc: move backcpu_exec_init()to init
target-s390: move backcpu_exec_init()to init
target-arm: movecpu_exec_realize()to realize function
target-alpha: movecpu_exec_realize()to realize function
target-cris: movecpu_exec_realize()to realize function
target-lm32: movecpu_exec_realize()to realize function
target-m68k: movecpu_exec_realize()to realize function
target-microblaze: movecpu_exec_realize()to realize function
target-mips: movecpu_exec_realize()to realize function
target-moxie: movecpu_exec_realize()to realize function
target-openrisc: movecpu_exec_realize()to realize function
target-sh4: movecpu_exec_realize()to realize function
target-sparc: movecpu_exec_realize()to realize function
target-tilegx: movecpu_exec_realize()to realize function
target-tricore: movecpu_exec_realize()to realize function
target-unicore32: movecpu_exec_realize()to realize function
target-xtensa: movecpu_exec_realize()to realize functionexec.c | 8 +++++--- include/exec/exec-all.h | 1 + target-alpha/cpu.c | 14 +++++++------- target-arm/cpu.c | 18 +++++++----------- target-cris/cpu.c | 14 +++++++------- target-i386/cpu.c | 12 ++++++------ target-lm32/cpu.c | 14 +++++++------- target-m68k/cpu.c | 14 +++++++------- target-microblaze/cpu.c | 13 +++++++------ target-mips/cpu.c | 14 +++++++------- target-moxie/cpu.c | 14 +++++++------- target-openrisc/cpu.c | 14 +++++++------- target-ppc/translate_init.c | 3 ++- target-s390x/cpu.c | 9 ++------- target-sh4/cpu.c | 14 +++++++------- target-sparc/cpu.c | 17 +++++++++-------- target-tilegx/cpu.c | 14 +++++++------- target-tricore/cpu.c | 14 +++++++------- target-unicore32/cpu.c | 17 +++++++++-------- target-xtensa/cpu.c | 14 +++++++------- 20 files changed, 125 insertions(+), 127 deletions(-)Signature · 1 line
2.7.4
Signature · 1 line
Eduardo