From patchwork Wed Oct 3 13:29:05 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 188764 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id CCA5A2C00BE for ; Wed, 3 Oct 2012 23:28:39 +1000 (EST) Received: from localhost ([::1]:36031 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TJP09-0004Bl-UX for incoming@patchwork.ozlabs.org; Wed, 03 Oct 2012 09:28:37 -0400 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 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q93DSKd7031274 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 3 Oct 2012 09:28:20 -0400 Received: from blackpad.lan.raisama.net (vpn1-7-147.gru2.redhat.com [10.97.7.147]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q93DSJx6029151; Wed, 3 Oct 2012 09:28:19 -0400 Received: by blackpad.lan.raisama.net (Postfix, from userid 500) id 39EC320362B; Wed, 3 Oct 2012 10:29:21 -0300 (BRT) From: Eduardo Habkost To: qemu-devel@nongnu.org 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> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Igor Mammedov , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Gleb Natapov , Paolo Bonzini Subject: [Qemu-devel] [RFC 09/18] target-i386: cpu: move cpuid_apic_id initialization to cpu_x86_register() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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;