From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48433) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHQMj-0001Ux-Nh for qemu-devel@nongnu.org; Mon, 27 Jun 2016 02:49:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHQMi-0003uz-AX for qemu-devel@nongnu.org; Mon, 27 Jun 2016 02:49:53 -0400 Date: Mon, 27 Jun 2016 16:51:34 +1000 From: David Gibson Message-ID: <20160627065134.GR4242@voom.fritz.box> References: <1467008386-21995-1-git-send-email-bharata@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="PY8tzLeNxmyMVNR3" Content-Disposition: inline In-Reply-To: <1467008386-21995-1-git-send-email-bharata@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [PATCH v2 1/1] spapr: Set compat type for CPUs of a core List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Bharata B Rao Cc: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, imammedo@redhat.com, thuth@redhat.com, ehabkost@redhat.com --PY8tzLeNxmyMVNR3 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jun 27, 2016 at 11:49:46AM +0530, Bharata B Rao wrote: > Compat CPU type is typically specified on -cpu cmdline option like: > -cpu host,compat=3Dpower7 or -cpu POWER8E,compat=3Dpower7 etc. When > compat is specified on -cpu cmdline, apply the same to all the > CPUs that get created as part of CPU core devices. >=20 > This patch takes care of compat property that is specified with > -cpu cmdline option only. The other way to specify this property > is via -global cmdline option and that usage isn't addressed by > this patch because -global is already broken for some CPU class > in PowerPC. There are two issues with using -global on CPU class. >=20 > - We specify alias names for CPUs commonly and use of alias names > won't work with -global seamlessly. For eg, When "-cpu host" is > specified, the actual CPU type that gets created > is host-powerpc64-cpu. Hence specifying -global host.compat=3Dpower7 > will not work, so it has to be -global host-powerpc64-cpu.compat=3Dpowe= r7. >=20 > - PowerPC class names have . (dot) and opts parsing doesn't like it. > Specifying -global POWER8E_v2.1-powerpc64-cpu.compat=3Dpower7 will not > work as the driver name gets extracted as POWER8E_v2 and hence setting > of global property fails. >=20 > The above two aspects could be considered/fixed separately from this > patch as this patch allows existing uses of -cpu cpuname,compat=3D to > work correctly after the introducton of sPAPR CPU cores. >=20 > Signed-off-by: Bharata B Rao > --- > Changes in v2: > - No need for a separate property named compat for cores. > - Simplified spapr_get_cpu_compat_type() based on David's review. I'm still not seeing why this is actually necessary. If the compat property is specified with -global, it will automatically be propagated to all threads without core intervention, yes? So shouldn't we just make the -cpu fallback effectively set the same -global property, rather than bouncing it through the core object? >=20 > v1: https://lists.gnu.org/archive/html/qemu-devel/2016-06/msg06279.html >=20 > hw/ppc/spapr_cpu_core.c | 32 ++++++++++++++++++++++++++++++++ > 1 file changed, 32 insertions(+) >=20 > diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c > index 3a5da09..e8873fd 100644 > --- a/hw/ppc/spapr_cpu_core.c > +++ b/hw/ppc/spapr_cpu_core.c > @@ -96,6 +96,28 @@ char *spapr_get_cpu_core_type(const char *model) > return core_type; > } > =20 > +/* > + * Returns the CPU compat type specified in -cpu @model. > + */ > +static char *spapr_get_cpu_compat_type(const char *model) > +{ > + char *model_str =3D g_strdup(model); > + char *featurestr, *compat =3D NULL; > + > + featurestr =3D model_str ? strtok(model_str, ",") : NULL; > + while (featurestr) { > + if (!strncmp(featurestr, "compat=3D", 7)) { > + compat =3D g_strdup(featurestr + 7); > + goto out; > + } > + featurestr =3D strtok(NULL, ","); > + } > + > +out: > + g_free(model_str); > + return compat; > +} > + > static void spapr_core_release(DeviceState *dev, void *opaque) > { > sPAPRCPUCore *sc =3D SPAPR_CPU_CORE(OBJECT(dev)); > @@ -285,6 +307,8 @@ static void spapr_cpu_core_realize(DeviceState *dev, = Error **errp) > CPUCore *cc =3D CPU_CORE(OBJECT(dev)); > const char *typename =3D object_class_get_name(sc->cpu_class); > size_t size =3D object_type_get_instance_size(typename); > + MachineState *machine =3D MACHINE(qdev_get_machine()); > + char *compat =3D spapr_get_cpu_compat_type(machine->cpu_model); > Error *local_err =3D NULL; > Object *obj; > int i; > @@ -300,11 +324,18 @@ static void spapr_cpu_core_realize(DeviceState *dev= , Error **errp) > if (local_err) { > goto err; > } > + if (compat) { > + object_property_set_str(obj, compat, "compat", &local_err); > + if (local_err) { > + goto err; > + } > + } > } > object_child_foreach(OBJECT(dev), spapr_cpu_core_realize_child, &loc= al_err); > if (local_err) { > goto err; > } else { > + g_free(compat); > return; > } > =20 > @@ -315,6 +346,7 @@ err: > i--; > } > g_free(sc->threads); > + g_free(compat); > error_propagate(errp, local_err); > } > =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 --PY8tzLeNxmyMVNR3 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXcMz2AAoJEGw4ysog2bOSgrsQAMVAF69XYSp56mIM6LU1OhGp WLGCz4h0KGfH+y7H2uYm/+2jMlf1xNogHmzwrcxobtHrt6B59+YvRr9aSzNlKT73 jgOhC/OPxhaPHHh6L/0lRjcl5mTckh9yukX5jU7STAnJVZP3pNZY6q+g9olZe0Ka dCDO4zAtSW1PeioWS/cEQoJlNNmjVbHiqZoTGLqGRhVLb6NuQpEVxoeNDI4Fij4q +INxRq5SEHQg1bdo+4nQvOdl6dPIdB1SJ/rkRolY+5rxdrQnFWgcC0mqOvHtCrqj e1VECgocMbqP2Ib8cEJ4BNAjtPDedH+6vSjRcpN7ZqIPYlIBP3fD0Pum8x+oUEcH cVPGW4Lomtid99r+Ffe8MpYEOLTX3haTl7xLLg2LAXN5s2EJSPSUxsB5TMPWLyQp U06IJf2F4t/IUJK78yf265yOBqFhv4KOb0H+7YInKnQoibvuHGPWqL+DL5lEBEr/ he3uQ2v6oOioVqjWkr2xQSPyNlP04O3hifXipmZggN2g4MYhtpKejzhHuus63bB8 m/F+dI2KAehLuS15Fa2kOqlmm5FHg5KUIljHqtN6q9/CSgT1pccO4YSevg8ZL4E4 YHLx4eNOSz6YwE4QKU9shXQOqXBOR3Vdl2H+m3o/Z4QHwbtDxO56ie9RYCCnw1z1 unNrcS80CBs78Psn0YwG =HYL2 -----END PGP SIGNATURE----- --PY8tzLeNxmyMVNR3--