aboutsummaryrefslogtreecommitdiff
path: root/hw/ppc/spapr.c
diff options
context:
space:
mode:
authorEmilio G. Cota <cota@braap.org>2018-08-19 05:13:34 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2018-08-23 18:46:25 +0200
commit04d595b300041bec645c862baccbea1c8befb6d4 (patch)
tree3d9d69f4abdc519a5840b187c6f6b0757b150671 /hw/ppc/spapr.c
parentdbf8862a39f3099004366f1bd66d534b1590a34f (diff)
downloadqemu-04d595b300041bec645c862baccbea1c8befb6d4.zip
qemu-04d595b300041bec645c862baccbea1c8befb6d4.tar.gz
qemu-04d595b300041bec645c862baccbea1c8befb6d4.tar.bz2
spapr: do not use CPU_FOREACH_REVERSE
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 <david@gibson.dropbear.id.au> Signed-off-by: Emilio G. Cota <cota@braap.org> Message-Id: <20180819091335.22863-11-cota@braap.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/ppc/spapr.c')
-rw-r--r--hw/ppc/spapr.c16
1 files changed, 15 insertions, 1 deletions
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,
static void spapr_populate_cpus_dt_node(void *fdt, sPAPRMachineState *spapr)
{
+ CPUState **rev;
CPUState *cs;
+ int n_cpus;
int cpus_offset;
char *nodename;
+ int i;
cpus_offset = fdt_add_subnode(fdt, 0, "cpus");
_FDT(cpus_offset);
@@ -635,8 +638,19 @@ static void spapr_populate_cpus_dt_node(void *fdt, sPAPRMachineState *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 = 0;
+ rev = NULL;
+ CPU_FOREACH(cs) {
+ rev = g_renew(CPUState *, rev, n_cpus + 1);
+ rev[n_cpus++] = cs;
+ }
+
+ for (i = n_cpus - 1; i >= 0; i--) {
+ CPUState *cs = rev[i];
PowerPCCPU *cpu = POWERPC_CPU(cs);
int index = spapr_get_vcpu_id(cpu);
DeviceClass *dc = DEVICE_GET_CLASS(cs);