From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jin Dongming Subject: [PATCH 1/2] Add "broadcast" option for mce command. Date: Thu, 25 Nov 2010 10:19:30 +0900 Message-ID: <4CEDB9A2.1030606@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 , Hidetoshi Seto , Dean Nelson , KVM list To: Avi Kivity , Marcelo Tosatti Return-path: Received: from fgwmail5.fujitsu.co.jp ([192.51.44.35]:53141 "EHLO fgwmail5.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752382Ab0KYBRX (ORCPT ); Wed, 24 Nov 2010 20:17:23 -0500 Received: from m6.gw.fujitsu.co.jp ([10.0.50.76]) by fgwmail5.fujitsu.co.jp (Fujitsu Gateway) with ESMTP id oAP1HL18009642 for (envelope-from jin.dongming@np.css.fujitsu.com); Thu, 25 Nov 2010 10:17:21 +0900 Received: from smail (m6 [127.0.0.1]) by outgoing.m6.gw.fujitsu.co.jp (Postfix) with ESMTP id AAED545DE50 for ; Thu, 25 Nov 2010 10:17:21 +0900 (JST) Received: from s6.gw.fujitsu.co.jp (s6.gw.fujitsu.co.jp [10.0.50.96]) by m6.gw.fujitsu.co.jp (Postfix) with ESMTP id 7A48A45DD71 for ; Thu, 25 Nov 2010 10:17:21 +0900 (JST) Received: from s6.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s6.gw.fujitsu.co.jp (Postfix) with ESMTP id 639261DB8014 for ; Thu, 25 Nov 2010 10:17:21 +0900 (JST) Received: from m003.s.css.fujitsu.com (m003.s.css.fujitsu.com [10.23.4.33]) by s6.gw.fujitsu.co.jp (Postfix) with ESMTP id 0D1091DB8012 for ; Thu, 25 Nov 2010 10:17:21 +0900 (JST) Sender: kvm-owner@vger.kernel.org List-ID: 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 --- 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