From 0e86d7a71e8b5af201f2066a56071d3e23f4693c Mon Sep 17 00:00:00 2001 From: Philippe Mathieu-Daudé Date: Tue, 21 Jan 2025 12:38:45 +0100 Subject: cpus: Cache CPUClass early in instance_init() handler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cache CPUClass as early as possible, when the instance is initialized. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <20250123234415.59850-5-philmd@linaro.org> --- hw/core/cpu-common.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'hw/core/cpu-common.c') diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index cb79566cc5..ff605059c1 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -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; -- cgit 1.4.1 From 6042c47cddae04d0c1f0c750968f66a553611f40 Mon Sep 17 00:00:00 2001 From: Philippe Mathieu-Daudé Date: Thu, 16 Jan 2025 18:45:41 +0100 Subject: cpus: Keep default fields initialization in cpu_common_initfn() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cpu_common_initfn() is our target agnostic initializer, while cpu_exec_initfn() is the target specific one. The %as and %num_ases fields are not target specific, so initialize them in the common helper. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <20250123234415.59850-6-philmd@linaro.org> --- cpu-target.c | 3 --- hw/core/cpu-common.c | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'hw/core/cpu-common.c') diff --git a/cpu-target.c b/cpu-target.c index 89874496a4..75501a909d 100644 --- a/cpu-target.c +++ b/cpu-target.c @@ -234,9 +234,6 @@ void cpu_class_init_props(DeviceClass *dc) void cpu_exec_initfn(CPUState *cpu) { - cpu->as = NULL; - cpu->num_ases = 0; - #ifndef CONFIG_USER_ONLY cpu->memory = get_system_memory(); object_ref(OBJECT(cpu->memory)); diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index ff605059c1..71425cb742 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -244,6 +244,8 @@ static void cpu_common_initfn(Object *obj) gdb_init_cpu(cpu); cpu->cpu_index = UNASSIGNED_CPU_INDEX; cpu->cluster_index = UNASSIGNED_CLUSTER_INDEX; + cpu->as = NULL; + cpu->num_ases = 0; /* user-mode doesn't have configurable SMP topology */ /* the default value is changed by qemu_init_vcpu() for system-mode */ cpu->nr_threads = 1; -- cgit 1.4.1 From de5a43192b55b5744ed7ec0e263d4d208c834617 Mon Sep 17 00:00:00 2001 From: Philippe Mathieu-Daudé Date: Wed, 29 Nov 2023 16:55:37 +0100 Subject: accel/tcg: Remove pointless initialization of cflags_next_tb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cflags_next_tb is always re-initialized in the CPU Reset() handler in cpu_common_reset_hold(), no need to initialize it in cpu_common_initfn(). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <20240427155714.53669-13-philmd@linaro.org> --- hw/core/cpu-common.c | 1 - 1 file changed, 1 deletion(-) (limited to 'hw/core/cpu-common.c') diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index 71425cb742..d5cd227fe6 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -249,7 +249,6 @@ static void cpu_common_initfn(Object *obj) /* user-mode doesn't have configurable SMP topology */ /* the default value is changed by qemu_init_vcpu() for system-mode */ cpu->nr_threads = 1; - cpu->cflags_next_tb = -1; /* allocate storage for thread info, initialise condition variables */ cpu->thread = g_new0(QemuThread, 1); -- cgit 1.4.1