From patchwork Mon Jan 24 09:02:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 80110 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5A08CB7120 for ; Mon, 24 Jan 2011 20:28:30 +1100 (EST) Received: from localhost ([127.0.0.1]:51441 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PhIip-0008Lc-5e for incoming@patchwork.ozlabs.org; Mon, 24 Jan 2011 04:28:27 -0500 Received: from [140.186.70.92] (port=37977 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PhIMS-0008Ku-4T for qemu-devel@nongnu.org; Mon, 24 Jan 2011 04:05:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PhIMO-0007EA-PU for qemu-devel@nongnu.org; Mon, 24 Jan 2011 04:05:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:64661) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PhIMO-0007Db-GM for qemu-devel@nongnu.org; Mon, 24 Jan 2011 04:05:16 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0O95FTR024110 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 24 Jan 2011 04:05:15 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p0O95EJO015453; Mon, 24 Jan 2011 04:05:15 -0500 Received: from amt.cnet (vpn2-9-29.ams2.redhat.com [10.36.9.29]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p0O95Bga008802; Mon, 24 Jan 2011 04:05:14 -0500 Received: from amt.cnet (localhost.localdomain [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 0340B652148; Mon, 24 Jan 2011 07:03:23 -0200 (BRST) Received: (from marcelo@localhost) by amt.cnet (8.14.4/8.14.4/Submit) id p0O93JM6028390; Mon, 24 Jan 2011 07:03:19 -0200 From: Marcelo Tosatti To: Anthony Liguori Date: Mon, 24 Jan 2011 07:02:14 -0200 Message-Id: <2bd3e04c3b3c76d573435a299a4d85bad0021a90.1295859760.git.mtosatti@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Marcelo Tosatti , qemu-devel@nongnu.org, kvm@vger.kernel.org, Jin Dongming Subject: [Qemu-devel] [PATCH 05/31] Add function for checking mca broadcast of CPU X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jin Dongming Add function for checking whether current CPU support mca broadcast. Signed-off-by: Jin Dongming Signed-off-by: Marcelo Tosatti --- 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 f0c07cd..dddcd74 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -760,6 +760,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 2cfb4a4..6dfa27d 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -110,6 +110,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 */ @@ -1080,6 +1106,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 8b868ad..2115a58 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -1711,13 +1711,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;