]> git.ipfire.org Git - thirdparty/qemu.git/commit
spapr: move VCPU calculation to core machine code
authorGreg Kurz <groug@kaod.org>
Wed, 14 Feb 2018 19:40:35 +0000 (20:40 +0100)
committerGreg Kurz <groug@kaod.org>
Tue, 22 May 2018 10:58:59 +0000 (12:58 +0200)
commita8074a58951b04ed40d824dd837d7771ba7f08cb
tree3db8c9f9ea4f0ac39eb118a9ba6f2053d350236d
parentcc86c467587bae3c742a7294fac64cb5d5588854
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>
(cherry picked from commit 648edb64751ea0e550f36302fa66f9f11e480824)
Signed-off-by: Greg Kurz <groug@kaod.org>
hw/ppc/spapr.c
hw/ppc/spapr_cpu_core.c
include/hw/ppc/spapr.h