[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PULL 40/40] ppc: spapr: Move VCPU ID calculation into sPAPR
From: |
David Gibson |
Subject: |
[Qemu-ppc] [PULL 40/40] ppc: spapr: Move VCPU ID calculation into sPAPR |
Date: |
Fri, 8 Sep 2017 20:35:58 +1000 |
From: Sam Bobroff <address@hidden>
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 <address@hidden>
Reviewed-by: Greg Kurz <address@hidden>
Signed-off-by: David Gibson <address@hidden>
---
hw/ppc/spapr_cpu_core.c | 11 +++++++++++
target/ppc/translate_init.c | 18 +++---------------
2 files changed, 14 insertions(+), 15 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;
diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c
index 3e24cddb86..c827d1e388 100644
--- a/target/ppc/translate_init.c
+++ b/target/ppc/translate_init.c
@@ -9904,28 +9904,15 @@ static void ppc_cpu_realizefn(DeviceState *dev, Error
**errp)
PowerPCCPU *cpu = POWERPC_CPU(dev);
PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
Error *local_err = NULL;
-#if !defined(CONFIG_USER_ONLY)
- int max_smt = kvmppc_smt_threads();
-#endif
cpu_exec_realizefn(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
}
-
-#if !defined(CONFIG_USER_ONLY)
- cpu->vcpu_id = (cs->cpu_index / smp_threads) * max_smt
- + (cs->cpu_index % smp_threads);
-
- if (kvm_enabled() && !kvm_vcpu_id_is_valid(cpu->vcpu_id)) {
- error_setg(errp, "Can't create CPU with id %d in KVM", cpu->vcpu_id);
- error_append_hint(errp, "Adjust the number of cpus to %d "
- "or try to raise the number of threads per core\n",
- cpu->vcpu_id * smp_threads / max_smt);
- goto unrealize;
+ if (cpu->vcpu_id == UNASSIGNED_CPU_INDEX) {
+ cpu->vcpu_id = cs->cpu_index;
}
-#endif
if (tcg_enabled()) {
if (ppc_fixup_cpu(cpu) != 0) {
@@ -10576,6 +10563,7 @@ static void ppc_cpu_initfn(Object *obj)
CPUPPCState *env = &cpu->env;
cs->env_ptr = env;
+ cpu->vcpu_id = UNASSIGNED_CPU_INDEX;
env->msr_mask = pcc->msr_mask;
env->mmu_model = pcc->mmu_model;
--
2.13.5
- [Qemu-ppc] [PULL 16/40] ppc: spapr: Make VCPU ID handling private to SPAPR, (continued)
- [Qemu-ppc] [PULL 16/40] ppc: spapr: Make VCPU ID handling private to SPAPR, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 23/40] ppc4xx: Make MAL emulation more generic, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 13/40] spapr: add pseries-2.11 machine type, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 29/40] hw/nvram/spapr_nvram: Device can not be created by the users, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 27/40] ppc4xx: Export ECB and PLB emulation, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 28/40] hw/ppc/spapr_cpu_core: Add a proper check for spapr machine, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 24/40] ppc4xx: Split off 4xx I2C emulation from ppc405_uc to its own file, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 26/40] ppc4xx_i2c: Move to hw/i2c, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 25/40] ppc4xx_i2c: QOMify, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 36/40] ppc: replace inter-function cyclic dependency/recurssion with 2 simple lookups, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 40/40] ppc: spapr: Move VCPU ID calculation into sPAPR,
David Gibson <=
- [Qemu-ppc] [PULL 31/40] PPC: KVM: Support machine option to set VSMT mode, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 33/40] ppc: use macros to make cpu type name from string literal, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 32/40] target/ppc: Remove old STATUS file, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 39/40] ppc: remove non implemented cpu models, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 30/40] spapr: fallback to raw mode if best compat mode cannot be set during CAS, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 37/40] ppc: simplify cpu model lookup by PVR, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 35/40] ppc: make cpu alias point only to real cpu models, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 38/40] ppc: drop caching ObjectClass from PowerPCCPUAlias, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 22/40] ppc4xx: Move MAL from ppc405_uc to ppc4xx_devs, David Gibson, 2017/09/08
- [Qemu-ppc] [PULL 34/40] ppc: make cpu_model translation to type consistent, David Gibson, 2017/09/08