From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jin Dongming Subject: [PATCH 2/2] reset mce registers of the given VCPU or all VCPUs with mce command. Date: Thu, 25 Nov 2010 10:20:58 +0900 Message-ID: <4CEDB9FA.5000400@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 , Dean Nelson , Hidetoshi Seto , KVM list To: Avi Kivity , Marcelo Tosatti Return-path: Received: from fgwmail6.fujitsu.co.jp ([192.51.44.36]:51998 "EHLO fgwmail6.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754491Ab0KYBSx (ORCPT ); Wed, 24 Nov 2010 20:18:53 -0500 Received: from m4.gw.fujitsu.co.jp ([10.0.50.74]) by fgwmail6.fujitsu.co.jp (Fujitsu Gateway) with ESMTP id oAP1IqFH012650 for (envelope-from jin.dongming@np.css.fujitsu.com); Thu, 25 Nov 2010 10:18:53 +0900 Received: from smail (m4 [127.0.0.1]) by outgoing.m4.gw.fujitsu.co.jp (Postfix) with ESMTP id 9567445DE60 for ; Thu, 25 Nov 2010 10:18:52 +0900 (JST) Received: from s4.gw.fujitsu.co.jp (s4.gw.fujitsu.co.jp [10.0.50.94]) by m4.gw.fujitsu.co.jp (Postfix) with ESMTP id 62EB745DE7E for ; Thu, 25 Nov 2010 10:18:52 +0900 (JST) Received: from s4.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s4.gw.fujitsu.co.jp (Postfix) with ESMTP id 225791DB803A for ; Thu, 25 Nov 2010 10:18:52 +0900 (JST) Received: from m002.s.css.fujitsu.com (m002.s.css.fujitsu.com [10.23.4.32]) by s4.gw.fujitsu.co.jp (Postfix) with ESMTP id 5F7371DB803B for ; Thu, 25 Nov 2010 10:18:51 +0900 (JST) Sender: kvm-owner@vger.kernel.org List-ID: For saving test time, fake_panic will be set when mce test is done. After setting fake_panic==1, injecting mce from qemu-monitor to test mce of Guest OS, fatal mce data of last time will not be cleared. And the result of this time is not right. Before testing mce, mce registers could be reset with mce command now. This operation could be sure the result more reliable. The usage of resetting mce registers with mce command is like following: COMMAND CPU BANK STATUS MCG_STATUS ADDR MISC BROADCAST given VCPU: (qemu) mce N 0 0 0 0 0 - all VCPUs: (qemu) mce N 0 0 0 0 0 broadcast/b (Comment: "N" is the number of VCPU; "-" means no option.) Signed-off-by: Jin Dongming --- hmp-commands.hx | 4 +++- monitor.c | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index 3a93837..3f1389d 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1056,7 +1056,9 @@ ETEXI #if defined(KVM_CAP_MCE) .args_type = "cpu_index:i,bank:i,status:l,mcg_status:l,addr:l,misc:l,broadcast:s?", .params = "cpu bank status mcgstatus addr misc [broadcast|b]", - .help = "inject a MCE on the given CPU [and broadcast to other CPUs]", + .help = "\n1. inject a MCE on the given CPU [and broadcast to other CPUs] \ + \n2. reset MCE registers on the given CPU with !status and !mcg_status \ + \n [and reset other CPUs with broadcast/b option]", #else .args_type = "cpu_index:i,bank:i,status:l,mcg_status:l,addr:l,misc:l", .params = "cpu bank status mcgstatus addr misc", diff --git a/monitor.c b/monitor.c index 9d0a98e..419fafd 100644 --- a/monitor.c +++ b/monitor.c @@ -60,6 +60,7 @@ #include "trace.h" #endif #include "qemu-kvm.h" +#include "kvm_x86.h" //#define DEBUG //#define DEBUG_COMPLETION @@ -2277,7 +2278,19 @@ static void do_inject_mce(Monitor *mon, const QDict *qdict) #endif for (cenv = first_cpu; cenv != NULL; cenv = cenv->next_cpu) { - if (cenv->cpu_index == cpu_index && cenv->mcg_cap) { + if (!cenv->mcg_cap) + continue; + +#if defined(KVM_CAP_MCE) + if (!status && !mcg_status) { + if (cenv->cpu_index == cpu_index || broadcast) + kvm_inject_x86_mce(cenv, 0, 0, 0, 0, 0, 0); + + continue; + } +#endif + + if (cenv->cpu_index == cpu_index) { cpu_inject_x86_mce(cenv, bank, status, mcg_status, addr, misc); #if defined(KVM_CAP_MCE) if (broadcast) -- 1.7.1.1