qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [RFC 09/18] target-i386: cpu: move cpuid_apic_id initializa


From: Eduardo Habkost
Subject: [Qemu-devel] [RFC 09/18] target-i386: cpu: move cpuid_apic_id initialization to cpu_x86_register()
Date: Wed, 3 Oct 2012 10:29:05 -0300

The problem here is:

 - The CPU object can't define its APIC ID itself, it has to be
   defined by the creator of the CPU object
 - The object instance_init() function can't get extra arguments
 - I don't want to add a APIC ID argument to x86_cpu_realize(), as it
   should eventually become a ObjectClass::realize() method

So, the only place where the CPU object can get an additional
x86-specific initialization argument (the APIC ID) is
cpu_x86_register(). This patch just moves the initialization code there,
the apic_id argument to cpu_x86_register() will be added later.

The cpuid_apic_id field is used only at:

 - pc_new_cpu(), after the cpu_x86_register() call
 - kvm_init_vcpu(), that is called from the VCPU thread
   created by qemu_init_vcpu(), called by x86_cpu_realize()
   (called after cpu_x86_register())
 - helper_cpuid(), called only when the VCPU is already running
 - kvm_arch_init_vcpu(), that's called by kvm_init_vcpu()

So it's safe to initialize it later.

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

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 1628b0e..c0db73e 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1733,6 +1733,8 @@ int cpu_x86_register(X86CPU *cpu, const char *cpu_model)
     QDict *features = NULL;
     char *name = NULL;
 
+    cpu->env.cpuid_apic_id = env->cpu_index;
+
     /* for CPU subclasses should go into cpu_x86_init() before object_new() */
     compat_normalize_cpu_model(cpu_model, &name, &features, &error);
     if (error_is_set(&error)) {
@@ -2361,8 +2363,6 @@ static void x86_cpu_initfn(Object *obj)
     x86_register_cpuid_properties(obj, svm_feature_name);
     x86_register_cpuid_properties(obj, cpuid_7_0_ebx_feature_name);
 
-    env->cpuid_apic_id = env->cpu_index;
-
     /* init various static tables used in TCG mode */
     if (tcg_enabled() && !inited) {
         inited = 1;
-- 
1.7.11.4




reply via email to

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