From patchwork Tue Jun 19 01:41:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 10472859 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2963F601D7 for ; Tue, 19 Jun 2018 02:08:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14E3028D55 for ; Tue, 19 Jun 2018 02:08:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0976828D60; Tue, 19 Jun 2018 02:08:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 98D8C28D55 for ; Tue, 19 Jun 2018 02:08:43 +0000 (UTC) Received: from localhost ([::1]:38508 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV64Y-0002CG-3s for patchwork-qemu-devel@patchwork.kernel.org; Mon, 18 Jun 2018 22:08:42 -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) 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) 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) 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 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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=dtb.bin \ -smp cores=16,maxcpus=16,threads=1 $ 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 == 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édric 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(InterruptStatsProvider *obj, int spapr_get_vcpu_id(PowerPCCPU *cpu) { - CPUState *cs = CPU(cpu); - - if (kvm_enabled()) { - return kvm_arch_vcpu_id(cs); - } else { - return cs->cpu_index; - } + return cpu->vcpu_id; } void spapr_set_vcpu_id(PowerPCCPU *cpu, int cpu_index, Error **errp)