* [PATCH 1/2] Add "broadcast" option for mce command.
@ 2010-11-25 1:19 Jin Dongming
2010-11-25 1:33 ` Huang Ying
0 siblings, 1 reply; 3+ messages in thread
From: Jin Dongming @ 2010-11-25 1:19 UTC (permalink / raw)
To: Avi Kivity, Marcelo Tosatti
Cc: Andi Kleen, Huang Ying, Hidetoshi Seto, Dean Nelson, KVM list
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] Add "broadcast" option for mce command.
2010-11-25 1:19 [PATCH 1/2] Add "broadcast" option for mce command Jin Dongming
@ 2010-11-25 1:33 ` Huang Ying
2010-11-25 4:25 ` Jin Dongming
0 siblings, 1 reply; 3+ messages in thread
From: Huang Ying @ 2010-11-25 1:33 UTC (permalink / raw)
To: Jin Dongming
Cc: Avi Kivity, Marcelo Tosatti, Andi Kleen, Hidetoshi Seto,
Dean Nelson, KVM list
On Thu, 2010-11-25 at 09:19 +0800, Jin Dongming wrote:
[...]
> --- 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
Broadcast can not be used by QEMU-TCG?
[...]
Best Regards,
Huang Ying
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] Add "broadcast" option for mce command.
2010-11-25 1:33 ` Huang Ying
@ 2010-11-25 4:25 ` Jin Dongming
0 siblings, 0 replies; 3+ messages in thread
From: Jin Dongming @ 2010-11-25 4:25 UTC (permalink / raw)
To: Huang Ying
Cc: Avi Kivity, Marcelo Tosatti, Andi Kleen, Hidetoshi Seto,
Dean Nelson, KVM list
Hi, Huang-san
(2010/11/25 10:33), Huang Ying wrote:
> On Thu, 2010-11-25 at 09:19 +0800, Jin Dongming wrote:
> [...]
>
>> --- 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
>
> Broadcast can not be used by QEMU-TCG?
I must say sorry, I don't know much about QEMU-TCG.
Because broadcast option used kvm_mce_broadcast_rest() in KVM_CAP_MCE,
so if KVM_CAP_MCE is disabled, broadcast option could not work well.
And I don't know how mce command is used in other virtual machine
without KVM module, so I add ifdef to make sure this patch does not give
any impact to other virtual machine without KVM module.
Best Regards,
Jin Dongming
>
> [...]
>
> Best Regards,
> Huang Ying
>
>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-11-25 4:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-25 1:19 [PATCH 1/2] Add "broadcast" option for mce command Jin Dongming
2010-11-25 1:33 ` Huang Ying
2010-11-25 4:25 ` Jin Dongming
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox