public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Jin Dongming <jin.dongming@np.css.fujitsu.com>
To: Avi Kivity <avi@redhat.com>, Marcelo Tosatti <mtosatti@redhat.com>
Cc: Andi Kleen <andi@firstfloor.org>,
	Huang Ying <ying.huang@intel.com>,
	Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>,
	Dean Nelson <dnelson@redhat.com>, KVM list <kvm@vger.kernel.org>
Subject: [PATCH 1/2] Add "broadcast" option for mce command.
Date: Thu, 25 Nov 2010 10:19:30 +0900	[thread overview]
Message-ID: <4CEDB9A2.1030606@np.css.fujitsu.com> (raw)

When the following test case is injected with mce command, maybe user could not
get the expected result.
    DATA
               command cpu bank status             mcg_status  addr   misc
        (qemu) mce     1   1    0xbd00000000000000 0x05        0x1234 0x8c

    Expected Result
           panic type: "Fatal Machine check"

That is because each mce command can only inject the given cpu and could not
inject mce interrupt to other cpus. So user will get the following result:
    panic type: "Fatal machine check on current CPU"

"broadcast" option is used for injecting dummy data into other cpus. Injecting mce
with this option the expected result could be gotten.

Signed-off-by: Jin Dongming <jin.dongming@np.css.fujitsu.com>
---
 hmp-commands.hx   |    6 ++++++
 monitor.c         |   19 ++++++++++++++++++-
 qemu-kvm.h        |    3 +++
 target-i386/kvm.c |    2 +-
 4 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/hmp-commands.hx b/hmp-commands.hx
index ba6de28..3a93837 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1053,9 +1053,15 @@ ETEXI
 
     {
         .name       = "mce",
+#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]",
+#else
         .args_type  = "cpu_index:i,bank:i,status:l,mcg_status:l,addr:l,misc:l",
         .params     = "cpu bank status mcgstatus addr misc",
         .help       = "inject a MCE on the given CPU",
+#endif
         .mhandler.cmd = do_inject_mce,
     },
 
diff --git a/monitor.c b/monitor.c
index 66d6acd..9d0a98e 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2263,12 +2263,29 @@ static void do_inject_mce(Monitor *mon, const QDict *qdict)
     uint64_t mcg_status = qdict_get_int(qdict, "mcg_status");
     uint64_t addr = qdict_get_int(qdict, "addr");
     uint64_t misc = qdict_get_int(qdict, "misc");
+#if defined(KVM_CAP_MCE)
+    const char *b = qdict_get_try_str(qdict, "broadcast");
+    int broadcast = 0;
 
-    for (cenv = first_cpu; cenv != NULL; cenv = cenv->next_cpu)
+    if (b) {
+        if (!strncmp(b, "broadcast", sizeof("broadcast")) ||
+            !strncmp(b, "b", sizeof("b"))) {
+            broadcast = 1;
+        } else
+            monitor_printf(mon, "Don't do broadcast: option invalid: %s\n", b);
+    }
+#endif
+
+    for (cenv = first_cpu; cenv != NULL; cenv = cenv->next_cpu) {
         if (cenv->cpu_index == cpu_index && cenv->mcg_cap) {
             cpu_inject_x86_mce(cenv, bank, status, mcg_status, addr, misc);
+#if defined(KVM_CAP_MCE)
+            if (broadcast)
+                kvm_mce_broadcast_rest(cenv);
+#endif
             break;
         }
+    } 
 }
 #endif
 
diff --git a/qemu-kvm.h b/qemu-kvm.h
index 0f3fb50..b3986cc 100644
--- a/qemu-kvm.h
+++ b/qemu-kvm.h
@@ -98,6 +98,9 @@ int try_push_interrupts(kvm_context_t kvm);
 
 #if defined(__x86_64__) || defined(__i386__)
 struct kvm_x86_mce;
+#if defined KVM_CAP_MCE
+extern void kvm_mce_broadcast_rest(CPUState *env);
+#endif
 #endif
 
 /*!
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index b7b2430..e3ebbb2 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -1705,7 +1705,7 @@ static void hardware_memory_error(void)
 }
 
 #ifdef KVM_CAP_MCE
-static void kvm_mce_broadcast_rest(CPUState *env)
+void kvm_mce_broadcast_rest(CPUState *env)
 {
     CPUState *cenv;
     int family, model, cpuver = env->cpuid_version;
-- 
1.7.1.1



             reply	other threads:[~2010-11-25  1:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-25  1:19 Jin Dongming [this message]
2010-11-25  1:33 ` [PATCH 1/2] Add "broadcast" option for mce command Huang Ying
2010-11-25  4:25   ` Jin Dongming

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4CEDB9A2.1030606@np.css.fujitsu.com \
    --to=jin.dongming@np.css.fujitsu.com \
    --cc=andi@firstfloor.org \
    --cc=avi@redhat.com \
    --cc=dnelson@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=seto.hidetoshi@jp.fujitsu.com \
    --cc=ying.huang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox