@@ -823,7 +823,7 @@ void ppce500_init(MachineState *machine, PPCE500Params *params)
CPUState *cs;
qemu_irq *input;
- cpu = ppc_cpu_init(machine->cpu_model);
+ cpu = ppc_cpu_init(machine->cpu_model, i);
if (cpu == NULL) {
fprintf(stderr, "Unable to initialize CPU!\n");
exit(1);
@@ -194,7 +194,7 @@ static void ppc_core99_init(MachineState *machine)
}
ppc_cpu_parse_features(machine->cpu_model);
for (i = 0; i < smp_cpus; i++) {
- cpu = ppc_cpu_init(machine->cpu_model);
+ cpu = ppc_cpu_init(machine->cpu_model, i);
if (cpu == NULL) {
fprintf(stderr, "Unable to find PowerPC CPU definition\n");
exit(1);
@@ -114,7 +114,7 @@ static void ppc_heathrow_init(MachineState *machine)
machine->cpu_model = "G3";
ppc_cpu_parse_features(machine->cpu_model);
for (i = 0; i < smp_cpus; i++) {
- cpu = ppc_cpu_init(machine->cpu_model);
+ cpu = ppc_cpu_init(machine->cpu_model, i);
if (cpu == NULL) {
fprintf(stderr, "Unable to find PowerPC CPU definition\n");
exit(1);
@@ -1353,7 +1353,7 @@ PowerPCCPU *ppc_get_vcpu_by_dt_id(int cpu_dt_id)
return NULL;
}
-PowerPCCPU *ppc_cpu_init(const char *cpu_model)
+PowerPCCPU *ppc_cpu_init(const char *cpu_model, unsigned vcpu_dt_id)
{
PowerPCCPU *cpu = NULL;
ObjectClass *oc;
@@ -1373,6 +1373,9 @@ PowerPCCPU *ppc_cpu_init(const char *cpu_model)
}
cpu = POWERPC_CPU(object_new(object_class_get_name(oc)));
+
+ cpu->cpu_dt_id = vcpu_dt_id;
+
object_property_set_bool(OBJECT(cpu), true, "realized", &err);
out:
@@ -187,7 +187,7 @@ static void bamboo_init(MachineState *machine)
machine->cpu_model = "440EP";
}
ppc_cpu_parse_features(machine->cpu_model);
- cpu = ppc_cpu_init(machine->cpu_model);
+ cpu = ppc_cpu_init(machine->cpu_model, 0);
if (cpu == NULL) {
fprintf(stderr, "Unable to initialize CPU!\n");
exit(1);
@@ -57,7 +57,7 @@ PowerPCCPU *ppc4xx_init(const char *cpu_model,
/* init CPUs */
ppc_cpu_parse_features(cpu_model);
- cpu = ppc_cpu_init(cpu_model);
+ cpu = ppc_cpu_init(cpu_model, 0);
if (cpu == NULL) {
fprintf(stderr, "Unable to find PowerPC %s CPU definition\n",
cpu_model);
@@ -510,7 +510,7 @@ static void ppc_prep_init(MachineState *machine)
machine->cpu_model = "602";
ppc_cpu_parse_features(machine->cpu_model);
for (i = 0; i < smp_cpus; i++) {
- cpu = ppc_cpu_init(machine->cpu_model);
+ cpu = ppc_cpu_init(machine->cpu_model, i);
if (cpu == NULL) {
fprintf(stderr, "Unable to find PowerPC CPU definition\n");
exit(1);
@@ -1837,7 +1837,10 @@ static void ppc_spapr_init(MachineState *machine)
g_free(type);
} else {
for (i = 0; i < smp_cpus; i++) {
- PowerPCCPU *cpu = ppc_cpu_init(machine->cpu_model);
+ unsigned core_index = i / smp_threads;
+ unsigned thread_index = i % smp_threads;
+ PowerPCCPU *cpu = ppc_cpu_init(machine->cpu_model,
+ core_index * smt + thread_index);
if (cpu == NULL) {
error_report("Unable to find PowerPC CPU definition");
exit(1);
@@ -259,13 +259,16 @@ out:
error_propagate(errp, local_err);
}
-static void spapr_cpu_core_realize_child(Object *child, Error **errp)
+static void spapr_cpu_core_realize_child(Object *child, unsigned vcpu_dt_id,
+ Error **errp)
{
Error *local_err = NULL;
sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
CPUState *cs = CPU(child);
PowerPCCPU *cpu = POWERPC_CPU(cs);
+ cpu->cpu_dt_id = vcpu_dt_id;
+
object_property_set_bool(child, true, "realized", &local_err);
if (local_err) {
error_propagate(errp, local_err);
@@ -306,7 +309,7 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp)
for (j = 0; j < cc->nr_threads; j++) {
obj = sc->threads + j * size;
- spapr_cpu_core_realize_child(obj, &local_err);
+ spapr_cpu_core_realize_child(obj, cc->core_id + j, &local_err);
if (local_err) {
goto err;
}
@@ -97,7 +97,7 @@ static PowerPCCPU *ppc440_init_xilinx(ram_addr_t *ram_size,
qemu_irq *irqs;
ppc_cpu_parse_features(cpu_model);
- cpu = ppc_cpu_init(cpu_model);
+ cpu = ppc_cpu_init(cpu_model, 0);
if (cpu == NULL) {
fprintf(stderr, "Unable to initialize CPU!\n");
exit(1);
@@ -106,6 +106,6 @@ enum {
/* ppc_booke.c */
void ppc_booke_timers_init(PowerPCCPU *cpu, uint32_t freq, uint32_t flags);
-PowerPCCPU *ppc_cpu_init(const char *cpu_model);
+PowerPCCPU *ppc_cpu_init(const char *cpu_model, unsigned vcpu_dt_id);
void ppc_cpu_parse_features(const char *cpu_model);
#endif
This patch switches machine types to provide device-tree cpu ids. We have three cases to handle: - pseries < 2.7 call ppc_cpu_init() and should compute the DT id as it is currently done in the target code. - pseries 2.7 don't call ppc_cpu_init() and compute the DT as the sum of the core DT id and the the thread index within the core - all other machine types don't support SMT and just need to provide a different index for each vcpu Signed-off-by: Greg Kurz <groug@kaod.org> --- hw/ppc/e500.c | 2 +- hw/ppc/mac_newworld.c | 2 +- hw/ppc/mac_oldworld.c | 2 +- hw/ppc/ppc.c | 5 ++++- hw/ppc/ppc440_bamboo.c | 2 +- hw/ppc/ppc4xx_devs.c | 2 +- hw/ppc/prep.c | 2 +- hw/ppc/spapr.c | 5 ++++- hw/ppc/spapr_cpu_core.c | 7 +++++-- hw/ppc/virtex_ml507.c | 2 +- include/hw/ppc/ppc.h | 2 +- 11 files changed, 21 insertions(+), 12 deletions(-)