From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jin Dongming Subject: [PATCH 3/3] Add function for checking mca broadcast of CPU. Date: Fri, 10 Dec 2010 17:21:14 +0900 Message-ID: <4D01E2FA.2080000@np.css.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-2022-JP Content-Transfer-Encoding: 7bit Cc: Andi Kleen , Huang Ying , Hidetoshi Seto , Dean Nelson , KVM list To: Avi Kivity , Marcelo Tosatti Return-path: Received: from fgwmail5.fujitsu.co.jp ([192.51.44.35]:59982 "EHLO fgwmail5.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753927Ab0LJISv (ORCPT ); Fri, 10 Dec 2010 03:18:51 -0500 Received: from m1.gw.fujitsu.co.jp ([10.0.50.71]) by fgwmail5.fujitsu.co.jp (Fujitsu Gateway) with ESMTP id oBA8IorL023538 for (envelope-from jin.dongming@np.css.fujitsu.com); Fri, 10 Dec 2010 17:18:50 +0900 Received: from smail (m1 [127.0.0.1]) by outgoing.m1.gw.fujitsu.co.jp (Postfix) with ESMTP id 0994245DE60 for ; Fri, 10 Dec 2010 17:18:50 +0900 (JST) Received: from s1.gw.fujitsu.co.jp (s1.gw.fujitsu.co.jp [10.0.50.91]) by m1.gw.fujitsu.co.jp (Postfix) with ESMTP id DA06545DE5D for ; Fri, 10 Dec 2010 17:18:49 +0900 (JST) Received: from s1.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s1.gw.fujitsu.co.jp (Postfix) with ESMTP id CBD861DB8046 for ; Fri, 10 Dec 2010 17:18:49 +0900 (JST) Received: from m001.s.css.fujitsu.com (m001.s.css.fujitsu.com [10.23.4.39]) by s1.gw.fujitsu.co.jp (Postfix) with ESMTP id 95E45E08002 for ; Fri, 10 Dec 2010 17:18:49 +0900 (JST) Sender: kvm-owner@vger.kernel.org List-ID: Add function for checking whether current CPU support mca broadcast. Signed-off-by: Jin Dongming --- target-i386/cpu.h | 1 + target-i386/helper.c | 33 +++++++++++++++++++++++++++++++++ target-i386/kvm.c | 6 +----- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/target-i386/cpu.h b/target-i386/cpu.h index 1f1151d..f16860f 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -762,6 +762,7 @@ int cpu_x86_exec(CPUX86State *s); void cpu_x86_close(CPUX86State *s); void x86_cpu_list (FILE *f, fprintf_function cpu_fprintf, const char *optarg); void x86_cpudef_setup(void); +int cpu_x86_support_mca_broadcast(CPUState *env); int cpu_get_pic_interrupt(CPUX86State *s); /* MSDOS compatibility mode FPU exception support */ diff --git a/target-i386/helper.c b/target-i386/helper.c index 985d532..b86a6c5 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -112,6 +112,32 @@ void cpu_x86_close(CPUX86State *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 */ @@ -1082,6 +1108,13 @@ void cpu_inject_x86_mce(CPUState *cenv, int bank, uint64_t status, return; } + if (broadcast) { + if (!cpu_x86_support_mca_broadcast(cenv)) { + fprintf(stderr, "Current CPU does not support broadcast\n"); + return; + } + } + if (kvm_enabled()) { if (broadcast) { flag |= MCE_BROADCAST; diff --git a/target-i386/kvm.c b/target-i386/kvm.c index d866dce..a7261c0 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -1741,13 +1741,9 @@ static void hardware_memory_error(void) static void kvm_mce_broadcast_rest(CPUState *env) { 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 */ - if ((family == 6 && model >= 14) || family > 6) { + if (cpu_x86_support_mca_broadcast(env)) { for (cenv = first_cpu; cenv != NULL; cenv = cenv->next_cpu) { if (cenv == env) { continue; -- 1.7.1.1