public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] reset mce registers of the given VCPU or all VCPUs with mce command.
@ 2010-11-25  1:20 Jin Dongming
  2010-11-25  5:55 ` Huang Ying
  0 siblings, 1 reply; 3+ messages in thread
From: Jin Dongming @ 2010-11-25  1:20 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti
  Cc: Andi Kleen, Huang Ying, Dean Nelson, Hidetoshi Seto, KVM list

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 <jin.dongming@np.css.fujitsu.com>
---
 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



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-11-25  8:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-25  1:20 [PATCH 2/2] reset mce registers of the given VCPU or all VCPUs with mce command Jin Dongming
2010-11-25  5:55 ` Huang Ying
2010-11-25  8:46   ` Jin Dongming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox