From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44184) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uw0gz-0000bT-6H for qemu-devel@nongnu.org; Sun, 07 Jul 2013 21:56:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uw0gu-0001Mm-Su for qemu-devel@nongnu.org; Sun, 07 Jul 2013 21:56:41 -0400 Date: Mon, 8 Jul 2013 11:09:17 +1000 From: David Gibson Message-ID: <20130708010917.GD2696@voom.redhat.com> References: <1373118856-30171-1-git-send-email-aik@ozlabs.ru> <1373118856-30171-19-git-send-email-aik@ozlabs.ru> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="n/aVsWSeQ4JHkrmm" Content-Disposition: inline In-Reply-To: <1373118856-30171-19-git-send-email-aik@ozlabs.ru> Subject: Re: [Qemu-devel] [PATCH 18/19] target-ppc: Enhance the CPU node labels for the guest device tree for pseries. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexey Kardashevskiy Cc: Anthony Liguori , Alexander Graf , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, Prerna Saxena , Paul Mackerras --n/aVsWSeQ4JHkrmm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Jul 06, 2013 at 11:54:15PM +1000, Alexey Kardashevskiy wrote: > From: Prerna Saxena >=20 > In absence of a -CPU parameter in the qemu command line, the nodes of > KVM-enabled guest device tree look like this : >=20 > /proc/device-tree/cpus/HOST@0/... > /proc/device-tree/cpus/HOST@4/... >=20 > This patch replaces this obscure 'HOST' label with a more descriptive lab= el. > This is gathered by first identifying the PVR of the host, and then deter= mining > the host CPU alias which corresponds to the model indicated by this PVR. >=20 > Sample Final outcome for an KVM-enabled pseries guest running on POWER7: > /proc/device-tree/cpus/PowerPC,POWER7@0/... > /proc/device-tree/cpus/PowerPC,POWER7@4/... >=20 > This also helps userspace tools like ppc64_cpu, which expect the device t= ree > to be in this format in the guest. >=20 > Signed-off-by: Prerna Saxena > Signed-off-by: Alexey Kardashevskiy > --- > hw/ppc/spapr.c | 17 ++++++++++++++--- > target-ppc/cpu-qom.h | 1 + > target-ppc/translate_init.c | 28 ++++++++++++++++++++++++++++ > 3 files changed, 43 insertions(+), 3 deletions(-) >=20 > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index 26dd3f7..5ecd81b 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -80,6 +80,7 @@ > =20 > #define HTAB_SIZE(spapr) (1ULL << ((spapr)->htab_shift)) > =20 > +#define PPC_DEVTREE_STR "PowerPC," I thought under PowerVM, modern CPUs showed up as simply e.g. "POWER7@0" not "PowerPC,POWER7@0". Have I misremembered? > sPAPREnvironment *spapr; > =20 > int spapr_allocate_irq(int hint, bool lsi) > @@ -296,9 +297,12 @@ static void *spapr_create_fdt_skel(const char *cpu_m= odel, > _FDT((fdt_property_cell(fdt, "#address-cells", 0x1))); > _FDT((fdt_property_cell(fdt, "#size-cells", 0x0))); > =20 > - modelname =3D g_strdup(cpu_model); > + /* device tree nodes must look like this : > + * PowerPC,CPU_ALIAS@0 > + */ > + modelname =3D g_strdup_printf(PPC_DEVTREE_STR "%s", cpu_model); > =20 > - for (i =3D 0; i < strlen(modelname); i++) { > + for (i =3D strlen(PPC_DEVTREE_STR); i < strlen(modelname); i++) { > modelname[i] =3D toupper(modelname[i]); > } > =20 > @@ -1112,7 +1116,7 @@ static void ppc_spapr_init(QEMUMachineInitArgs *arg= s) > MemoryRegion *sysmem =3D get_system_memory(); > MemoryRegion *ram =3D g_new(MemoryRegion, 1); > hwaddr rma_alloc_size; > - uint32_t initrd_base =3D 0; > + uint32_t initrd_base =3D 0, pvr =3D 0; > long kernel_size =3D 0, initrd_size =3D 0; > long load_limit, rtas_limit, fw_size; > char *filename; > @@ -1342,6 +1346,13 @@ static void ppc_spapr_init(QEMUMachineInitArgs *ar= gs) > register_savevm_live(NULL, "spapr/htab", -1, 1, > &savevm_htab_handlers, spapr); > =20 > + /* Ensure that cpu_model is correctly reflected for a KVM guest */ > + if (kvm_enabled() && !strcmp(cpu_model, "host")) { > + asm ("mfpvr %0" > + : "=3Dr"(pvr)); > + cpu_model =3D ppc_cpu_alias_by_pvr(pvr); This needs to be protected by an ifdef CONFIG_KVM or similar. If the compiler optimization level is turned down, so that it doesn't recognize that the kvm_enabled() is always false, then this could attempt to compile the ppc asm instructions on an x86 (or whatever) host. --=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 --n/aVsWSeQ4JHkrmm Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.13 (GNU/Linux) iEYEARECAAYFAlHaET0ACgkQaILKxv3ab8a3yACghP2hjxYe5qiVGT3S6hB6fd6c TWsAniUYUPfh3IxVtNg5uoCo1o7CQ7Xk =OzkK -----END PGP SIGNATURE----- --n/aVsWSeQ4JHkrmm--