Skip to contentSkip to conversation

Split cpu_exec_init() into an init and a realize part

PATCH Superseded Laurent Vivier 5 participants 32 messages Oct 5, 2016 – Oct 6, 2016

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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
index c8389f9..95b0aee 100644
@@ -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
index 336a57c..649187d 100644
@@ -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
index 6d01d7f..19f2eb2 100644
@@ -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
index 1b9540e..5fda716 100644
@@ -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
index d680cfb..78753ed 100644
@@ -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
index 1c57fce..125a10c 100644
@@ -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
index a783d46..4b93454 100644
@@ -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
index 116b784..307910a 100644
@@ -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
index 8edc00a..9ec2c9c 100644
@@ -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
index 64ad112..8a42213 100644
@@ -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
index 50a0899..28beff1 100644
@@ -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
index 155913f..1f2a084 100644
@@ -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
index b66b40b..5e84e65 100644
@@ -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
index 35ae2ce..20a88dd 100644
@@ -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
index f589532..f172516 100644
@@ -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
index 800a25a..77cc920 100644
@@ -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
index 7017cb6..f7ec920 100644
@@ -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
index 35d4ee4..2fd3325 100644
@@ -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
index e7a4984..2e5466a 100644
@@ -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
index 5ad08a2..fc72726 100644
@@ -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
#2 lore raw

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 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 +0 -3
index c8389f9..95b0aee 100644
@@ -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

#3 lore raw

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 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
index c8389f9..95b0aee 100644
@@ -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 -0
     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?

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
#4 lore raw

Re: [Qemu-devel] [PATCH 01/19] exec: split cpu_exec_init()

In reply to Peter Maydell
Quoted 57 lines · Peter Maydell
Quoted 56 lines · Laurent Vivier

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
index c8389f9..95b0aee 100644
@@ -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 -0
     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?

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

#5 lore raw

Re: [Qemu-devel] [PATCH 01/19] exec: split cpu_exec_init()

In reply to Peter Maydell
Quoted 57 lines · Peter Maydell
Quoted 56 lines · Laurent Vivier

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
index c8389f9..95b0aee 100644
@@ -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 -0
     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?

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
#6 lore raw

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 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?

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.

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

#7 lore raw

PATCH 2/19 target-i386: move back cpu_exec_init() to init

In reply to Laurent Vivier

We 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
index 125a10c..087c78d 100644
@@ -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
#8 lore raw

PATCH 3/19 target-ppc: move back cpu_exec_init() to init

In reply to Laurent Vivier

We 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
index 5e84e65..5eb2d3a 100644
@@ -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
#9 lore raw

PATCH 4/19 target-s390: move back cpu_exec_init() to init

In reply to Laurent Vivier

We 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")

CC Richard Henderson <[email protected]>
---
 target-s390x/cpu.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)
target-s390x/cpu.c +1 -10
index 20a88dd..74154a9 100644
@@ -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
#10 lore raw

PATCH 5/19 target-arm: move cpu_exec_realize() to realize function

In reply to Laurent Vivier

I'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
index 5fda716..7920fb0 100644
@@ -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
#11 lore raw

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_yet field as cpu_exec_init() is not called by arm_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 4c315c27 with
"arm1026-arm-cpu")

---
 target-arm/cpu.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)
target-arm/cpu.c +7 -12
index 5fda716..7920fb0 100644
@@ -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
#12 lore raw

PATCH 6/19 target-alpha: move cpu_exec_realize() to realize function

In reply to Laurent Vivier

I'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")

CC Richard Henderson <[email protected]>
---
 target-alpha/cpu.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
target-alpha/cpu.c +7 -8
index 19f2eb2..5d739c6 100644
@@ -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
#13 lore raw

PATCH 7/19 target-cris: move cpu_exec_realize() to realize function

In reply to Laurent Vivier

I'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")

CC Edgar E. Iglesias <[email protected]>
---
 target-cris/cpu.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
target-cris/cpu.c +7 -8
index 78753ed..e83d055 100644
@@ -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
#14 lore raw

