diff options
author | Sam Bobroff <sam.bobroff@au1.ibm.com> | 2017-08-31 16:38:46 +1000 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2017-09-08 09:30:55 +1000 |
commit | 7cca3e466eb0baa36d1cc29d5aeb5da74a260711 (patch) | |
tree | 0f438c8140d51fc127fa8b991bf94003e6f85741 /hw/ppc | |
parent | aef779605779579afbafffaba1e3a06ea89c3bdd (diff) |
ppc: spapr: Move VCPU ID calculation into sPAPR
Move the calculation of a CPU's VCPU ID out of the generic PPC code
(ppc_cpu_realizefn()) and into sPAPR specific code
(spapr_cpu_core_realize()) where it belongs.
Unfortunately, due to the way things are ordered, we still need to
default the VCPU ID in ppc_cpu_realizfn() but at least doing that
doesn't require any interaction with sPAPR.
Signed-off-by: Sam Bobroff <sam.bobroff@au1.ibm.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'hw/ppc')
-rw-r--r-- | hw/ppc/spapr_cpu_core.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index 92bec033b3..85037ef71e 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -213,6 +213,7 @@ error: static void spapr_cpu_core_realize(DeviceState *dev, Error **errp) { + sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine()); sPAPRCPUCore *sc = SPAPR_CPU_CORE(OBJECT(dev)); sPAPRCPUCoreClass *scc = SPAPR_CPU_CORE_GET_CLASS(OBJECT(dev)); CPUCore *cc = CPU_CORE(OBJECT(dev)); @@ -239,6 +240,16 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp) cs = CPU(obj); cpu = POWERPC_CPU(cs); cs->cpu_index = cc->core_id + i; + cpu->vcpu_id = (cc->core_id * spapr->vsmt / smp_threads) + i; + if (kvm_enabled() && !kvm_vcpu_id_is_valid(cpu->vcpu_id)) { + error_setg(&local_err, "Can't create CPU with id %d in KVM", + cpu->vcpu_id); + error_append_hint(&local_err, "Adjust the number of cpus to %d " + "or try to raise the number of threads per core\n", + cpu->vcpu_id * smp_threads / spapr->vsmt); + goto err; + } + /* Set NUMA node for the threads belonged to core */ cpu->node_id = sc->node_id; |