Add "broadcast" option for mce command.
PATCH 1/2 Add "broadcast" option for mce command.
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.
--- hmp-commands.hx | 6 ++++++ monitor.c | 19 ++++++++++++++++++- qemu-kvm.h | 3 +++ target-i386/kvm.c | 2 +- 4 files changed, 28 insertions(+), 2 deletions(-)
hmp-commands.hx +6 -0
@@ -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, },
monitor.c +18 -1
@@ -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
qemu-kvm.h +3 -0
@@ -98,6 +98,9 @@ int try_push_interrupts(kvm_context_t kvm);#if defined(__x86_64__) || defined(__i386__)struct kvm_x86_mce ; +#if definedKVM_CAP_MCE +extern void kvm_mce_broadcast_rest (CPUState *env); +#endif #endif /*!
target-i386/kvm.c +1 -1
@@ -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;
Signature · 1 line
1.7.1.1
On Thu, 2010-11-25 at 09:19 +0800, Jin Dongming wrote:
[...]
Quoted 5 lines
hmp-commands.hx +0
-0@@ -1053,9 +1053,15 @@ ETEXI {
hmp-commands.hx ETEXI · line 1064
Quoted 10 lines
hmp-commands.hx +6
-0.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
Hi, Huang-san
Quoted 7 lines · Huang Ying
On Thu, 2010-11-25 at 09:19 +0800, Jin Dongming wrote:
[...]Quoted 4 lines
hmp-commands.hx +0
-0@@ -1053,9 +1053,15 @@ ETEXI
Quoted 13 lines
hmp-commands.hx ETEXI · line 1064
Quoted 11 lines
hmp-commands.hx +6
-0{ .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", +#endifBroadcast 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
Quoted 9 lines
[...]
Best Regards,
Huang Ying