Add function for checking mca broadcast of CPU

Add function for checking whether current CPU support mca broadcast.

Signed-off-by: Jin Dongming <jin.dongming@np.css.fujitsu.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
This commit is contained in:
Jin Dongming 2010-12-10 17:21:14 +09:00 committed by Marcelo Tosatti
parent 31ce5e0c49
commit 2bd3e04c3b
3 changed files with 35 additions and 5 deletions

View File

@ -760,6 +760,7 @@ int cpu_x86_exec(CPUX86State *s);
void cpu_x86_close(CPUX86State *s); void cpu_x86_close(CPUX86State *s);
void x86_cpu_list (FILE *f, fprintf_function cpu_fprintf, const char *optarg); void x86_cpu_list (FILE *f, fprintf_function cpu_fprintf, const char *optarg);
void x86_cpudef_setup(void); void x86_cpudef_setup(void);
int cpu_x86_support_mca_broadcast(CPUState *env);
int cpu_get_pic_interrupt(CPUX86State *s); int cpu_get_pic_interrupt(CPUX86State *s);
/* MSDOS compatibility mode FPU exception support */ /* MSDOS compatibility mode FPU exception support */

View File

@ -110,6 +110,32 @@ void cpu_x86_close(CPUX86State *env)
qemu_free(env); qemu_free(env);
} }
static void cpu_x86_version(CPUState *env, int *family, int *model)
{
int cpuver = env->cpuid_version;
if (family == NULL || model == NULL) {
return;
}
*family = (cpuver >> 8) & 0x0f;
*model = ((cpuver >> 12) & 0xf0) + ((cpuver >> 4) & 0x0f);
}
/* Broadcast MCA signal for processor version 06H_EH and above */
int cpu_x86_support_mca_broadcast(CPUState *env)
{
int family = 0;
int model = 0;
cpu_x86_version(env, &family, &model);
if ((family == 6 && model >= 14) || family > 6) {
return 1;
}
return 0;
}
/***********************************************************/ /***********************************************************/
/* x86 debug */ /* x86 debug */
@ -1080,6 +1106,13 @@ void cpu_inject_x86_mce(CPUState *cenv, int bank, uint64_t status,
return; return;
} }
if (broadcast) {
if (!cpu_x86_support_mca_broadcast(cenv)) {
fprintf(stderr, "Current CPU does not support broadcast\n");
return;
}
}
if (kvm_enabled()) { if (kvm_enabled()) {
if (broadcast) { if (broadcast) {
flag |= MCE_BROADCAST; flag |= MCE_BROADCAST;

View File

@ -1711,13 +1711,9 @@ static void hardware_memory_error(void)
static void kvm_mce_broadcast_rest(CPUState *env) static void kvm_mce_broadcast_rest(CPUState *env)
{ {
CPUState *cenv; CPUState *cenv;
int family, model, cpuver = env->cpuid_version;
family = (cpuver >> 8) & 0xf;
model = ((cpuver >> 12) & 0xf0) + ((cpuver >> 4) & 0xf);
/* Broadcast MCA signal for processor version 06H_EH and above */ /* Broadcast MCA signal for processor version 06H_EH and above */
if ((family == 6 && model >= 14) || family > 6) { if (cpu_x86_support_mca_broadcast(env)) {
for (cenv = first_cpu; cenv != NULL; cenv = cenv->next_cpu) { for (cenv = first_cpu; cenv != NULL; cenv = cenv->next_cpu) {
if (cenv == env) { if (cenv == env) {
continue; continue;