Skip to contentSkip to conversation

reset mce registers of the given VCPU or all VCPUs with mce command.

PATCH In review Jin Dongming 2 participants 3 messages Nov 25, 2010 KVM

lore
Share & tools
lore
#0 lore raw

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

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.)

---
 hmp-commands.hx |    4 +++-
 monitor.c       |   15 ++++++++++++++-
 2 files changed, 17 insertions(+), 2 deletions(-)
hmp-commands.hx +3 -1
index 3a93837..3f1389d 100644
@@ -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",
monitor.c +14 -1
index 9d0a98e..419fafd 100644
@@ -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)
Signature · 1 line
1.7.1.1
#1 lore raw
Quoted 21 lines · Jin Dongming
monitor.c +7 -1
@@ -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)

monitor.c static void do_inject_mce(Monitor *mon, const QDict *qdict) · line 2296

Quoted 10 lines
monitor.c +7 -0
+                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)

Are you sure there is no test cases that require the Machine Check registers not cleared? I have had a test case before that injects another MCE when MCIP in MCGSTATUS is set to check whether system will go reset.

It may be better to clear MC registers in an explicit mode.

Best Regards,
Huang Ying

#2 lore raw

Hi, Huang-san

Quoted 38 lines · Huang Ying
Quoted 21 lines · Jin Dongming
monitor.c +7 -1
@@ -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)

monitor.c static void do_inject_mce(Monitor *mon, const QDict *qdict) · line 2296

Quoted 10 lines
monitor.c +7 -0
+                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)

Are you sure there is no test cases that require the Machine Check registers not cleared? I have had a test case before that injects another MCE when MCIP in MCGSTATUS is set to check whether system will go reset.

Quoted 1 line

It may be better to clear MC registers in an explicit mode.

MC registers could be cleared in Guest OS with APL. So I will cancel this patch.

I will resend the patch for broadcast option.

Best Regards,
Jin Dongming

Quoted 11 lines

Best Regards,
Huang Ying

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