From: Jan Kiszka <jan.kiszka@web.de>
To: Marcelo Tosatti <mtosatti@redhat.com>,
Anthony Liguori <aliguori@us.ibm.com>
Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org,
Jin Dongming <jin.dongming@np.css.fujitsu.com>
Subject: [Qemu-devel] Re: [PATCH 04/35] Add "broadcast" option for mce command
Date: Sun, 09 Jan 2011 19:51:20 +0100 [thread overview]
Message-ID: <4D2A03A8.9080600@web.de> (raw)
In-Reply-To: <497ea69043289b0421a8265f32e9b1a80a3c9481.1294336601.git.mtosatti@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 7886 bytes --]
Am 06.01.2011 18:56, Marcelo Tosatti wrote:
> From: Jin Dongming <jin.dongming@np.css.fujitsu.com>
>
> 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.
>
> Usage:
> Broadcast[on]
> command broadcast cpu bank status mcg_status addr misc
> (qemu) mce -b 1 1 0xbd00000000000000 0x05 0x1234 0x8c
>
> Broadcast[off]
> command cpu bank status mcg_status addr misc
> (qemu) mce 1 1 0xbd00000000000000 0x05 0x1234 0x8c
>
> Signed-off-by: Jin Dongming <jin.dongming@np.css.fujitsu.com>
> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
> ---
> cpu-all.h | 3 ++-
> hmp-commands.hx | 6 +++---
> monitor.c | 7 +++++--
> target-i386/helper.c | 20 ++++++++++++++++++--
> target-i386/kvm.c | 16 ++++++++++++----
> target-i386/kvm_x86.h | 5 ++++-
> 6 files changed, 44 insertions(+), 13 deletions(-)
>
> diff --git a/cpu-all.h b/cpu-all.h
> index 30ae17d..4ce4e83 100644
> --- a/cpu-all.h
> +++ b/cpu-all.h
> @@ -964,6 +964,7 @@ int cpu_memory_rw_debug(CPUState *env, target_ulong addr,
> uint8_t *buf, int len, int is_write);
>
> void cpu_inject_x86_mce(CPUState *cenv, int bank, uint64_t status,
> - uint64_t mcg_status, uint64_t addr, uint64_t misc);
> + uint64_t mcg_status, uint64_t addr, uint64_t misc,
> + int broadcast);
>
> #endif /* CPU_ALL_H */
> diff --git a/hmp-commands.hx b/hmp-commands.hx
> index df134f8..c82fb10 100644
> --- a/hmp-commands.hx
> +++ b/hmp-commands.hx
> @@ -1091,9 +1091,9 @@ ETEXI
>
> {
> .name = "mce",
> - .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",
> + .args_type = "broadcast:-b,cpu_index:i,bank:i,status:l,mcg_status:l,addr:l,misc:l",
> + .params = "[-b] cpu bank status mcgstatus addr misc",
> + .help = "inject a MCE on the given CPU [and broadcast to other CPUs with -b option]",
> .mhandler.cmd = do_inject_mce,
> },
>
> diff --git a/monitor.c b/monitor.c
> index f258000..f4f624b 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -2671,12 +2671,15 @@ 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");
> + int broadcast = qdict_get_try_bool(qdict, "broadcast", 0);
>
> - for (cenv = first_cpu; cenv != NULL; cenv = cenv->next_cpu)
> + 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);
> + cpu_inject_x86_mce(cenv, bank, status, mcg_status, addr, misc,
> + broadcast);
> break;
> }
> + }
> }
> #endif
>
> diff --git a/target-i386/helper.c b/target-i386/helper.c
> index 2c94130..2cfb4a4 100644
> --- a/target-i386/helper.c
> +++ b/target-i386/helper.c
> @@ -1069,18 +1069,34 @@ static void qemu_inject_x86_mce(CPUState *cenv, int bank, uint64_t status,
> }
>
> void cpu_inject_x86_mce(CPUState *cenv, int bank, uint64_t status,
> - uint64_t mcg_status, uint64_t addr, uint64_t misc)
> + uint64_t mcg_status, uint64_t addr, uint64_t misc,
> + int broadcast)
> {
> unsigned bank_num = cenv->mcg_cap & 0xff;
> + CPUState *env;
> + int flag = 0;
>
> if (bank >= bank_num || !(status & MCI_STATUS_VAL)) {
> return;
> }
>
> if (kvm_enabled()) {
> - kvm_inject_x86_mce(cenv, bank, status, mcg_status, addr, misc, 0);
> + if (broadcast) {
> + flag |= MCE_BROADCAST;
> + }
> +
> + kvm_inject_x86_mce(cenv, bank, status, mcg_status, addr, misc, flag);
> } else {
> qemu_inject_x86_mce(cenv, bank, status, mcg_status, addr, misc);
> + if (broadcast) {
> + for (env = first_cpu; env != NULL; env = env->next_cpu) {
> + if (cenv == env) {
> + continue;
> + }
> +
> + qemu_inject_x86_mce(env, 1, 0xa000000000000000, 0, 0, 0);
Constant lacks "ULL". Can probably be fixed up on commit.
Jan
> + }
> + }
> }
> }
> #endif /* !CONFIG_USER_ONLY */
> diff --git a/target-i386/kvm.c b/target-i386/kvm.c
> index 4004de7..8b868ad 100644
> --- a/target-i386/kvm.c
> +++ b/target-i386/kvm.c
> @@ -264,11 +264,13 @@ static void kvm_do_inject_x86_mce(void *_data)
> }
> }
> }
> +
> +static void kvm_mce_broadcast_rest(CPUState *env);
> #endif
>
> void kvm_inject_x86_mce(CPUState *cenv, int bank, uint64_t status,
> uint64_t mcg_status, uint64_t addr, uint64_t misc,
> - int abort_on_error)
> + int flag)
> {
> #ifdef KVM_CAP_MCE
> struct kvm_x86_mce mce = {
> @@ -288,10 +290,15 @@ void kvm_inject_x86_mce(CPUState *cenv, int bank, uint64_t status,
> return;
> }
>
> + if (flag & MCE_BROADCAST) {
> + kvm_mce_broadcast_rest(cenv);
> + }
> +
> run_on_cpu(cenv, kvm_do_inject_x86_mce, &data);
> #else
> - if (abort_on_error)
> + if (flag & ABORT_ON_ERROR) {
> abort();
> + }
> #endif
> }
>
> @@ -1716,7 +1723,8 @@ static void kvm_mce_broadcast_rest(CPUState *env)
> continue;
> }
> kvm_inject_x86_mce(cenv, 1, MCI_STATUS_VAL | MCI_STATUS_UC,
> - MCG_STATUS_MCIP | MCG_STATUS_RIPV, 0, 0, 1);
> + MCG_STATUS_MCIP | MCG_STATUS_RIPV, 0, 0,
> + ABORT_ON_ERROR);
> }
> }
> }
> @@ -1816,7 +1824,7 @@ int kvm_on_sigbus(int code, void *addr)
> | 0xc0;
> kvm_inject_x86_mce(first_cpu, 9, status,
> MCG_STATUS_MCIP | MCG_STATUS_RIPV, paddr,
> - (MCM_ADDR_PHYS << 6) | 0xc, 1);
> + (MCM_ADDR_PHYS << 6) | 0xc, ABORT_ON_ERROR);
> kvm_mce_broadcast_rest(first_cpu);
> } else
> #endif
> diff --git a/target-i386/kvm_x86.h b/target-i386/kvm_x86.h
> index 04932cf..9d7b584 100644
> --- a/target-i386/kvm_x86.h
> +++ b/target-i386/kvm_x86.h
> @@ -15,8 +15,11 @@
> #ifndef __KVM_X86_H__
> #define __KVM_X86_H__
>
> +#define ABORT_ON_ERROR 0x01
> +#define MCE_BROADCAST 0x02
> +
> void kvm_inject_x86_mce(CPUState *cenv, int bank, uint64_t status,
> uint64_t mcg_status, uint64_t addr, uint64_t misc,
> - int abort_on_error);
> + int flag);
>
> #endif
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]
next prev parent reply other threads:[~2011-01-09 18:51 UTC|newest]
Thread overview: 152+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-06 17:56 [Qemu-devel] [PATCH 00/35] [PULL] qemu-kvm.git uq/master queue Marcelo Tosatti
2011-01-06 17:56 ` [Qemu-devel] [PATCH 01/35] kvm: Enable user space NMI injection for kvm guest Marcelo Tosatti
2011-01-06 17:56 ` [Qemu-devel] [PATCH 02/35] kvm: convert kvm_ioctl(KVM_CHECK_EXTENSION) to kvm_check_extension() Marcelo Tosatti
2011-01-06 17:56 ` [Qemu-devel] [PATCH 03/35] Clean up cpu_inject_x86_mce() Marcelo Tosatti
2011-01-06 17:56 ` [Qemu-devel] [PATCH 04/35] Add "broadcast" option for mce command Marcelo Tosatti
2011-01-09 18:51 ` Jan Kiszka [this message]
2011-01-15 16:24 ` [Qemu-devel] " Jan Kiszka
2011-01-06 17:56 ` [Qemu-devel] [PATCH 05/35] Add function for checking mca broadcast of CPU Marcelo Tosatti
2011-01-06 17:56 ` [Qemu-devel] [PATCH 06/35] kvm: introduce kvm_mce_in_progress Marcelo Tosatti
2011-01-06 17:56 ` [Qemu-devel] [PATCH 07/35] kvm: kvm_mce_inj_* subroutines for templated error injections Marcelo Tosatti
2011-01-06 17:56 ` [Qemu-devel] [PATCH 08/35] kvm: introduce kvm_inject_x86_mce_on Marcelo Tosatti
2011-01-06 17:56 ` [Qemu-devel] [PATCH 09/35] kvm: x86: Fix DPL write back of segment registers Marcelo Tosatti
2011-01-06 17:56 ` [Qemu-devel] [PATCH 10/35] kvm: x86: Remove obsolete SS.RPL/DPL aligment Marcelo Tosatti
2011-01-06 17:56 ` [Qemu-devel] [PATCH 11/35] kvm: x86: Prevent sign extension of DR7 in guest debugging mode Marcelo Tosatti
2011-01-06 17:56 ` [Qemu-devel] [PATCH 12/35] kvm: x86: Fix a few coding style violations Marcelo Tosatti
2011-01-06 17:56 ` [Qemu-devel] [PATCH 13/35] kvm: Fix " Marcelo Tosatti
2011-01-06 17:56 ` [Qemu-devel] [PATCH 14/35] kvm: Drop return value of kvm_cpu_exec Marcelo Tosatti
2011-01-08 13:09 ` [Qemu-devel] " Jan Kiszka
2011-01-06 17:56 ` [Qemu-devel] [PATCH 15/35] kvm: Stop on all fatal exit reasons Marcelo Tosatti
2011-01-06 17:56 ` [Qemu-devel] [PATCH 16/35] kvm: Improve reporting of fatal errors Marcelo Tosatti
2011-01-06 17:56 ` [Qemu-devel] [PATCH 17/35] x86: Optionally dump code bytes on cpu_dump_state Marcelo Tosatti
2011-01-06 17:56 ` [Qemu-devel] [PATCH 18/35] kvm: x86: Align kvm_arch_put_registers code with comment Marcelo Tosatti
2011-01-06 17:56 ` [Qemu-devel] [PATCH 19/35] kvm: x86: Prepare kvm_get_mp_state for in-kernel irqchip Marcelo Tosatti
2011-01-06 17:56 ` [Qemu-devel] [PATCH 20/35] kvm: x86: Remove redundant mp_state initialization Marcelo Tosatti
2011-01-06 17:56 ` [Qemu-devel] [PATCH 21/35] kvm: x86: Fix xcr0 reset mismerge Marcelo Tosatti
2011-01-06 17:56 ` [Qemu-devel] [PATCH 22/35] kvm: x86: Refactor msr_star/hsave_pa setup and checks Marcelo Tosatti
2011-01-06 17:56 ` [Qemu-devel] [PATCH 23/35] kvm: x86: Reset paravirtual MSRs Marcelo Tosatti
2011-01-06 17:56 ` [Qemu-devel] [PATCH 24/35] Synchronize VCPU states before reset Marcelo Tosatti
2011-01-06 17:56 ` [Qemu-devel] [PATCH 25/35] kvm: x86: Drop MCE MSRs write back restrictions Marcelo Tosatti
2011-01-06 17:56 ` [Qemu-devel] [PATCH 26/35] kvm: Eliminate KVMState arguments Marcelo Tosatti
2011-01-06 19:24 ` [Qemu-devel] " Anthony Liguori
2011-01-07 9:03 ` Jan Kiszka
2011-01-07 23:27 ` Anthony Liguori
2011-01-08 8:47 ` Jan Kiszka
2011-01-10 19:59 ` Anthony Liguori
2011-01-10 20:12 ` Jan Kiszka
2011-01-10 20:23 ` Anthony Liguori
2011-01-10 20:34 ` Jan Kiszka
2011-01-11 9:01 ` Avi Kivity
2011-01-11 14:00 ` Anthony Liguori
2011-01-11 14:06 ` Alexander Graf
2011-01-11 14:09 ` Anthony Liguori
2011-01-11 14:22 ` Avi Kivity
2011-01-11 14:36 ` Anthony Liguori
2011-01-11 14:56 ` Avi Kivity
2011-01-11 15:12 ` Anthony Liguori
2011-01-11 15:17 ` Alexander Graf
2011-01-11 15:37 ` Avi Kivity
2011-01-11 15:55 ` Anthony Liguori
2011-01-11 16:03 ` Avi Kivity
2011-01-11 16:26 ` Anthony Liguori
2011-01-11 17:05 ` Avi Kivity
2011-01-11 14:24 ` Alexander Graf
2011-01-11 14:18 ` Avi Kivity
2011-01-11 14:28 ` Anthony Liguori
2011-01-11 14:52 ` Avi Kivity
2011-01-10 20:11 ` Anthony Liguori
2011-01-10 20:15 ` Jan Kiszka
2011-01-11 9:17 ` Avi Kivity
2011-01-06 17:56 ` [Qemu-devel] [PATCH 27/35] kvm: x86: Fix !CONFIG_KVM_PARA build Marcelo Tosatti
2011-01-06 17:56 ` [Qemu-devel] [PATCH 28/35] kvm: x86: Introduce kvmclock device to save/restore its state Marcelo Tosatti
2011-01-10 20:31 ` Anthony Liguori
2011-01-10 21:06 ` Jan Kiszka
2011-01-10 22:21 ` Jan Kiszka
2011-01-10 23:02 ` Anthony Liguori
2011-01-11 5:54 ` Jan Kiszka
2011-01-11 8:00 ` Paolo Bonzini
2011-01-11 8:53 ` Gerd Hoffmann
2011-01-11 17:13 ` Jan Kiszka
2011-01-11 9:31 ` Markus Armbruster
2011-01-11 13:54 ` Anthony Liguori
2011-01-12 10:22 ` Avi Kivity
2011-01-12 10:31 ` Jan Kiszka
2011-01-18 14:28 ` Jan Kiszka
2011-01-18 15:04 ` Anthony Liguori
2011-01-18 15:43 ` Jan Kiszka
2011-01-18 15:48 ` Anthony Liguori
2011-01-18 15:54 ` Jan Kiszka
2011-01-18 17:02 ` Alex Williamson
2011-01-18 17:08 ` Jan Kiszka
2011-01-18 17:39 ` Alex Williamson
2011-01-18 15:50 ` Anthony Liguori
2011-01-18 16:01 ` Jan Kiszka
2011-01-18 16:04 ` Anthony Liguori
2011-01-18 16:17 ` Jan Kiszka
2011-01-18 16:37 ` Anthony Liguori
2011-01-18 16:56 ` Jan Kiszka
2011-01-18 17:09 ` Anthony Liguori
2011-01-18 17:20 ` Jan Kiszka
2011-01-18 17:31 ` Anthony Liguori
2011-01-18 17:45 ` Jan Kiszka
2011-01-19 9:48 ` Gerd Hoffmann
2011-01-19 13:11 ` Markus Armbruster
2011-01-19 16:54 ` Anthony Liguori
2011-01-19 17:19 ` Daniel P. Berrange
2011-01-19 17:43 ` Anthony Liguori
2011-01-20 8:44 ` Gerd Hoffmann
2011-01-20 10:33 ` Daniel P. Berrange
2011-01-20 19:42 ` Anthony Liguori
2011-01-20 19:39 ` Anthony Liguori
2011-01-21 8:35 ` Gerd Hoffmann
2011-01-21 10:03 ` Markus Armbruster
2011-01-19 16:53 ` Anthony Liguori
2011-01-19 17:01 ` Daniel P. Berrange
2011-01-19 17:51 ` Anthony Liguori
2011-01-19 18:52 ` Daniel P. Berrange
2011-01-19 18:58 ` Anthony Liguori
2011-01-19 17:35 ` Daniel P. Berrange
2011-01-19 17:42 ` Anthony Liguori
2011-01-19 18:53 ` Daniel P. Berrange
2011-01-19 13:09 ` Markus Armbruster
2011-01-24 8:45 ` Gleb Natapov
2011-01-19 13:15 ` Markus Armbruster
2011-01-19 16:57 ` Anthony Liguori
2011-01-19 17:25 ` Jan Kiszka
2011-01-19 19:32 ` Blue Swirl
2011-01-20 9:33 ` Jan Kiszka
2011-01-20 19:27 ` Blue Swirl
2011-01-20 21:22 ` Jan Kiszka
2011-01-20 21:40 ` Blue Swirl
2011-01-20 21:53 ` Jan Kiszka
2011-01-25 11:10 ` Avi Kivity
2011-01-21 8:46 ` Gerd Hoffmann
2011-01-21 10:05 ` Markus Armbruster
2011-01-21 16:37 ` Blue Swirl
2011-01-21 17:21 ` Jan Kiszka
2011-01-21 18:04 ` Blue Swirl
2011-01-21 18:17 ` Jan Kiszka
2011-01-21 18:49 ` Blue Swirl
2011-01-24 14:08 ` Jan Kiszka
2011-01-24 21:35 ` Blue Swirl
2011-01-24 21:57 ` Jan Kiszka
2011-01-20 19:37 ` Anthony Liguori
2011-01-20 20:02 ` Blue Swirl
2011-01-20 21:42 ` Jan Kiszka
2011-01-20 21:27 ` Jan Kiszka
2011-01-25 11:06 ` Avi Kivity
2011-01-25 14:30 ` Anthony Liguori
2011-01-25 10:34 ` Avi Kivity
2011-01-25 10:27 ` Avi Kivity
2011-01-25 13:58 ` Anthony Liguori
2011-01-12 12:04 ` Markus Armbruster
2011-01-10 23:04 ` Anthony Liguori
2011-01-11 5:55 ` Jan Kiszka
2011-01-06 17:56 ` [Qemu-devel] [PATCH 29/35] kvm: Drop smp_cpus argument from init functions Marcelo Tosatti
2011-01-06 17:56 ` [Qemu-devel] [PATCH 30/35] kvm: Consolidate must-have capability checks Marcelo Tosatti
2011-01-06 17:56 ` [Qemu-devel] [PATCH 31/35] kvm: x86: Rework identity map and TSS setup for larger BIOS sizes Marcelo Tosatti
2011-01-06 17:56 ` [Qemu-devel] [PATCH 32/35] kvm: Flush coalesced mmio buffer on IO window exits Marcelo Tosatti
2011-01-06 17:56 ` [Qemu-devel] [PATCH 33/35] kvm: Do not use qemu_fair_mutex Marcelo Tosatti
2011-01-06 17:56 ` [Qemu-devel] [PATCH 34/35] kvm: x86: Implicitly clear nmi_injected/pending on reset Marcelo Tosatti
2011-01-06 17:56 ` [Qemu-devel] [PATCH 35/35] kvm: x86: Only read/write MSR_KVM_ASYNC_PF_EN if supported Marcelo Tosatti
2011-01-27 14:39 ` [Qemu-devel] [PATCH] kvm: x86: Fix build in absence of KVM_CAP_ASYNC_PF Jan Kiszka
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=4D2A03A8.9080600@web.de \
--to=jan.kiszka@web.de \
--cc=aliguori@us.ibm.com \
--cc=jin.dongming@np.css.fujitsu.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=qemu-devel@nongnu.org \
/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;
as well as URLs for NNTP newsgroup(s).