[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 4/9] qom: move CPUClass.tcg_initialize to a global
From: |
Peter Maydell |
Subject: |
[Qemu-devel] [PULL 4/9] qom: move CPUClass.tcg_initialize to a global |
Date: |
Mon, 13 Nov 2017 14:11:39 +0000 |
From: "Emilio G. Cota" <address@hidden>
55c3cee ("qom: Introduce CPUClass.tcg_initialize", 2017-10-24)
introduces a per-CPUClass bool that we check so that the target CPU
is initialized for TCG only once. This works well except when
we end up creating more than one CPUClass, in which case we end
up incorrectly initializing TCG more than once, i.e. once for
each CPUClass.
This can be replicated with:
$ aarch64-softmmu/qemu-system-aarch64 -machine xlnx-zcu102 -smp 6 \
-global driver=xlnx,,zynqmp,property=has_rpu,value=on
In this case the class name of the "RPUs" is prefixed by "cortex-r5-",
whereas the "regular" CPUs are prefixed by "cortex-a53-". This
results in two CPUClass instances being created.
Fix it by introducing a static variable, so that only the first
target CPU being initialized will initialize the target-dependent
part of TCG, regardless of CPUClass instances.
Fixes: 55c3ceef61fcf06fc98ddc752b7cce788ce7680b
Signed-off-by: Emilio G. Cota <address@hidden>
Reviewed-by: Eduardo Habkost <address@hidden>
Reviewed-by: Alistair Francis <address@hidden>
Reviewed-by: Richard Henderson <address@hidden>
Tested-by: Alistair Francis <address@hidden>
Message-id: address@hidden
Signed-off-by: Peter Maydell <address@hidden>
---
include/qom/cpu.h | 1 -
exec.c | 5 +++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index fa4b0c9..c2fa151 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -209,7 +209,6 @@ typedef struct CPUClass {
/* Keep non-pointer data at the end to minimize holes. */
int gdb_num_core_regs;
bool gdb_stop_before_watchpoint;
- bool tcg_initialized;
} CPUClass;
#ifdef HOST_WORDS_BIGENDIAN
diff --git a/exec.c b/exec.c
index 97a24a8..8b579c0 100644
--- a/exec.c
+++ b/exec.c
@@ -792,11 +792,12 @@ void cpu_exec_initfn(CPUState *cpu)
void cpu_exec_realizefn(CPUState *cpu, Error **errp)
{
CPUClass *cc = CPU_GET_CLASS(cpu);
+ static bool tcg_target_initialized;
cpu_list_add(cpu);
- if (tcg_enabled() && !cc->tcg_initialized) {
- cc->tcg_initialized = true;
+ if (tcg_enabled() && !tcg_target_initialized) {
+ tcg_target_initialized = true;
cc->tcg_initialize();
}
--
2.7.4
- [Qemu-devel] [PULL 0/9] target-arm queue, Peter Maydell, 2017/11/13
- [Qemu-devel] [PULL 6/9] xlnx-zcu102: Add an info message deprecating the EP108, Peter Maydell, 2017/11/13
- [Qemu-devel] [PULL 7/9] xlnx-zcu102: Specify the max number of CPUs for the EP108, Peter Maydell, 2017/11/13
- [Qemu-devel] [PULL 9/9] accel/tcg/translate-all: expand cpu_restore_state addr check, Peter Maydell, 2017/11/13
- [Qemu-devel] [PULL 8/9] hw: add .min_cpus and .default_cpus fields to machine_class, Peter Maydell, 2017/11/13
- [Qemu-devel] [PULL 3/9] MAINTAINERS: Add entries for Smartfusion2, Peter Maydell, 2017/11/13
- [Qemu-devel] [PULL 4/9] qom: move CPUClass.tcg_initialize to a global,
Peter Maydell <=
- [Qemu-devel] [PULL 5/9] xlnx-zynqmp: Properly support the smp command line option, Peter Maydell, 2017/11/13
- [Qemu-devel] [PULL 2/9] highbank: validate register offset before access, Peter Maydell, 2017/11/13
- [Qemu-devel] [PULL 1/9] arm/translate-a64: mark path as unreachable to eliminate warning, Peter Maydell, 2017/11/13
- Re: [Qemu-devel] [PULL 0/9] target-arm queue, Peter Maydell, 2017/11/14