target-i386: Defer MCE init
PATCH 1/1 target-i386: Defer MCE init
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 >= 6 though, so we could end up with a sequence such as for -cpu somecpu,family=6:
x86_cpu_initfn => X86CPU::family == 5
mce_init => no-op
cpu_x86_register => X86CPU::family = 6
=> MCE unexpectedly not init'ed
or for -cpu someothercpu,family=5:
x86_cpu_initfn => X86CPU::family == 6
mce_init => init'ed
cpu_x86_register => X86CPU::family = 5
=> 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.
--- target-i386/cpu-qom.h | 4 ++++ target-i386/cpu.c | 9 ++++++++- target-i386/helper.c | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-)
target-i386/cpu-qom.h +4 -0
@@ -22,6 +22,7 @@#include "qemu/cpu.h" #include "cpu.h" +#include "error.h" #ifdef TARGET_X86_64 #define TYPE_X86_CPU "x86_64-cpu"
@@ -71,5 +72,8 @@ static inline X86CPU *x86_env_get_cpu(CPUX86State *env)#define ENV_GET_CPU (e) CPU(x86_env_get_cpu(e)) +/* TODO Drop once ObjectClass::realize is available */ +void x86_cpu_realize (Object *obj,Error **errp); +#endif
target-i386/cpu.c +8 -1
@@ -1722,6 +1722,14 @@ static void mce_init(X86CPU *cpu) } } +void x86_cpu_realize (Object *obj,Error **errp) +{ +X86CPU *cpu =X86_CPU (obj); + +mce_init (cpu); +qemu_init_vcpu (&cpu->env); +} +static void x86_cpu_initfn (Object *obj) {X86CPU *cpu =X86_CPU (obj);
@@ -1755,7 +1763,6 @@ static void x86_cpu_initfn(Object *obj) x86_cpuid_set_tsc_freq, NULL, NULL, NULL); env->cpuid_apic_id = env->cpu_index; -mce_init (cpu); }static void x86_cpu_common_class_init (ObjectClass *oc,void *data)
target-i386/helper.c +1 -1
@@ -1181,7 +1181,7 @@ CPUX86State *cpu_x86_init(const char *cpu_model)return NULL ; } -qemu_init_vcpu (env); +x86_cpu_realize (OBJECT (cpu),NULL );return env; }
Signature · 1 line
1.7.7
----- Original Message -----
Quoted 108 lines
From: "Andreas Färber" <[email protected]>
To: [email protected]
Cc: "Eduardo Habkost" <[email protected]>, "Michael Roth" <[email protected]>, "Anthony Liguori" <[email protected]>, "Paolo Bonzini" <[email protected]>, [email protected], "Andreas Färber" <[email protected]>
Sent: Thursday, May 10, 2012 12:09:10 AM
Subject: [Qemu-devel] [PATCH for-1.1] target-i386: Defer MCE initCommit
de024815e3b523addf58f1f79846b7fe74643678(target-i386: QOM'ify CPU init) movedmce_init()call from helper.c:cpu_x86_init() into X86CPU's cpu.c:x86_cpu_initfn().mce_init()checks for a family >= 6 though, so we could end up with a sequence such as for -cpu somecpu,family=6:
x86_cpu_initfn=>X86CPU::family== 5
mce_init=> no-op
cpu_x86_register=>X86CPU::family= 6
=> MCE unexpectedly not init'edor for -cpu someothercpu,family=5:
x86_cpu_initfn=>X86CPU::family== 6
mce_init=> init'ed
cpu_x86_register=>X86CPU::family= 5
=> MCE unexpectedly init'edTherefore partially revert the above commit. To avoid moving
mce_init()back intohelper.c, foresightedly move it into a newx86_cpu_realize()function and, in lack ofObjectClass::realize, call it directly fromcpu_x86_init().While at it, move the
qemu_init_vcpu()call that used to followmce_init()incpu_x86_init()into the new realizefn as well.Reported-by Igor Mammedov <[email protected]>Signed-off-by Andreas Färber <[email protected]>Cc Anthony Liguori <[email protected]>Cc Paolo Bonzini <[email protected]>Cc Eduardo Habkost <[email protected]>Cc Michael Roth <[email protected]>--- target-i386/cpu-qom.h | 4 ++++ target-i386/cpu.c | 9 ++++++++- target-i386/helper.c | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-)target-i386/cpu-qom.h +4
-0@@ -22,6 +22,7 @@#include "qemu/cpu.h" #include "cpu.h" +#include "error.h" #ifdef TARGET_X86_64 #define TYPE_X86_CPU "x86_64-cpu"@@ -71,5 +72,8 @@ static inline X86CPU *x86_env_get_cpu(CPUX86State *env)#define ENV_GET_CPU (e) CPU(x86_env_get_cpu(e)) +/* TODO Drop once ObjectClass::realize is available */ +void x86_cpu_realize (Object *obj,Error **errp); +#endif
target-i386/cpu.c +8
-1@@ -1722,6 +1722,14 @@ static void mce_init(X86CPU *cpu) } } +void x86_cpu_realize (Object *obj,Error **errp) +{ +X86CPU *cpu =X86_CPU (obj); + +mce_init (cpu); +qemu_init_vcpu (&cpu->env); +} +static void x86_cpu_initfn (Object *obj) {X86CPU *cpu =X86_CPU (obj);@@ -1755,7 +1763,6 @@ static void x86_cpu_initfn(Object *obj) x86_cpuid_set_tsc_freq, NULL, NULL, NULL); env->cpuid_apic_id = env->cpu_index; -mce_init (cpu); }static void x86_cpu_common_class_init (ObjectClass *oc,void *data)target-i386/helper.c +1
-1@@ -1181,7 +1181,7 @@ CPUX86State *cpu_x86_init(const char *cpu_model)return NULL ; } -qemu_init_vcpu (env); +x86_cpu_realize (OBJECT (cpu),NULL );return env;
Quoted 4 lines
}
--
1.7.7
Looks good to me.
Am 10.05.2012 21:14, schrieb Igor Mammedov:
Quoted 47 lines
----- Original Message -----
Quoted 40 lines
From: "Andreas Färber" <[email protected]>
To: [email protected]
Cc: "Eduardo Habkost" <[email protected]>, "Michael Roth" <[email protected]>, "Anthony Liguori" <[email protected]>, "Paolo Bonzini" <[email protected]>, [email protected], "Andreas Färber" <[email protected]>
Sent: Thursday, May 10, 2012 12:09:10 AM
Subject: [Qemu-devel] [PATCH for-1.1] target-i386: Defer MCE initCommit
de024815e3b523addf58f1f79846b7fe74643678(target-i386: QOM'ify CPU init) movedmce_init()call from helper.c:cpu_x86_init() into X86CPU's cpu.c:x86_cpu_initfn().mce_init()checks for a family >= 6 though, so we could end up with a sequence such as for -cpu somecpu,family=6:
x86_cpu_initfn=>X86CPU::family== 5
mce_init=> no-op
cpu_x86_register=>X86CPU::family= 6
=> MCE unexpectedly not init'edor for -cpu someothercpu,family=5:
x86_cpu_initfn=>X86CPU::family== 6
mce_init=> init'ed
cpu_x86_register=>X86CPU::family= 5
=> MCE unexpectedly init'edTherefore partially revert the above commit. To avoid moving
mce_init()back intohelper.c, foresightedly move it into a newx86_cpu_realize()function and, in lack ofObjectClass::realize, call it directly fromcpu_x86_init().While at it, move the
qemu_init_vcpu()call that used to followmce_init()incpu_x86_init()into the new realizefn as well.Reported-by Igor Mammedov <[email protected]>Signed-off-by Andreas Färber <[email protected]>Cc Anthony Liguori <[email protected]>Cc Paolo Bonzini <[email protected]>Cc Eduardo Habkost <[email protected]>Cc Michael Roth <[email protected]>Quoted 5 lines
--- target-i386/cpu-qom.h | 4 ++++ target-i386/cpu.c | 9 ++++++++- target-i386/helper.c | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-)
Quoted 3 lines
Looks good to me.
Reviewed-by Igor Mammedov <[email protected]>
Thanks, I've applied it to qom-1.1 and qom-next branches for now:
http://repo.or.cz/w/qemu/afaerber.git/shortlog/refs/heads/qom-1.1
http://repo.or.cz/w/qemu/afaerber.git/shortlog/refs/heads/qom-next
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg