From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:36928) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1STdWt-00085A-8J for qemu-devel@nongnu.org; Sun, 13 May 2012 14:28:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1STdWn-0007YB-Jh for qemu-devel@nongnu.org; Sun, 13 May 2012 14:28:26 -0400 Received: from cantor2.suse.de ([195.135.220.15]:38460 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1STdWn-0007Xh-Au for qemu-devel@nongnu.org; Sun, 13 May 2012 14:28:21 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Sun, 13 May 2012 20:27:41 +0200 Message-Id: <1336933665-3867-4-git-send-email-afaerber@suse.de> In-Reply-To: <1336933665-3867-1-git-send-email-afaerber@suse.de> References: <1336933665-3867-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 3/7] target-i386: Defer MCE init List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= , anthony@codemonkey.ws Commit de024815e3b523addf58f1f79846b7fe74643678 (target-i386: QOM'ify CPU init) moved mce_init() call from helper.c:cpu_x86_init() into X86CPU's cpu.c:x86_cpu_initfn(). mce_init() checks for a family >=3D 6 though, so we could end up with a sequence such as for -cpu somecpu,family=3D6: x86_cpu_initfn =3D> X86CPU::family =3D=3D 5 mce_init =3D> no-op cpu_x86_register =3D> X86CPU::family =3D 6 =3D> MCE unexpectedly not init'ed or for -cpu someothercpu,family=3D5: x86_cpu_initfn =3D> X86CPU::family =3D=3D 6 mce_init =3D> init'ed cpu_x86_register =3D> X86CPU::family =3D 5 =3D> MCE unexpectedly init'ed Therefore partially revert the above commit. To avoid moving mce_init() back into helper.c, foresightedly move it into a new x86_cpu_realize() function and, in lack of ObjectClass::realize, call it directly from cpu_x86_init(). While at it, move the qemu_init_vcpu() call that used to follow mce_init() in cpu_x86_init() into the new realizefn as well. Reported-by: Igor Mammedov Signed-off-by: Andreas F=C3=A4rber Reviewed-by: Igor Mammedov --- target-i386/cpu-qom.h | 4 ++++ target-i386/cpu.c | 9 ++++++++- target-i386/helper.c | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/target-i386/cpu-qom.h b/target-i386/cpu-qom.h index 40635c4..5901140 100644 --- a/target-i386/cpu-qom.h +++ b/target-i386/cpu-qom.h @@ -22,6 +22,7 @@ =20 #include "qemu/cpu.h" #include "cpu.h" +#include "error.h" =20 #ifdef TARGET_X86_64 #define TYPE_X86_CPU "x86_64-cpu" @@ -71,5 +72,8 @@ static inline X86CPU *x86_env_get_cpu(CPUX86State *env) =20 #define ENV_GET_CPU(e) CPU(x86_env_get_cpu(e)) =20 +/* TODO Drop once ObjectClass::realize is available */ +void x86_cpu_realize(Object *obj, Error **errp); + =20 #endif diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 65d9af6..89b4ac7 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -1722,6 +1722,14 @@ static void mce_init(X86CPU *cpu) } } =20 +void x86_cpu_realize(Object *obj, Error **errp) +{ + X86CPU *cpu =3D X86_CPU(obj); + + mce_init(cpu); + qemu_init_vcpu(&cpu->env); +} + static void x86_cpu_initfn(Object *obj) { X86CPU *cpu =3D X86_CPU(obj); @@ -1755,7 +1763,6 @@ static void x86_cpu_initfn(Object *obj) x86_cpuid_set_tsc_freq, NULL, NULL, NULL); =20 env->cpuid_apic_id =3D env->cpu_index; - mce_init(cpu); } =20 static void x86_cpu_common_class_init(ObjectClass *oc, void *data) diff --git a/target-i386/helper.c b/target-i386/helper.c index 0b22582..3421be2 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -1181,7 +1181,7 @@ CPUX86State *cpu_x86_init(const char *cpu_model) return NULL; } =20 - qemu_init_vcpu(env); + x86_cpu_realize(OBJECT(cpu), NULL); =20 return env; } --=20 1.7.7