From nobody Mon Feb 9 23:01:00 2026 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 (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 152937415776489.1936160465383; Mon, 18 Jun 2018 19:09:17 -0700 (PDT) Received: from localhost ([::1]:38508 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV656-0002CG-V7 for importer@patchew.org; Mon, 18 Jun 2018 22:09:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45042) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5hB-0000iS-Hq for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5hA-0007xg-J8 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:33 -0400 Received: from mail-oi0-x241.google.com ([2607:f8b0:4003:c06::241]:39684) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5hA-0007x3-Dt; Mon, 18 Jun 2018 21:44:32 -0400 Received: by mail-oi0-x241.google.com with SMTP id t22-v6so16699647oih.6; Mon, 18 Jun 2018 18:44:32 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id d38-v6sm11477836otc.44.2018.06.18.18.44.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:44:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XBIIn2zPumrey8jrcEZBqbza6n+jON531yb8z6m6xwk=; b=Zx9UIs0S2CmTKN5q6il6+CueIFlIZCJN6N1srZ0uBgjgIGrJ9Bs1nsB+8/0IAgqu9C lTbVKcLJJ/FliDyiQhwbGaAg/YziqeWl2Tiywe365ldvDe6Rh7eBD0dVdXWXEwIb3QUB 3KChPd8AgMMnDgNVc8OEFEzhTgAVws8ybdgPP4XcvlH96j47hlyp94GQqjSkrpR/ClBV xuGXEhYNpPizFeyTjIHiGYVDKVIUi4oqboeWaduNVoG3zsIN2ZVOyeuhLnt6vI9ItF2U afHJxAWg/1bwmIf9HOQXuLf6bMQNfwxWItWRW6SSOfA79sUTl0/8tJ0P+ZvmEAqIUtWB BWIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=XBIIn2zPumrey8jrcEZBqbza6n+jON531yb8z6m6xwk=; b=muudwXP46Lf9+xAyW2cWGSGgmdZlEQIMXCBITjzDplEPyxTW9hVCUdLTVY8CXeZDfy gINC7KRhWlLU4icXNV/nGwZ2lGEZPo3uBC2QBBVpkCCbKajZFOAfBK3x/KW12HFqo+3M aJEB2CHZlYQESlIpVMnDWk6vrJXK1G2rmmu2EYyMZ2J5DY7I4uuYp5xRynypH289xWr8 a9nQ5+mik4GRuzB1uRQoIVFfj7q43udiDKzpHNMBc2lQWEAdWMxGfFk5NqqARbGS1ULv AVyrNLePX/iCUbUYqyOBj1PH2AqTwnP0rqNxolQJArJh3eGzeLMRUhTtv1d5uRONEHX4 MWGw== X-Gm-Message-State: APt69E3MG7aW4rEGvOhwUfI8spA+amSKRKWOzRPMmbVyJT4cCBqRtx4c HjTbK/+DBfowjEBRhEfO/KJYTyIC X-Google-Smtp-Source: ADUXVKISn1fhOr11ZuZQGHYW/FhsUwkiHRNHiitrAH1mXvrxQwn0JOn5YyCSAURHBr6Sd58Ym3LfkA== X-Received: by 2002:aca:3382:: with SMTP id z124-v6mr8788701oiz.49.1529372671268; Mon, 18 Jun 2018 18:44:31 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:40 -0500 Message-Id: <20180619014319.28272-15-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::241 Subject: [Qemu-devel] [PATCH 014/113] 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: David Gibson , qemu-stable@nongnu.org, Greg Kurz 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 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 (cherry picked from commit b1a568c1c2192f090536b8ac76d135ce1f46a0ee) Signed-off-by: Greg Kurz --- 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 a36494b87b..d53123c127 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3655,13 +3655,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.11.0