qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 5/6] target-i386: Move TCG initialization to realize


From: Eduardo Habkost
Subject: [Qemu-devel] [PATCH 5/6] target-i386: Move TCG initialization to realize time
Date: Thu, 5 Mar 2015 12:38:49 -0300

To ask the CPU classes for CPU model information and allow QOM
properties to be queried by qmp_device_list_properties(), we need to be
able to safely instantiate a X86CPU object without any side-effects.

Move TCG initialization to realize time so it won't be called when just
doing object_new() on a X86CPU subclass.

Signed-off-by: Eduardo Habkost <address@hidden>
---
 target-i386/cpu.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index b4e70d3..400b1e0 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -2756,6 +2756,12 @@ static void x86_cpu_realizefn(DeviceState *dev, Error 
**errp)
     CPUX86State *env = &cpu->env;
     Error *local_err = NULL;
     static bool ht_warned;
+    static bool tcg_initialized;
+
+    if (tcg_enabled() && !tcg_initialized) {
+        tcg_initialized = 1;
+        tcg_x86_init();
+    }
 
     if (cpu->apic_id < 0) {
         error_setg(errp, "apic-id property was not initialized properly");
@@ -2832,7 +2838,6 @@ static void x86_cpu_initfn(Object *obj)
     X86CPU *cpu = X86_CPU(obj);
     X86CPUClass *xcc = X86_CPU_GET_CLASS(obj);
     CPUX86State *env = &cpu->env;
-    static int inited;
 
     cs->env_ptr = env;
     cpu_exec_init(env);
@@ -2879,12 +2884,6 @@ static void x86_cpu_initfn(Object *obj)
 #endif
 
     x86_cpu_load_def(cpu, xcc->cpu_def, &error_abort);
-
-    /* init various static tables used in TCG mode */
-    if (tcg_enabled() && !inited) {
-        inited = 1;
-        tcg_x86_init();
-    }
 }
 
 static int64_t x86_cpu_get_arch_id(CPUState *cs)
-- 
2.1.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]