From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41161) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKyex-0007OI-Jn for qemu-devel@nongnu.org; Wed, 06 Jul 2016 22:03:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bKyet-0001uk-Gy for qemu-devel@nongnu.org; Wed, 06 Jul 2016 22:03:23 -0400 Date: Thu, 7 Jul 2016 11:59:06 +1000 From: David Gibson Message-ID: <20160707015906.GJ14675@voom.fritz.box> References: <146780713904.26232.12351310667258006783.stgit@bahia.lab.toulouse-stg.fr.ibm.com> <146780723427.26232.10779748351110554240.stgit@bahia.lab.toulouse-stg.fr.ibm.com> <20160706180616.40c8c2cc@bahia.lan> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="5me2qT3T17SWzdxI" Content-Disposition: inline In-Reply-To: <20160706180616.40c8c2cc@bahia.lan> Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH v3 4/7] ppc: open code cpu creation for machine types List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Greg Kurz Cc: Eduardo Habkost , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, Cedric Le Goater , Bharata B Rao , Scott Wood , Igor Mammedov --5me2qT3T17SWzdxI Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jul 06, 2016 at 06:06:16PM +0200, Greg Kurz wrote: > On Wed, 06 Jul 2016 14:14:25 +0200 > Greg Kurz wrote: >=20 > > If we want to generate cpu_dt_id in the machine code, this must occur > > before the cpu gets realized. We must open code the cpu creation to be > > able to do this. > >=20 > > This patch just does that. > >=20 > > Signed-off-by: Greg Kurz > > --- > > v3: don't parse cpu features as it is done in a previous patch > > --- > > hw/ppc/ppc.c | 32 +++++++++++++++++++++++++++++++- > > 1 file changed, 31 insertions(+), 1 deletion(-) > >=20 > > diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c > > index 313b3f0b9a51..0df32a9b3965 100644 > > --- a/hw/ppc/ppc.c > > +++ b/hw/ppc/ppc.c > > @@ -32,6 +32,7 @@ > > #include "sysemu/cpus.h" > > #include "hw/timer/m48t59.h" > > #include "qemu/log.h" > > +#include "qapi/error.h" > > #include "qemu/error-report.h" > > #include "qapi/error.h" > > #include "hw/loader.h" > > @@ -1354,7 +1355,36 @@ PowerPCCPU *ppc_get_vcpu_by_dt_id(int cpu_dt_id) > > =20 > > PowerPCCPU *ppc_cpu_init(const char *cpu_model) > > { > > - return POWERPC_CPU(cpu_generic_init(TYPE_POWERPC_CPU, cpu_model)); > > + PowerPCCPU *cpu; > > + ObjectClass *oc; > > + gchar **model_pieces; > > + Error *err =3D NULL; > > + > > + model_pieces =3D g_strsplit(cpu_model, ",", 2); > > + if (!model_pieces[0]) { > > + error_report("Invalid/empty CPU model name"); > > + return NULL; > > + } > > + > > + oc =3D cpu_class_by_name(TYPE_POWERPC_CPU, model_pieces[0]); > > + if (oc =3D=3D NULL) { > > + error_report("Unable to find CPU definition: %s", model_pieces= [0]); > > + goto out; > > + } > > + > > + cpu =3D POWERPC_CPU(object_new(object_class_get_name(oc))); > > + object_property_set_bool(OBJECT(cpu), true, "realized", &err); > > + > > +out: > > + g_strfreev(model_pieces); > > + > > + if (err !=3D NULL) { > > + error_report_err(err); > > + object_unref(OBJECT(cpu)); >=20 > cpu can be uninitialized here (thanks travis) >=20 > I will initialize cpu to NULL and do this: >=20 > if (cpu !=3D NULL) { > object_unref(OBJECT(cpu)); > } Good catch. > > + return NULL; > > + } > > + > > + return cpu; > > } > > =20 > > void ppc_cpu_parse_features(const char *cpu_model) > >=20 > >=20 >=20 --=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 --5me2qT3T17SWzdxI Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXfbdpAAoJEGw4ysog2bOSsUoP/iSOKyY8aktGPEOXWxQwxbXi jfa+IwKmNskwTXOgwumTOWNSREOUba2MrQ5+xgNrzmZPTtBFir3htKMgttTTFJj/ cJhsU++xcURcgK2kg0Y25cUk4jz12wn9sBkVXCqHhnJMjVpU73rUJ9PB2+pfgf0W KOWLJybUtyAaPvzxWKtu9gwpvwqT+5mFiV/nYH/f/GRWWZ6bBKkbQEQCEpMg8tkK sBvkmNDbGQ3iIaUuyG+NugIxfhJlsZQJCaU5Mrcfm8d2b7+AaWkZZSjjo934Cuc7 Ekj8020PSOJtlHdAGG5e3dX6dwCoaw8IEVSu+k73M9Wnk5XeILsbKut+Ml2Hbqzf XOAiQtcHt458opIIW4XzdABQbqGL0PsdNczmENzIJIc/T0cR31fOmglaYGYCF3xz //qn/u2rTMkDWlKTsvUnS1SsflAI6G35yHS3+4J3BahqawV6KhMq2UJjv2gf4GS+ dJbFrQ5v3pU8nF+FJiUTKgLziB+OaBa71E2XLn8+j3KCMF2bdMI5XOcM7U3inu3T cm7MmL0VjT3+GR7DHSsVCUzirhzfYID5g2+p/F/py0lGD4uCjGyba7oAG2aer9mm bFW2uUog1Ktyh5/krdB3rHgase+50180JUOjf6qvGs5MDtr/ueWUkt9xekjaiqdm 0EimHM3QEzUYaJ21YugP =GssX -----END PGP SIGNATURE----- --5me2qT3T17SWzdxI--