From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:37098) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TJOzv-00042x-Lw for qemu-devel@nongnu.org; Wed, 03 Oct 2012 09:28:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TJOzt-0006au-1R for qemu-devel@nongnu.org; Wed, 03 Oct 2012 09:28:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:61422) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TJOzs-0006aF-OH for qemu-devel@nongnu.org; Wed, 03 Oct 2012 09:28:20 -0400 From: Eduardo Habkost Date: Wed, 3 Oct 2012 10:29:05 -0300 Message-Id: <1349270954-4657-10-git-send-email-ehabkost@redhat.com> In-Reply-To: <1349270954-4657-1-git-send-email-ehabkost@redhat.com> References: <1349270954-4657-1-git-send-email-ehabkost@redhat.com> Subject: [Qemu-devel] [RFC 09/18] target-i386: cpu: move cpuid_apic_id initialization to cpu_x86_register() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Igor Mammedov , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Gleb Natapov , Paolo Bonzini 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 --- 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