[PATCH 2/2] reset mce registers of the given VCPU or all VCPUs with mce command.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxx>
---
 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


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux