From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hidetoshi Seto Subject: [PATCH uq/master 2/2] kvm, x86: broadcast mce depending on the cpu version Date: Tue, 19 Oct 2010 11:04:47 +0900 Message-ID: <4CBCFCBF.1060509@jp.fujitsu.com> References: <4CB6C580.1090804@np.css.fujitsu.com> <20101015010649.GB32272@amt.cnet> <4CB7B3C5.7070102@jp.fujitsu.com> <20101015133012.GA16246@amt.cnet> <4CBCFB71.3070103@jp.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Jin Dongming , KVM list , Dean Nelson , "qemu-devel@nongnu.org" , Avi Kivity , Huang Ying To: Marcelo Tosatti Return-path: Received: from fgwmail6.fujitsu.co.jp ([192.51.44.36]:35129 "EHLO fgwmail6.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755008Ab0JSCFK (ORCPT ); Mon, 18 Oct 2010 22:05:10 -0400 Received: from m6.gw.fujitsu.co.jp ([10.0.50.76]) by fgwmail6.fujitsu.co.jp (Fujitsu Gateway) with ESMTP id o9J255Og009371 for (envelope-from seto.hidetoshi@jp.fujitsu.com); Tue, 19 Oct 2010 11:05:06 +0900 Received: from smail (m6 [127.0.0.1]) by outgoing.m6.gw.fujitsu.co.jp (Postfix) with ESMTP id 30AA945DE51 for ; Tue, 19 Oct 2010 11:05:05 +0900 (JST) Received: from s6.gw.fujitsu.co.jp (s6.gw.fujitsu.co.jp [10.0.50.96]) by m6.gw.fujitsu.co.jp (Postfix) with ESMTP id 0246645DE4F for ; Tue, 19 Oct 2010 11:05:05 +0900 (JST) Received: from s6.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s6.gw.fujitsu.co.jp (Postfix) with ESMTP id DFA77E38004 for ; Tue, 19 Oct 2010 11:05:04 +0900 (JST) Received: from ml13.s.css.fujitsu.com (ml13.s.css.fujitsu.com [10.249.87.103]) by s6.gw.fujitsu.co.jp (Postfix) with ESMTP id 9DCEDE38001 for ; Tue, 19 Oct 2010 11:05:04 +0900 (JST) In-Reply-To: <4CBCFB71.3070103@jp.fujitsu.com> Sender: kvm-owner@vger.kernel.org List-ID: There is no reason why SRAO event received by the main thread is the only one that being broadcasted. According to the x86 ASDM vol.3A 15.10.4.1, MCE signal is broadcast on processor version 06H_EH or later. This change is required to handle SRAR in smp guests. Signed-off-by: Hidetoshi Seto --- target-i386/kvm.c | 28 ++++++++++++++++++++++++---- 1 files changed, 24 insertions(+), 4 deletions(-) diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 98a0505..e97fbd3 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -1631,6 +1631,28 @@ static void hardware_memory_error(void) exit(1); } +#ifdef KVM_CAP_MCE +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 (cenv == env) { + continue; + } + for (cenv = first_cpu; cenv != NULL; cenv = cenv->next_cpu) { + kvm_inject_x86_mce(cenv, 1, MCI_STATUS_VAL | MCI_STATUS_UC, + MCG_STATUS_MCIP | MCG_STATUS_RIPV, 0, 0, 1); + } + } +} +#endif + int kvm_on_sigbus_vcpu(CPUState *env, int code, void *addr) { #if defined(KVM_CAP_MCE) @@ -1688,6 +1710,7 @@ int kvm_on_sigbus_vcpu(CPUState *env, int code, void *addr) fprintf(stderr, "kvm_set_mce: %s\n", strerror(errno)); abort(); } + kvm_mce_broadcast_rest(env); } else #endif { @@ -1726,10 +1749,7 @@ int kvm_on_sigbus(int code, void *addr) kvm_inject_x86_mce(first_cpu, 9, status, MCG_STATUS_MCIP | MCG_STATUS_RIPV, paddr, (MCM_ADDR_PHYS << 6) | 0xc, 1); - for (cenv = first_cpu->next_cpu; cenv != NULL; cenv = cenv->next_cpu) { - kvm_inject_x86_mce(cenv, 1, MCI_STATUS_VAL | MCI_STATUS_UC, - MCG_STATUS_MCIP | MCG_STATUS_RIPV, 0, 0, 1); - } + kvm_mce_broadcast_rest(first_cpu); } else #endif { -- 1.7.3.1