From nobody Wed Nov 5 14:28:09 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1534873698738998.252680512645; Tue, 21 Aug 2018 10:48:18 -0700 (PDT) Received: from localhost ([::1]:55177 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fsAlN-0004ui-GV for importer@patchew.org; Tue, 21 Aug 2018 13:48:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33703) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fsA4n-0002IF-LU for qemu-devel@nongnu.org; Tue, 21 Aug 2018 13:04:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fsA4W-0006pf-VQ for qemu-devel@nongnu.org; Tue, 21 Aug 2018 13:04:08 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:34303) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fsA4V-0006bk-Ty for qemu-devel@nongnu.org; Tue, 21 Aug 2018 13:04:00 -0400 Received: by mail-wr1-x442.google.com with SMTP id g33-v6so6431637wrd.1 for ; Tue, 21 Aug 2018 10:03:53 -0700 (PDT) Received: from 640k.lan (dynamic-adsl-78-12-184-244.clienti.tiscali.it. [78.12.184.244]) by smtp.gmail.com with ESMTPSA id v6-v6sm2608955wmc.43.2018.08.21.10.03.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Aug 2018 10:03:51 -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; bh=k7wotZAI+pPfegmMvrAxfM3Iit+qUnjf7yHSM9xYKDA=; b=T+V/ssiHynPYTcu6x0eOAj+qu62YlJYl0OL5oBznu+01CUITBKkWiGJ5LdcdCLANvv e3mMpyG55rgHirU2BWS7lPZLEkXRM6SEU8zTcohqHInkE5iKeLiuRRDuHmfZeFxpatj0 WSImHhgFc2OTXv3o4SmYdGLI6zNo2h/ndcRZKZB+HqSzUwl8JbA9ydjWbj8KGDhtNX78 Jz8h1qFXn+uawGN/LOJNbyb8UboWDVRZt7rzZSVF/3ae9YTsae2P2dxELV45mK8v2qlo jDitSFGJH9wO7wAp7ZeexZOacL0F0crdVrq1fjr5eiGIUYnWcJC4ZzTigkh5uwztH6N+ jagQ== 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; bh=k7wotZAI+pPfegmMvrAxfM3Iit+qUnjf7yHSM9xYKDA=; b=YOvL/CeteWoF6wBZdRrOev2xt1xhO3HyKH2mYhalBht/f4qkrBGrm7bTx5TeqZ552e XkMNOstNVXN0DVdV6LDO4njMKN7w9CYmnCnntvgn5FkFgsohPPaLDNqATLXKhTEm+MDL dZ9XdG5j6ueVn+2Jxxm/OtsJeVPqPyNBxwgkMK+QWbyQCvbzEOlrh9IVUH+y+7PGzase obRARvbhH/5T5c6ER0/udmrENRLYih+CmpTL7F3RcENhSiI/IZlPV/VFf/DQ9xlyu7JE xdJ24Jc9ytNUJGtFDmxIiMHTWl2vainHPacNT/yl1t7PdlsM2VcpKfKCS5lh3iTk3HKJ qYlA== X-Gm-Message-State: AOUpUlG2SrmMDMA2s6FKFzbmjDfTtHPYDTVdj8XYh8DvuffxqXzj88xG jm1g+C+MyEv/rXhmRCBHkrPkMhDu X-Google-Smtp-Source: AA+uWPyADzPVyN8V97pWh3FyNdzgqM9bl43E6itrmAQshEJos1c16lAIsXSh8nhe6i8h22ug4Zl2dg== X-Received: by 2002:adf:9b11:: with SMTP id b17-v6mr34778761wrc.119.1534871032566; Tue, 21 Aug 2018 10:03:52 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 21 Aug 2018 19:02:17 +0200 Message-Id: <1534870966-9287-46-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534870966-9287-1-git-send-email-pbonzini@redhat.com> References: <1534870966-9287-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 Subject: [Qemu-devel] [PULL 45/74] 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: "Emilio G. Cota" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 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: "Emilio G. Cota" 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 Message-Id: <20180819091335.22863-11-cota@braap.org> Signed-off-by: Paolo Bonzini --- 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 e5d8253..ab9c04e 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 1.8.3.1