return false;
}
-static void fdt_add_cpu_nodes(const VirtMachineState *vms)
+static void fdt_add_cpu_nodes(VirtMachineState *vms)
{
int cpu;
int addr_cells = 1;
const MachineState *ms = MACHINE(vms);
const MachineClass *mc = MACHINE_GET_CLASS(ms);
const VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms);
- int smp_cpus = ms->smp.cpus;
+ unsigned int smp_cpus = ms->smp.cpus;
int socket_id, cluster_id, core_id;
uint32_t next_level = 0;
uint32_t socket_offset = 0;
qemu_fdt_setprop_cell(ms->fdt, "/cpus", "#address-cells", addr_cells);
qemu_fdt_setprop_cell(ms->fdt, "/cpus", "#size-cells", 0x0);
+ vms->cpu_phandles = g_new0(uint32_t, smp_cpus);
+
for (cpu = smp_cpus - 1; cpu >= 0; cpu--) {
socket_id = cpu / (ms->smp.clusters * ms->smp.cores * ms->smp.threads);
cluster_id = cpu / (ms->smp.cores * ms->smp.threads) % ms->smp.clusters;
ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(cpu));
CPUState *cs = CPU(armcpu);
const char *prefix = NULL;
+ uint32_t phandle;
qemu_fdt_add_subnode(ms->fdt, nodename);
qemu_fdt_setprop_string(ms->fdt, nodename, "device_type", "cpu");
ms->possible_cpus->cpus[cs->cpu_index].props.node_id);
}
- if (!vmc->no_cpu_topology) {
- qemu_fdt_setprop_cell(ms->fdt, nodename, "phandle",
- qemu_fdt_alloc_phandle(ms->fdt));
- }
+ phandle = qemu_fdt_alloc_phandle(ms->fdt);
+ qemu_fdt_setprop_cell(ms->fdt, nodename, "phandle", phandle);
+ vms->cpu_phandles[cpu] = phandle;
if (!vmc->no_cpu_topology && num_cache) {
for (uint8_t i = 0; i < num_cache; i++) {
qemu_fdt_add_subnode(ms->fdt, "/cpus/cpu-map");
for (cpu = smp_cpus - 1; cpu >= 0; cpu--) {
- char *cpu_path = g_strdup_printf("/cpus/cpu@%d", cpu);
char *map_path;
if (ms->smp.threads > 1) {
cpu % ms->smp.cores);
}
qemu_fdt_add_path(ms->fdt, map_path);
- qemu_fdt_setprop_phandle(ms->fdt, map_path, "cpu", cpu_path);
+ qemu_fdt_setprop_cell(ms->fdt, map_path, "cpu",
+ vms->cpu_phandles[cpu]);
g_free(map_path);
- g_free(cpu_path);
}
}
}