From nobody Tue Feb 10 04:14:52 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 150486821094461.22221810540282; Fri, 8 Sep 2017 03:56:50 -0700 (PDT) Received: from localhost ([::1]:44548 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqGxt-0003QS-Vd for importer@patchew.org; Fri, 08 Sep 2017 06:56:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58905) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqGeF-0002HG-5R for qemu-devel@nongnu.org; Fri, 08 Sep 2017 06:36:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dqGe6-0003Mn-K8 for qemu-devel@nongnu.org; Fri, 08 Sep 2017 06:36:31 -0400 Received: from ozlabs.org ([103.22.144.67]:43071) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dqGe6-0003Jb-9J; Fri, 08 Sep 2017 06:36:22 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3xpYdQ1cTyz9t6N; Fri, 8 Sep 2017 20:36:09 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1504866970; bh=Ki0F2uvpPsF1FvkXjAx2J7ey2GKd8jejlTvOOmghSCY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MQrYX9w7W7zLwQ+K0YWYWhcSQbm1/XAzXcbB+NQjDp8ohDx2bhpEDLOrEaurIPhXZ nZH+Tg1ibSKC4FxZ3afGg3u45SlyEvlLdjnyCWSv2E0kkwfRG9k/JHezJLRPjeNMeJ iz58N9ynaBVjwEoiKF36f31x+BKExWC5FJ7X7npY= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 8 Sep 2017 20:35:58 +1000 Message-Id: <20170908103558.31632-41-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170908103558.31632-1-david@gibson.dropbear.id.au> References: <20170908103558.31632-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 103.22.144.67 Subject: [Qemu-devel] [PULL 40/40] ppc: spapr: Move VCPU ID calculation into sPAPR 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, aik@ozlabs.ru, agraf@suse.de, mdroth@linux.vnet.ibm.com, qemu-ppc@nongnu.org, imammedo@redhat.com, sam.bobroff@au1.ibm.com, David Gibson 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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Sam Bobroff Move the calculation of a CPU's VCPU ID out of the generic PPC code (ppc_cpu_realizefn()) and into sPAPR specific code (spapr_cpu_core_realize()) where it belongs. Unfortunately, due to the way things are ordered, we still need to default the VCPU ID in ppc_cpu_realizfn() but at least doing that doesn't require any interaction with sPAPR. Signed-off-by: Sam Bobroff Reviewed-by: Greg Kurz Signed-off-by: David Gibson --- hw/ppc/spapr_cpu_core.c | 11 +++++++++++ target/ppc/translate_init.c | 18 +++--------------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index 92bec033b3..85037ef71e 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -213,6 +213,7 @@ error: =20 static void spapr_cpu_core_realize(DeviceState *dev, Error **errp) { + sPAPRMachineState *spapr =3D SPAPR_MACHINE(qdev_get_machine()); sPAPRCPUCore *sc =3D SPAPR_CPU_CORE(OBJECT(dev)); sPAPRCPUCoreClass *scc =3D SPAPR_CPU_CORE_GET_CLASS(OBJECT(dev)); CPUCore *cc =3D CPU_CORE(OBJECT(dev)); @@ -239,6 +240,16 @@ static void spapr_cpu_core_realize(DeviceState *dev, E= rror **errp) cs =3D CPU(obj); cpu =3D POWERPC_CPU(cs); cs->cpu_index =3D cc->core_id + i; + cpu->vcpu_id =3D (cc->core_id * spapr->vsmt / smp_threads) + i; + if (kvm_enabled() && !kvm_vcpu_id_is_valid(cpu->vcpu_id)) { + error_setg(&local_err, "Can't create CPU with id %d in KVM", + cpu->vcpu_id); + error_append_hint(&local_err, "Adjust the number of cpus to %d= " + "or try to raise the number of threads per c= ore\n", + cpu->vcpu_id * smp_threads / spapr->vsmt); + goto err; + } + =20 /* Set NUMA node for the threads belonged to core */ cpu->node_id =3D sc->node_id; diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c index 3e24cddb86..c827d1e388 100644 --- a/target/ppc/translate_init.c +++ b/target/ppc/translate_init.c @@ -9904,28 +9904,15 @@ static void ppc_cpu_realizefn(DeviceState *dev, Err= or **errp) PowerPCCPU *cpu =3D POWERPC_CPU(dev); PowerPCCPUClass *pcc =3D POWERPC_CPU_GET_CLASS(cpu); Error *local_err =3D NULL; -#if !defined(CONFIG_USER_ONLY) - int max_smt =3D kvmppc_smt_threads(); -#endif =20 cpu_exec_realizefn(cs, &local_err); if (local_err !=3D NULL) { error_propagate(errp, local_err); return; } - -#if !defined(CONFIG_USER_ONLY) - cpu->vcpu_id =3D (cs->cpu_index / smp_threads) * max_smt - + (cs->cpu_index % smp_threads); - - if (kvm_enabled() && !kvm_vcpu_id_is_valid(cpu->vcpu_id)) { - error_setg(errp, "Can't create CPU with id %d in KVM", cpu->vcpu_i= d); - error_append_hint(errp, "Adjust the number of cpus to %d " - "or try to raise the number of threads per core\= n", - cpu->vcpu_id * smp_threads / max_smt); - goto unrealize; + if (cpu->vcpu_id =3D=3D UNASSIGNED_CPU_INDEX) { + cpu->vcpu_id =3D cs->cpu_index; } -#endif =20 if (tcg_enabled()) { if (ppc_fixup_cpu(cpu) !=3D 0) { @@ -10576,6 +10563,7 @@ static void ppc_cpu_initfn(Object *obj) CPUPPCState *env =3D &cpu->env; =20 cs->env_ptr =3D env; + cpu->vcpu_id =3D UNASSIGNED_CPU_INDEX; =20 env->msr_mask =3D pcc->msr_mask; env->mmu_model =3D pcc->mmu_model; --=20 2.13.5