aboutsummaryrefslogtreecommitdiff
path: root/qom/cpu.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2019-01-29 11:46:05 +0000
committerPeter Maydell <peter.maydell@linaro.org>2019-01-29 11:46:05 +0000
commit7ea7b9ad532e59c3efbcabff0e3484f4df06104c (patch)
tree37695fe686bc6c22aba3e3437846e6ce4a5d95d2 /qom/cpu.c
parentfa434424652ecfd3efba39e11ff7a1a560943abd (diff)
qom/cpu: Add cluster_index to CPUState
For TCG we want to distinguish which cluster a CPU is in, and we need to do it quickly. Cache the cluster index in the CPUState struct, by having the cluster object set cpu->cluster_index for each CPU child when it is realized. This means that board/SoC code must add all CPUs to the cluster before realizing the cluster object. Regrettably QOM provides no way to prevent adding children to a realized object and no way for the parent to be notified when a new child is added to it, so we don't have any way to enforce/assert this constraint; all we can do is document it in a comment. We can at least put in a check that the cluster contains at least one CPU, which should catch the typical cases of "realized cluster too early" or "forgot to parent the CPUs into it". The restriction on how many clusters can exist in the system is imposed by TCG code which will be added in a subsequent commit, but the check to enforce it in cluster.c fits better in this one. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-id: 20190121152218.9592-3-peter.maydell@linaro.org
Diffstat (limited to 'qom/cpu.c')
-rw-r--r--qom/cpu.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/qom/cpu.c b/qom/cpu.c
index 5442a7323b..f5579b1cd5 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -364,6 +364,7 @@ static void cpu_common_initfn(Object *obj)
CPUClass *cc = CPU_GET_CLASS(obj);
cpu->cpu_index = UNASSIGNED_CPU_INDEX;
+ cpu->cluster_index = UNASSIGNED_CLUSTER_INDEX;
cpu->gdb_num_regs = cpu->gdb_num_g_regs = cc->gdb_num_core_regs;
/* *-user doesn't have configurable SMP topology */
/* the default value is changed by qemu_init_vcpu() for softmmu */