cpus: Cache CPUClass early in instance_init() handler
authorPhilippe Mathieu-Daudé <philmd@linaro.org>
Tue, 21 Jan 2025 11:38:45 +0000 (12:38 +0100)
committerPhilippe Mathieu-Daudé <philmd@linaro.org>
Thu, 6 Mar 2025 14:46:17 +0000 (15:46 +0100)
Cache CPUClass as early as possible, when the instance
is initialized.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20250123234415.59850-5-philmd@linaro.org>

cpu-target.c
hw/core/cpu-common.c

index 667688332c929aa53782c94343def34571272d5f..89874496a41ea77f408ca3d4ff604411728fc82b 100644 (file)
@@ -134,9 +134,6 @@ const VMStateDescription vmstate_cpu_common = {
 
 bool cpu_exec_realizefn(CPUState *cpu, Error **errp)
 {
-    /* cache the cpu class for the hotpath */
-    cpu->cc = CPU_GET_CLASS(cpu);
-
     if (!accel_cpu_common_realize(cpu, errp)) {
         return false;
     }
index cb79566cc51bc7f4c11effe700584f9c3472f4b6..ff605059c1551313f0362b04464420cf21a6ddf4 100644 (file)
@@ -238,6 +238,9 @@ static void cpu_common_initfn(Object *obj)
 {
     CPUState *cpu = CPU(obj);
 
+    /* cache the cpu class for the hotpath */
+    cpu->cc = CPU_GET_CLASS(cpu);
+
     gdb_init_cpu(cpu);
     cpu->cpu_index = UNASSIGNED_CPU_INDEX;
     cpu->cluster_index = UNASSIGNED_CLUSTER_INDEX;