From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jin Dongming Subject: [PATCH 1/3] kvm, x86: introduce kvm_mce_in_progress Date: Fri, 10 Dec 2010 17:24:43 +0900 Message-ID: <4D01E3CB.20809@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 fgwmail7.fujitsu.co.jp ([192.51.44.37]:36081 "EHLO fgwmail7.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752521Ab0LJIW0 (ORCPT ); Fri, 10 Dec 2010 03:22:26 -0500 Received: from m1.gw.fujitsu.co.jp ([10.0.50.71]) by fgwmail7.fujitsu.co.jp (Fujitsu Gateway) with ESMTP id oBA8MPFS026654 for (envelope-from jin.dongming@np.css.fujitsu.com); Fri, 10 Dec 2010 17:22:25 +0900 Received: from smail (m1 [127.0.0.1]) by outgoing.m1.gw.fujitsu.co.jp (Postfix) with ESMTP id 0FF4545DE5E for ; Fri, 10 Dec 2010 17:22:25 +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 EA95245DE5D for ; Fri, 10 Dec 2010 17:22:24 +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 DBE91E08003 for ; Fri, 10 Dec 2010 17:22:24 +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 A4E41E38003 for ; Fri, 10 Dec 2010 17:22:24 +0900 (JST) Sender: kvm-owner@vger.kernel.org List-ID: Share same error handing, and rename this function after MCIP (Machine Check In Progress) flag. Signed-off-by: Hidetoshi Seto Signed-off-by: Jin Dongming --- target-i386/kvm.c | 15 +++++---------- 1 files changed, 5 insertions(+), 10 deletions(-) diff --git a/target-i386/kvm.c b/target-i386/kvm.c index a7261c0..d7aae8b 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -219,7 +219,7 @@ static int kvm_get_msr(CPUState *env, struct kvm_msr_entry *msrs, int n) } /* FIXME: kill this and kvm_get_msr, use env->mcg_status instead */ -static int kvm_mce_in_exception(CPUState *env) +static int kvm_mce_in_progress(CPUState *env) { struct kvm_msr_entry msr_mcg_status = { .index = MSR_MCG_STATUS, @@ -228,7 +228,8 @@ static int kvm_mce_in_exception(CPUState *env) r = kvm_get_msr(env, &msr_mcg_status, 1); if (r == -1 || r == 0) { - return -1; + fprintf(stderr, "Failed to get MCE status\n"); + return 0; } return !!(msr_mcg_status.data & MCG_STATUS_MCIP); } @@ -248,10 +249,7 @@ static void kvm_do_inject_x86_mce(void *_data) /* If there is an MCE exception being processed, ignore this SRAO MCE */ if ((data->env->mcg_cap & MCG_SER_P) && !(data->mce->status & MCI_STATUS_AR)) { - r = kvm_mce_in_exception(data->env); - if (r == -1) { - fprintf(stderr, "Failed to get MCE status\n"); - } else if (r) { + if (kvm_mce_in_progress(data->env)) { return; } } @@ -1782,10 +1780,7 @@ int kvm_on_sigbus_vcpu(CPUState *env, int code, void *addr) * If there is an MCE excpetion being processed, ignore * this SRAO MCE */ - r = kvm_mce_in_exception(env); - if (r == -1) { - fprintf(stderr, "Failed to get MCE status\n"); - } else if (r) { + if (kvm_mce_in_progress(env)) { return 0; } /* Fake an Intel architectural Memory scrubbing UCR */ -- 1.7.1.1