From nobody Sat Oct 25 09:03:10 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520309065868457.0259427538052; Mon, 5 Mar 2018 20:04:25 -0800 (PST) Received: from localhost ([::1]:52762 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1et3pn-0002qL-EZ for importer@patchew.org; Mon, 05 Mar 2018 23:04:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49141) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1et3nl-0001Nj-0h for qemu-devel@nongnu.org; Mon, 05 Mar 2018 23:02:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1et3nk-0004N6-6e for qemu-devel@nongnu.org; Mon, 05 Mar 2018 23:02:09 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:60965) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1et3nj-0004KS-8x; Mon, 05 Mar 2018 23:02:08 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3zwNQ069mHz9sgW; Tue, 6 Mar 2018 15:02:00 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1520308920; bh=N6izT8E1VadmMQ/UKuv2quiqRIGFm5ozSsigmTkVkXg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UD/k7w6rzNysUbD6b/fAQhH15aFxwsHYOM/mV2mzFfNCYi0VJrJYv08AubKhCSnU5 Lbr7AbEkA4led8o0srOKlvKOgi45GEaSbPSRvWxusqngTl5bA9bmIkhtcihQf9gms+ Ud6q9uqMMJDlLnGHxrpVxUuSkcpXiTG5mGArdJJU= From: David Gibson To: peter.maydell@linaro.org, groug@kaod.org Date: Tue, 6 Mar 2018 15:01:25 +1100 Message-Id: <20180306040154.3669-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180306040154.3669-1-david@gibson.dropbear.id.au> References: <20180306040154.3669-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 01/30] spapr: fix missing CPU core nodes in DT when running with TCG X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, David Gibson , qemu-ppc@nongnu.org, agraf@suse.de, surajjs@au1.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Greg Kurz 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. $ 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 { instead of the expected 16 cores that we get with KVM: $ 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 { 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. spapr_get_vcpu_id(cpu) % spapr->vsmt =3D=3D 0 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. 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. Fixes: 5d0fb1508e2d Reported-by: C=C3=A9dric Le Goater Signed-off-by: Greg Kurz Signed-off-by: David Gibson --- hw/ppc/spapr.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 83c9d66dd5..d6fd0e666e 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3810,13 +3810,7 @@ static void spapr_pic_print_info(InterruptStatsProvi= der *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 2.14.3