From nobody Wed Nov 5 10:09:30 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; 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 1534670367112112.02639766477932; Sun, 19 Aug 2018 02:19:27 -0700 (PDT) Received: from localhost ([::1]:42149 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frJrq-0006gt-1d for importer@patchew.org; Sun, 19 Aug 2018 05:19:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57176) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frJmS-0002NA-8p for qemu-devel@nongnu.org; Sun, 19 Aug 2018 05:13:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1frJmP-0000dR-KD for qemu-devel@nongnu.org; Sun, 19 Aug 2018 05:13:52 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:54733) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1frJmP-0000ca-5q; Sun, 19 Aug 2018 05:13:49 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 920A521B7F; Sun, 19 Aug 2018 05:13:48 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 19 Aug 2018 05:13:48 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id E45FA10291; Sun, 19 Aug 2018 05:13:47 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=mesmtp; bh=p6xJ+7KZqFPHlB MtixRUsDUt9g2Zrx0xcET+q0UQiMo=; b=FFkgVIOo0HZB9Qy6dPZiIj2Fw/gcnQ T7JSoaMX8kMqC26wy+On7DHFIzQ6kdiUL1+rHBs0Dc85p4JG4FxTyVBEXopAw+Vn UM80hDWTY7YN/pvKjJZdV7Llq+okZbsqHnwbBati6EnxMFpuJFzpbASg0FOkT2IE OtSlspILiuzL0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=p6xJ+7KZqFPHlBMtixRUsDUt9g2Zrx0xcET+q0UQiMo=; b=gWumpgJZ fUWYddkdjxMn+JUI8SxJqcIIqBTnwQ7WVdhz29SV20hUr7e0jXMqfs709oZNNWYO Kn/v0c2euTeWEanvstQDzVWe6KGEv09ODf4I/4trAODjzhZRppxNvzAo8SYjgqeD qzB+taI/MfvHTTCP/4OcSxaEksXL9SoRTxG55RUtXerlJ2K/b28iuq2caaU7y/aH Skh3l5+5hHN2h1OlqECtBYc5p1Z+nfUeTO+C/OqoCtlsdzIneVFkFzBHBHnkH7Dp vOesu7aRKIWDBcLNH8hiHVXubYr2Se0UkijIPTTKzUYjnb/IBpw1pIIdLfUBWgK4 NEwMVlwIsVIERQ== X-ME-Proxy: X-ME-Sender: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 19 Aug 2018 05:13:34 -0400 Message-Id: <20180819091335.22863-11-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180819091335.22863-1-cota@braap.org> References: <20180819091335.22863-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.25 Subject: [Qemu-devel] [PATCH v2 10/11] spapr: do not use CPU_FOREACH_REVERSE 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: Peter Crosthwaite , Riku Voipio , Alexander Graf , Laurent Vivier , qemu-ppc@nongnu.org, Paolo Bonzini , David Gibson , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This paves the way for implementing the CPU list with an RCU list, which cannot be traversed in reverse order. Note that this is the only caller of CPU_FOREACH_REVERSE. Acked-by: David Gibson Signed-off-by: Emilio G. Cota --- hw/ppc/spapr.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 421b2dd09b..2ef5be2790 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -622,9 +622,12 @@ static void spapr_populate_cpu_dt(CPUState *cs, void *= fdt, int offset, =20 static void spapr_populate_cpus_dt_node(void *fdt, sPAPRMachineState *spap= r) { + CPUState **rev; CPUState *cs; + int n_cpus; int cpus_offset; char *nodename; + int i; =20 cpus_offset =3D fdt_add_subnode(fdt, 0, "cpus"); _FDT(cpus_offset); @@ -635,8 +638,19 @@ static void spapr_populate_cpus_dt_node(void *fdt, sPA= PRMachineState *spapr) * We walk the CPUs in reverse order to ensure that CPU DT nodes * created by fdt_add_subnode() end up in the right order in FDT * for the guest kernel the enumerate the CPUs correctly. + * + * The CPU list cannot be traversed in reverse order, so we need + * to do extra work. */ - CPU_FOREACH_REVERSE(cs) { + n_cpus =3D 0; + rev =3D NULL; + CPU_FOREACH(cs) { + rev =3D g_renew(CPUState *, rev, n_cpus + 1); + rev[n_cpus++] =3D cs; + } + + for (i =3D n_cpus - 1; i >=3D 0; i--) { + CPUState *cs =3D rev[i]; PowerPCCPU *cpu =3D POWERPC_CPU(cs); int index =3D spapr_get_vcpu_id(cpu); DeviceClass *dc =3D DEVICE_GET_CLASS(cs); --=20 2.17.1