PATCH 8/19 target-lm32: move cpu_exec_realize() to realize function

In reply to Laurent Vivier

I'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
index 4b93454..b835779 100644
@@ -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
#15 lore raw

PATCH 9/19 target-m68k: move cpu_exec_realize() to realize function

In reply to Laurent Vivier

I'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
index 307910a..0728e02 100644
@@ -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
#16 lore raw

PATCH 10/19 target-microblaze: move cpu_exec_realize() to realize function

In reply to Laurent Vivier

I'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")

CC Edgar E. Iglesias <[email protected]>
---
 target-microblaze/cpu.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
target-microblaze/cpu.c +7 -7
index 9ec2c9c..625ce71 100644
@@ -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
#17 lore raw

PATCH 11/19 target-mips: move cpu_exec_realize() to realize function

In reply to Laurent Vivier

I'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
index 8a42213..cac8ed6 100644
@@ -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
#18 lore raw

PATCH 12/19 target-moxie: move cpu_exec_realize() to realize function

In reply to Laurent Vivier

I'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
index 28beff1..51fa87a 100644
@@ -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
#19 lore raw

PATCH 13/19 target-openrisc: move cpu_exec_realize() to realize function

In reply to Laurent Vivier

I'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
index 1f2a084..bd7360f 100644
@@ -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
#20 lore raw

PATCH 14/19 target-sh4: move cpu_exec_realize() to realize function

In reply to Laurent Vivier

I'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
index f172516..c7ed4ea 100644
@@ -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
#21 lore raw

PATCH 15/19 target-sparc: move cpu_exec_realize() to realize function

In reply to Laurent Vivier

I'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")

CC Artyom Tarasenko <[email protected]>
---
 target-sparc/cpu.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
target-sparc/cpu.c +9 -9
index 77cc920..77979a0 100644
@@ -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
#22 lore raw

PATCH 16/19 target-tilegx: move cpu_exec_realize() to realize function

In reply to Laurent Vivier

I'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
index f7ec920..6be69ef 100644
@@ -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
#23 lore raw

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_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)

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
---
 target-tilegx/cpu.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
target-tilegx/cpu.c +7 -8
index f7ec920..6be69ef 100644
@@ -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.
#24 lore raw

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_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)

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.

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
---
 target-tilegx/cpu.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
target-tilegx/cpu.c +7 -8
index f7ec920..6be69ef 100644
@@ -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
#25 lore raw

Re: [Qemu-devel] [PATCH 16/19] target-tilegx: move cpu_exec_realize() to realize function

In reply to Chen Gang
Quoted 11 lines · Chen Gang
Quoted 5 lines · Laurent Vivier

I'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)

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.

See PATCH 1/19 exec: split cpu_exec_init()

Thanks,
Laurent

#26 lore raw

PATCH 17/19 target-tricore: move cpu_exec_realize() to realize function

In reply to Laurent Vivier

I'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")

CC Bastian Koppelmann <[email protected]>
---
 target-tricore/cpu.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
target-tricore/cpu.c +7 -8
index 2fd3325..6a57aa9 100644
@@ -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
#27 lore raw

PATCH 18/19 target-unicore32: move cpu_exec_realize() to realize function

In reply to Laurent Vivier

I'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
index 2e5466a..a98908a 100644
@@ -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
#28 lore raw

PATCH 19/19 target-xtensa: move cpu_exec_realize() to realize function

In reply to Laurent Vivier

I'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
index fc72726..79e7fa3 100644
@@ -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
#29 lore raw
In reply to Laurent Vivier
Quoted 16 lines · Laurent Vivier

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).

Quoted 7 lines

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.

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

#30 lore raw
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: 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.

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 indeed cpu_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->memory in cpu_exec_init()?

Because of OBJ_PROP_LINK_UNREF_ON_RELEASE, I think the reference is decreased when the object is released.

Laurent

#31 lore raw
In reply to Laurent Vivier
Quoted 7 lines · Laurent Vivier

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.

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), 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).

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 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
Signature · 1 line
Eduardo