Received: from eggs.gnu.org ([2001:4830:134:3::10]:47920) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1enZ7z-0000v6-0s for qemu-devel@nongnu.org; Sun, 18 Feb 2018 19:16:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1enZ7x-0004FU-Nn for qemu-devel@nongnu.org; Sun, 18 Feb 2018 19:16:18 -0500 Date: Mon, 19 Feb 2018 11:11:52 +1100 From: David Gibson Message-ID: <20180219001152.GB1109@umbus.fritz.box> References: <151880748615.9544.1095813823117296064.stgit@bahia.lan> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="NDin8bjvE/0mNLFQ" Content-Disposition: inline In-Reply-To: <151880748615.9544.1095813823117296064.stgit@bahia.lan> Subject: Re: [Qemu-devel] [PATCH] spapr: fix missing CPU core nodes in DT when running with TCG List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Greg Kurz Cc: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, =?iso-8859-1?Q?C=E9dric?= Le Goater --NDin8bjvE/0mNLFQ Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Feb 16, 2018 at 07:58:06PM +0100, Greg Kurz wrote: > Commit 5d0fb1508e2d "spapr: consolidate the VCPU id numbering logic > in a single place" introduced a helper to detect thread0 of a virtual > core based on its VCPU id. This is used to create CPU core nodes in > the DT, but it is broken in TCG. >=20 > $ qemu-system-ppc64 -nographic -accel tcg -machine dumpdtb=3Ddtb.bin \ > -smp cores=3D16,maxcpus=3D16,threads=3D1 > $ dtc -f -O dts dtb.bin | grep POWER8 > PowerPC,POWER8@0 { > PowerPC,POWER8@8 { >=20 > instead of the expected 16 cores that we get with KVM: >=20 > $ dtc -f -O dts dtb.bin | grep POWER8 > PowerPC,POWER8@0 { > PowerPC,POWER8@8 { > PowerPC,POWER8@10 { > PowerPC,POWER8@18 { > PowerPC,POWER8@20 { > PowerPC,POWER8@28 { > PowerPC,POWER8@30 { > PowerPC,POWER8@38 { > PowerPC,POWER8@40 { > PowerPC,POWER8@48 { > PowerPC,POWER8@50 { > PowerPC,POWER8@58 { > PowerPC,POWER8@60 { > PowerPC,POWER8@68 { > PowerPC,POWER8@70 { > PowerPC,POWER8@78 { >=20 > This happens because spapr_get_vcpu_id() maps VCPU ids to > cs->cpu_index in TCG mode. This confuses the code in > spapr_is_thread0_in_vcore(), since it assumes thread0 VCPU > ids to have a spapr->vsmt spacing. >=20 > spapr_get_vcpu_id(cpu) % spapr->vsmt =3D=3D 0 >=20 > Actually, there's no real reason to expose cs->cpu_index instead > of the VCPU id, since we also generate it with TCG. Also we already > set it explicitly in spapr_set_vcpu_id(), so there's no real reason > either to call kvm_arch_vcpu_id() with KVM. >=20 > This patch unifies spapr_get_vcpu_id() to always return the computed > VCPU id both in TCG and KVM. This is one step forward towards KVM<->TCG > migration. >=20 > Fixes: 5d0fb1508e2d > Reported-by: C=E9dric Le Goater > Signed-off-by: Greg Kurz Applied, thanks. > --- > hw/ppc/spapr.c | 8 +------- > 1 file changed, 1 insertion(+), 7 deletions(-) >=20 > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index 83c9d66dd56f..d6fd0e666e74 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -3810,13 +3810,7 @@ static void spapr_pic_print_info(InterruptStatsPro= vider *obj, > =20 > int spapr_get_vcpu_id(PowerPCCPU *cpu) > { > - CPUState *cs =3D CPU(cpu); > - > - if (kvm_enabled()) { > - return kvm_arch_vcpu_id(cs); > - } else { > - return cs->cpu_index; > - } > + return cpu->vcpu_id; > } > =20 > void spapr_set_vcpu_id(PowerPCCPU *cpu, int cpu_index, Error **errp) >=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 --NDin8bjvE/0mNLFQ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEdfRlhq5hpmzETofcbDjKyiDZs5IFAlqKFkUACgkQbDjKyiDZ s5JcTxAAiT7jnsUoiWz9y7QPI0HNgVz3w1Cj+sAJlK9VmDW40p0gWAv8+DC69dwp uEQVIllJqrnC+/yHPPJRVE4rY2ez9jVOLC5CNYpRU3NgeodPQughA+1ZBUvJtiIZ WvktCHJlHONZrfdL/BlxW67Arl/fmTh+mt+phgJHKdMwyp2ihctCuQtZBSvHnA/T GEQu8MqEncUtVjs+m+cOcPgNRuir5LxKWqI3WBad8RHZ6yG86SgrgTt3ZtjOFNc/ Qc4HFyDq13kCAZaV6pUiGI8IX1GEWgm/6Uvk9pQZwqw0Tg4ErVvY7zLLgN5oGUWU YDcMcXqeKOz2sLVU8GIbmgBx7DuglUMINfmz2KRHuzTBaYBDuXM46ei2L1+TTtqe Srk2YTyiTh7br5JuJcPCSIIdJUMuVexDi2Z0gb4k3pXUk09Bk9mAioAyejryQ3X2 jlobgk2b06O3wb4kpwwdlujhKX7YDp43fKK0grPLzIkwqbftd5vLK9HtmMhDBn6S G852UbOg1O8pEohaXw5U/r1L87Sb7PLj3HJT9s/mtAiqtgmRZFJ4uhOOKqmc7vWP vRlKeg65Uw9InCeIdVSOjFbNvaLbkyn0VndpW1FdsHqpEGPIQodlPj+xMdCP8Npd TmAF9j/lkWQQKWxA77SBohsw35zJrQvM63Ik71LbhSdOMRxK4xQ= =iEEe -----END PGP SIGNATURE----- --NDin8bjvE/0mNLFQ--