From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41806) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1butoG-0007IF-G1 for qemu-devel@nongnu.org; Fri, 14 Oct 2016 00:09:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1butoA-0000QQ-W1 for qemu-devel@nongnu.org; Fri, 14 Oct 2016 00:09:27 -0400 Received: from ozlabs.org ([103.22.144.67]:57105) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1butoA-0000P2-Cn for qemu-devel@nongnu.org; Fri, 14 Oct 2016 00:09:22 -0400 Date: Fri, 14 Oct 2016 15:05:41 +1100 From: David Gibson Message-ID: <20161014040541.GC28562@umbus> References: <1476375902-11715-1-git-send-email-lvivier@redhat.com> <1476375902-11715-2-git-send-email-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="H8ygTp4AXg6deix2" Content-Disposition: inline In-Reply-To: <1476375902-11715-2-git-send-email-lvivier@redhat.com> Subject: Re: [Qemu-devel] [PATCH v2 01/20] exec: split cpu_exec_init() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Laurent Vivier Cc: qemu-devel@nongnu.org, Paolo Bonzini , Peter Maydell , Eduardo Habkost , Bharata B Rao , Markus Armbruster , Matthew Rosato --H8ygTp4AXg6deix2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Oct 13, 2016 at 06:24:43PM +0200, Laurent Vivier wrote: > 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. >=20 > Put in cpu_exec_init() what initializes the CPU, > in cpu_exec_realize() what adds it to the environment. >=20 > Remove error parameter from cpu_exec_init() as it can't fail. >=20 > Rename cpu_exec_exit() with cpu_exec_unrealize(): > cpu_exec_exit() is undoing what it has been done by cpu_exec_realize(), so > call it cpu_exec_unrealize(). >=20 > CC: Paolo Bonzini > Signed-off-by: Laurent Vivier Reviewed-by: David Gibson > --- > exec.c | 12 +++++++----- > include/exec/exec-all.h | 3 ++- > include/qom/cpu.h | 2 +- > qom/cpu.c | 2 +- > target-alpha/cpu.c | 3 ++- > target-arm/cpu.c | 3 ++- > target-cris/cpu.c | 3 ++- > target-i386/cpu.c | 3 ++- > target-lm32/cpu.c | 3 ++- > target-m68k/cpu.c | 3 ++- > target-microblaze/cpu.c | 3 ++- > target-mips/cpu.c | 3 ++- > target-moxie/cpu.c | 3 ++- > target-openrisc/cpu.c | 3 ++- > target-ppc/translate_init.c | 5 +++-- > target-s390x/cpu.c | 3 ++- > target-sh4/cpu.c | 3 ++- > target-sparc/cpu.c | 3 ++- > target-tilegx/cpu.c | 3 ++- > target-tricore/cpu.c | 3 ++- > target-unicore32/cpu.c | 3 ++- > target-xtensa/cpu.c | 3 ++- > 22 files changed, 48 insertions(+), 27 deletions(-) >=20 > diff --git a/exec.c b/exec.c > index 374c364..885dc79 100644 > --- a/exec.c > +++ b/exec.c > @@ -596,7 +596,7 @@ AddressSpace *cpu_get_address_space(CPUState *cpu, in= t asidx) > } > #endif > =20 > -void cpu_exec_exit(CPUState *cpu) > +void cpu_exec_unrealize(CPUState *cpu) > { > CPUClass *cc =3D CPU_GET_CLASS(cpu); > =20 > @@ -610,11 +610,8 @@ void cpu_exec_exit(CPUState *cpu) > } > } > =20 > -void cpu_exec_init(CPUState *cpu, Error **errp) > +void cpu_exec_init(CPUState *cpu) > { > - CPUClass *cc ATTRIBUTE_UNUSED =3D CPU_GET_CLASS(cpu); > - Error *local_err ATTRIBUTE_UNUSED =3D NULL; > - > cpu->as =3D NULL; > cpu->num_ases =3D 0; > =20 > @@ -635,6 +632,11 @@ void cpu_exec_init(CPUState *cpu, Error **errp) > cpu->memory =3D system_memory; > object_ref(OBJECT(cpu->memory)); > #endif > +} > + > +void cpu_exec_realize(CPUState *cpu, Error **errp) > +{ > + CPUClass *cc ATTRIBUTE_UNUSED =3D CPU_GET_CLASS(cpu); > =20 > cpu_list_add(cpu); > =20 > diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h > index 336a57c..b42533e 100644 > --- a/include/exec/exec-all.h > +++ b/include/exec/exec-all.h > @@ -57,7 +57,8 @@ TranslationBlock *tb_gen_code(CPUState *cpu, > uint32_t flags, > int cflags); > =20 > -void cpu_exec_init(CPUState *cpu, Error **errp); > +void cpu_exec_init(CPUState *cpu); > +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); > =20 > diff --git a/include/qom/cpu.h b/include/qom/cpu.h > index 6d481a1..4962980 100644 > --- a/include/qom/cpu.h > +++ b/include/qom/cpu.h > @@ -946,7 +946,7 @@ AddressSpace *cpu_get_address_space(CPUState *cpu, in= t asidx); > =20 > void QEMU_NORETURN cpu_abort(CPUState *cpu, const char *fmt, ...) > GCC_FMT_ATTR(2, 3); > -void cpu_exec_exit(CPUState *cpu); > +void cpu_exec_unrealize(CPUState *cpu); > =20 > #ifdef CONFIG_SOFTMMU > extern const struct VMStateDescription vmstate_cpu_common; > diff --git a/qom/cpu.c b/qom/cpu.c > index c40f774..39590e1 100644 > --- a/qom/cpu.c > +++ b/qom/cpu.c > @@ -367,7 +367,7 @@ static void cpu_common_initfn(Object *obj) > static void cpu_common_finalize(Object *obj) > { > CPUState *cpu =3D CPU(obj); > - cpu_exec_exit(cpu); > + cpu_exec_unrealize(CPU(obj)); > g_free(cpu->trace_dstate); > } > =20 > diff --git a/target-alpha/cpu.c b/target-alpha/cpu.c > index 6d01d7f..98761d7 100644 > --- a/target-alpha/cpu.c > +++ b/target-alpha/cpu.c > @@ -266,7 +266,8 @@ static void alpha_cpu_initfn(Object *obj) > CPUAlphaState *env =3D &cpu->env; > =20 > cs->env_ptr =3D env; > - cpu_exec_init(cs, &error_abort); > + cpu_exec_init(cs); > + cpu_exec_realize(cs, &error_abort); > tlb_flush(cs, 1); > =20 > alpha_translate_init(); > diff --git a/target-arm/cpu.c b/target-arm/cpu.c > index 1b9540e..7e58134 100644 > --- a/target-arm/cpu.c > +++ b/target-arm/cpu.c > @@ -444,7 +444,8 @@ static void arm_cpu_initfn(Object *obj) > uint32_t Aff1, Aff0; > =20 > cs->env_ptr =3D &cpu->env; > - cpu_exec_init(cs, &error_abort); > + cpu_exec_init(cs); > + cpu_exec_realize(cs, &error_abort); > cpu->cp_regs =3D g_hash_table_new_full(g_int_hash, g_int_equal, > g_free, g_free); > =20 > diff --git a/target-cris/cpu.c b/target-cris/cpu.c > index d680cfb..e28abc1 100644 > --- a/target-cris/cpu.c > +++ b/target-cris/cpu.c > @@ -187,7 +187,8 @@ static void cris_cpu_initfn(Object *obj) > static bool tcg_initialized; > =20 > cs->env_ptr =3D env; > - cpu_exec_init(cs, &error_abort); > + cpu_exec_init(cs); > + cpu_exec_realize(cs, &error_abort); > =20 > env->pregs[PR_VR] =3D ccc->vr; > =20 > diff --git a/target-i386/cpu.c b/target-i386/cpu.c > index 1c57fce..b977130 100644 > --- a/target-i386/cpu.c > +++ b/target-i386/cpu.c > @@ -3158,7 +3158,8 @@ static void x86_cpu_realizefn(DeviceState *dev, Err= or **errp) > cpu->phys_bits =3D 32; > } > } > - cpu_exec_init(cs, &error_abort); > + cpu_exec_init(cs); > + cpu_exec_realize(cs, &error_abort); > =20 > if (tcg_enabled()) { > tcg_x86_init(); > diff --git a/target-lm32/cpu.c b/target-lm32/cpu.c > index a783d46..147cc60 100644 > --- a/target-lm32/cpu.c > +++ b/target-lm32/cpu.c > @@ -160,7 +160,8 @@ static void lm32_cpu_initfn(Object *obj) > static bool tcg_initialized; > =20 > cs->env_ptr =3D env; > - cpu_exec_init(cs, &error_abort); > + cpu_exec_init(cs); > + cpu_exec_realize(cs, &error_abort); > =20 > env->flags =3D 0; > =20 > diff --git a/target-m68k/cpu.c b/target-m68k/cpu.c > index 116b784..2768bbb 100644 > --- a/target-m68k/cpu.c > +++ b/target-m68k/cpu.c > @@ -176,7 +176,8 @@ static void m68k_cpu_initfn(Object *obj) > static bool inited; > =20 > cs->env_ptr =3D env; > - cpu_exec_init(cs, &error_abort); > + cpu_exec_init(cs); > + cpu_exec_realize(cs, &error_abort); > =20 > if (tcg_enabled() && !inited) { > inited =3D true; > diff --git a/target-microblaze/cpu.c b/target-microblaze/cpu.c > index 8edc00a..71fd5fc 100644 > --- a/target-microblaze/cpu.c > +++ b/target-microblaze/cpu.c > @@ -199,7 +199,8 @@ static void mb_cpu_initfn(Object *obj) > static bool tcg_initialized; > =20 > cs->env_ptr =3D env; > - cpu_exec_init(cs, &error_abort); > + cpu_exec_init(cs); > + cpu_exec_realize(cs, &error_abort); > =20 > set_float_rounding_mode(float_round_nearest_even, &env->fp_status); > =20 > diff --git a/target-mips/cpu.c b/target-mips/cpu.c > index 64ad112..1154d11 100644 > --- a/target-mips/cpu.c > +++ b/target-mips/cpu.c > @@ -138,7 +138,8 @@ static void mips_cpu_initfn(Object *obj) > CPUMIPSState *env =3D &cpu->env; > =20 > cs->env_ptr =3D env; > - cpu_exec_init(cs, &error_abort); > + cpu_exec_init(cs); > + cpu_exec_realize(cs, &error_abort); > =20 > if (tcg_enabled()) { > mips_tcg_init(); > diff --git a/target-moxie/cpu.c b/target-moxie/cpu.c > index 50a0899..c9eed19 100644 > --- a/target-moxie/cpu.c > +++ b/target-moxie/cpu.c > @@ -75,7 +75,8 @@ static void moxie_cpu_initfn(Object *obj) > static int inited; > =20 > cs->env_ptr =3D &cpu->env; > - cpu_exec_init(cs, &error_abort); > + cpu_exec_init(cs); > + cpu_exec_realize(cs, &error_abort); > =20 > if (tcg_enabled() && !inited) { > inited =3D 1; > diff --git a/target-openrisc/cpu.c b/target-openrisc/cpu.c > index 155913f..74d52bf 100644 > --- a/target-openrisc/cpu.c > +++ b/target-openrisc/cpu.c > @@ -95,7 +95,8 @@ static void openrisc_cpu_initfn(Object *obj) > static int inited; > =20 > cs->env_ptr =3D &cpu->env; > - cpu_exec_init(cs, &error_abort); > + cpu_exec_init(cs); > + cpu_exec_realize(cs, &error_abort); > =20 > #ifndef CONFIG_USER_ONLY > cpu_openrisc_mmu_init(cpu); > diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c > index b66b40b..094f28a 100644 > --- a/target-ppc/translate_init.c > +++ b/target-ppc/translate_init.c > @@ -9678,7 +9678,8 @@ static void ppc_cpu_realizefn(DeviceState *dev, Err= or **errp) > } > #endif > =20 > - cpu_exec_init(cs, &local_err); > + cpu_exec_init(cs); > + cpu_exec_realize(cs, &local_err); > if (local_err !=3D NULL) { > error_propagate(errp, local_err); > return; > @@ -9910,7 +9911,7 @@ static void ppc_cpu_unrealizefn(DeviceState *dev, E= rror **errp) > opc_handler_t **table, **table_2; > int i, j, k; > =20 > - cpu_exec_exit(CPU(dev)); > + cpu_exec_unrealize(CPU(dev)); > =20 > for (i =3D 0; i < PPC_CPU_OPCODES_LEN; i++) { > if (env->opcodes[i] =3D=3D &invalid_handler) { > diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c > index 35ae2ce..4339da1 100644 > --- a/target-s390x/cpu.c > +++ b/target-s390x/cpu.c > @@ -207,7 +207,8 @@ static void s390_cpu_realizefn(DeviceState *dev, Erro= r **errp) > goto out; > } > =20 > - cpu_exec_init(cs, &err); > + cpu_exec_init(cs); > + cpu_exec_realize(cs, &err); > if (err !=3D NULL) { > goto out; > } > diff --git a/target-sh4/cpu.c b/target-sh4/cpu.c > index f589532..60689c7 100644 > --- a/target-sh4/cpu.c > +++ b/target-sh4/cpu.c > @@ -258,7 +258,8 @@ static void superh_cpu_initfn(Object *obj) > CPUSH4State *env =3D &cpu->env; > =20 > cs->env_ptr =3D env; > - cpu_exec_init(cs, &error_abort); > + cpu_exec_init(cs); > + cpu_exec_realize(cs, &error_abort); > =20 > env->movcal_backup_tail =3D &(env->movcal_backup); > =20 > diff --git a/target-sparc/cpu.c b/target-sparc/cpu.c > index 800a25a..135f30c 100644 > --- a/target-sparc/cpu.c > +++ b/target-sparc/cpu.c > @@ -814,7 +814,8 @@ static void sparc_cpu_initfn(Object *obj) > CPUSPARCState *env =3D &cpu->env; > =20 > cs->env_ptr =3D env; > - cpu_exec_init(cs, &error_abort); > + cpu_exec_init(cs); > + cpu_exec_realize(cs, &error_abort); > =20 > if (tcg_enabled()) { > gen_intermediate_code_init(env); > diff --git a/target-tilegx/cpu.c b/target-tilegx/cpu.c > index 7017cb6..ae6ea6e 100644 > --- a/target-tilegx/cpu.c > +++ b/target-tilegx/cpu.c > @@ -107,7 +107,8 @@ static void tilegx_cpu_initfn(Object *obj) > static bool tcg_initialized; > =20 > cs->env_ptr =3D env; > - cpu_exec_init(cs, &error_abort); > + cpu_exec_init(cs); > + cpu_exec_realize(cs, &error_abort); > =20 > if (tcg_enabled() && !tcg_initialized) { > tcg_initialized =3D true; > diff --git a/target-tricore/cpu.c b/target-tricore/cpu.c > index 35d4ee4..43f444f 100644 > --- a/target-tricore/cpu.c > +++ b/target-tricore/cpu.c > @@ -95,7 +95,8 @@ static void tricore_cpu_initfn(Object *obj) > CPUTriCoreState *env =3D &cpu->env; > =20 > cs->env_ptr =3D env; > - cpu_exec_init(cs, &error_abort); > + cpu_exec_init(cs); > + cpu_exec_realize(cs, &error_abort); > =20 > if (tcg_enabled()) { > tricore_tcg_init(); > diff --git a/target-unicore32/cpu.c b/target-unicore32/cpu.c > index e7a4984..ffc01bd 100644 > --- a/target-unicore32/cpu.c > +++ b/target-unicore32/cpu.c > @@ -116,7 +116,8 @@ static void uc32_cpu_initfn(Object *obj) > static bool inited; > =20 > cs->env_ptr =3D env; > - cpu_exec_init(cs, &error_abort); > + cpu_exec_init(cs); > + cpu_exec_realize(cs, &error_abort); > =20 > #ifdef CONFIG_USER_ONLY > env->uncached_asr =3D ASR_MODE_USER; > diff --git a/target-xtensa/cpu.c b/target-xtensa/cpu.c > index 5ad08a2..2719b73 100644 > --- a/target-xtensa/cpu.c > +++ b/target-xtensa/cpu.c > @@ -117,7 +117,8 @@ static void xtensa_cpu_initfn(Object *obj) > =20 > cs->env_ptr =3D env; > env->config =3D xcc->config; > - cpu_exec_init(cs, &error_abort); > + cpu_exec_init(cs); > + cpu_exec_realize(cs, &error_abort); > =20 > if (tcg_enabled() && !tcg_inited) { > tcg_inited =3D true; --=20 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 --H8ygTp4AXg6deix2 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJYAFmTAAoJEGw4ysog2bOSfgEQALwGQ06NmaElZvvfZpYr/h0f FSrT6Mlgn2MSh+7VxsxQzZ+N/wvo9Nmk1yxjRdcMee1RyHuAHK/JZdeg1TkX5Ex/ CBM/ffcFNouHE1Z3O1rv40JzjVPrqgUPIzjRAm8oX1f617B1hejkhdG4YZHXdLm9 t8v+uTqGApnrj+a3pyjLst9gMVR6RjXZExOmgZHiyygVRmo1zK++wuWi3Vs96Pxi WO0g9CeLuH/TjujVZt2TPWcg6ThSIpPPE9L0JbwbUPCkH9bSFqkvEbh4wa7N8aYv rmQDiAg2Vdhgz697GruLzg3iUuABKnTdZ4ABHBseMM0YaPSmUQe8WI7mcQB2VuEw pzGVgPwTKIKQJMaXBu9xyxJ9DcghknRAzXgTG0k3NBwmtBFKPL5Cp8WVhZ1+9Fbd plJJLLLRi5zAt9W+W3DmMD1tWIKCwBJEC8KbDMzVAFIW0vYtU+paO3oKhFl9pqeS ysRzP/aYnRkOsYsdj8v+mfLqdg5NLk8xl+x0+HCVehb/8nd0Z2odoAKOAZB0GNzB 9c+E6rdU5/GWjPUvjh+BGG4X1fpi7tlp8/RcHWn6i6Cruf/udnXbB7atTpPpSS6V +HdUgS0174kY1ju3v0hvCJoOFqCp7rtXL9KADwFa9x/FrKNSmLFvsNPoPKuq2NGv yXPkS6a7ezoORoPlB5U7 =RKy+ -----END PGP SIGNATURE----- --H8ygTp4AXg6deix2--