diff options
author | Greg Kurz <groug@kaod.org> | 2018-02-14 20:40:35 +0100 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2018-02-16 12:14:26 +1100 |
commit | 648edb64751ea0e550f36302fa66f9f11e480824 (patch) | |
tree | e8796697aaa57d776b3a9090a285094fbf328cd1 /include | |
parent | 72194664c8a16b67865eb95054f984dd169cfa86 (diff) | |
download | qemu-648edb64751ea0e550f36302fa66f9f11e480824.zip qemu-648edb64751ea0e550f36302fa66f9f11e480824.tar.gz qemu-648edb64751ea0e550f36302fa66f9f11e480824.tar.bz2 |
spapr: move VCPU calculation to core machine code
The VCPU ids are currently computed and assigned to each individual
CPU threads in spapr_cpu_core_realize(). But the numbering logic
of VCPU ids is actually a machine-level concept, and many places
in hw/ppc/spapr.c also have to compute VCPU ids out of CPU indexes.
The current formula used in spapr_cpu_core_realize() is:
vcpu_id = (cc->core_id * spapr->vsmt / smp_threads) + i
where:
cc->core_id is a multiple of smp_threads
cpu_index = cc->core_id + i
0 <= i < smp_threads
So we have:
cpu_index % smp_threads == i
cc->core_id / smp_threads == cpu_index / smp_threads
hence:
vcpu_id =
(cpu_index / smp_threads) * spapr->vsmt + cpu_index % smp_threads;
This formula was used before VSMT at the time VCPU ids where computed
at the target emulation level. It has the advantage of being useable
to derive a VPCU id out of a CPU index only. It is fitted for all the
places where the machine code has to compute a VCPU id.
This patch introduces an accessor to set the VCPU id in a PowerPCCPU object
using the above formula. It is a first step to consolidate all the VCPU id
logic in a single place.
Signed-off-by: Greg Kurz <groug@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'include')
-rw-r--r-- | include/hw/ppc/spapr.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 62c077a..af19320 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -767,6 +767,7 @@ void spapr_do_system_reset_on_cpu(CPUState *cs, run_on_cpu_data arg); #define HTAB_SIZE(spapr) (1ULL << ((spapr)->htab_shift)) int spapr_vcpu_id(PowerPCCPU *cpu); +void spapr_set_vcpu_id(PowerPCCPU *cpu, int cpu_index, Error **errp); PowerPCCPU *spapr_find_cpu(int vcpu_id); int spapr_irq_alloc(sPAPRMachineState *spapr, int irq_hint, bool lsi, |