Received: from eggs.gnu.org ([2001:4830:134:3::10]:53489) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YV4UR-0001fb-EQ for qemu-devel@nongnu.org; Mon, 09 Mar 2015 16:41:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YV4UN-0006z2-9h for qemu-devel@nongnu.org; Mon, 09 Mar 2015 16:41:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42918) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YV4UN-0006yt-0Q for qemu-devel@nongnu.org; Mon, 09 Mar 2015 16:41:23 -0400 From: Eduardo Habkost Date: Mon, 9 Mar 2015 17:40:51 -0300 Message-Id: <1425933651-20736-8-git-send-email-ehabkost@redhat.com> In-Reply-To: <1425933651-20736-1-git-send-email-ehabkost@redhat.com> References: <1425933651-20736-1-git-send-email-ehabkost@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 7/7] target-i386: Require APIC ID to be explicitly set before CPU realize List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Paolo Bonzini , =?UTF-8?q?Andreas=20F=C3=A4rber?= , qemu-devel@nongnu.org On softmuu, instead of setting APIC ID automatically when creating a X86CPU, require the property to be set before realizing the object (which is already done by the CPU creation code on PC). Keep apic_id =3D 0 by default on *-user so it can simply create a new CPU object and realize it without extra steps (so target-i386 will be able to use cpu_generic_init() eventually). Reviewed-by: Andreas F=C3=A4rber Signed-off-by: Eduardo Habkost --- target-i386/cpu-qom.h | 2 +- target-i386/cpu.c | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/target-i386/cpu-qom.h b/target-i386/cpu-qom.h index 4a6f48a..31a0c1e 100644 --- a/target-i386/cpu-qom.h +++ b/target-i386/cpu-qom.h @@ -93,7 +93,7 @@ typedef struct X86CPU { bool expose_kvm; bool migratable; bool host_features; - uint32_t apic_id; + int64_t apic_id; =20 /* if true the CPUID code directly forward host cache leaves to the = guest */ bool cache_info_passthrough; diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 110716e..50907d0 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -2757,6 +2757,11 @@ static void x86_cpu_realizefn(DeviceState *dev, Er= ror **errp) Error *local_err =3D NULL; static bool ht_warned; =20 + if (cpu->apic_id < 0) { + error_setg(errp, "apic-id property was not initialized properly"= ); + return; + } + if (env->features[FEAT_7_0_EBX] && env->cpuid_level < 7) { env->cpuid_level =3D 7; } @@ -2868,6 +2873,11 @@ static void x86_cpu_initfn(Object *obj) =20 cpu->hyperv_spinlock_attempts =3D HYPERV_SPINLOCK_NEVER_RETRY; =20 +#ifndef CONFIG_USER_ONLY + /* Any code creating new X86CPU objects have to set apic-id explicit= ly */ + cpu->apic_id =3D -1; +#endif + x86_cpu_load_def(cpu, xcc->cpu_def, &error_abort); =20 /* init various static tables used in TCG mode */ --=20 2.1.0