From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41160) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKyex-0007OH-JW 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-0001ul-HP for qemu-devel@nongnu.org; Wed, 06 Jul 2016 22:03:23 -0400 Date: Thu, 7 Jul 2016 11:54:12 +1000 From: David Gibson Message-ID: <20160707015412.GI14675@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> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="+PbGPm1eXpwOoWkI" Content-Disposition: inline In-Reply-To: <146780723427.26232.10779748351110554240.stgit@bahia.lab.toulouse-stg.fr.ibm.com> Subject: Re: [Qemu-devel] [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 , Benjamin Herrenschmidt , qemu-devel@nongnu.org, Alexander Graf , qemu-ppc@nongnu.org, Cedric Le Goater , Bharata B Rao , Scott Wood , Igor Mammedov --+PbGPm1eXpwOoWkI Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jul 06, 2016 at 02:14:25PM +0200, Greg Kurz wrote: > 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 Reviewed-by: David Gibson > --- > 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)); > + return NULL; > + } > + > + return cpu; > } > =20 > void ppc_cpu_parse_features(const char *cpu_model) >=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 --+PbGPm1eXpwOoWkI Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXfbZEAAoJEGw4ysog2bOS2xUQAN6GFGQy2VujjbxNVs1xvVoo pg+HlKpCsopRxDGVVOE6+wjw9irg7lQo70IoY+nTIbh5sBGj3QYiz7r3qz/5qFNc c/gvz5azx+/iEuKlLa2DoN3Hk5KKIZRQYXWkAI9I9X/DDhpXS0rMXrHuFUWNr2xE IGlyXbN5g8c9rJz1r2JHIUkAVXDFR8X7x1NvKEEwEbWcgbYHVWiPHDErUxja9Qm8 mZXRxCUPGQsvLSO00Zsl8uhSoLNdp+0OZ7HImHbA8necUiUVGibiEXk5YvcbECSe USCkk4WyWHK/geWWtqs0/kQRkd/+asmMcAFdCxLCoAd2v/bNgeg7Enx4OEiwQaRd Cr7E1Xjam3vlsJPb7LZ7mBvfhY9HC+R5SNN+AWTgKmmMJDv3N04bDCQ5yVLRIfaf wb1mDvxbKwa7HuF0BvaRr0/BjiryJgl31zsXuE1c1ZbnecZadP9tr/shb6aNRn2P bJSbHAVBj6zWt0IK6o5Cz1b7rE+6/dbrW54Fea9Bi3cqimxy+iHbPV3eLkhVeKL4 lQGiKuAm6p+QN/go3wx1yBdTynCG/VhSB3UYq2CuZH52AD5JQ/vrMRdHI7ffVAlV c4RtO4CGJTIl/GVrOmXm5rmjSFgUnfzFJnjL0cj86+jNe3bc7eKnoL+ZQxkIQaMs ubGkJNUIvo+cWnImlY/H =XHwF -----END PGP SIGNATURE----- --+PbGPm1eXpwOoWkI--