[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] Re: [PATCH 04/35] Add "broadcast" option for mce command
From: |
Jan Kiszka |
Subject: |
[Qemu-devel] Re: [PATCH 04/35] Add "broadcast" option for mce command |
Date: |
Sat, 15 Jan 2011 17:24:56 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 |
Am 09.01.2011 19:51, Jan Kiszka wrote:
> Am 06.01.2011 18:56, Marcelo Tosatti wrote:
>> From: Jin Dongming <address@hidden>
>>
>> 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 <address@hidden>
>> Signed-off-by: Marcelo Tosatti <address@hidden>
>> ---
>> 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.
Actually, the right fix is MCI_STATUS_VAL | MCI_STATUS_UC instead of the
magic number.
Still, there is an inconsistency: kvm_mce_broadcast_rest injects
mcg_state = MCG_STATUS_MCIP | MCG_STATUS_RIPV, the above code sets it to
0. I presume the KVM code is correct, isn't it?
This demonstrates one problem of the MCE code base: It contains too much
redundancy between TCG and KVM paths. And as the KVM part is also not
yet well integrated with VCPU state writeback, e.g. VCPU events, we have
some races over there. The good news is that we can drop half of the KVM
MCE bits when reusing qemu_inject_x86_mce for setting up the event
injection.
How to proceed? Fix up those nits, merge the patches, and then rework
MCE on top (I started like this already)? Or rather do the rework on top
of current qemu?
I'm willing to drive this, but I would also welcome if we could
distribute the effort.
Jan
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] Re: [PATCH 14/35] kvm: Drop return value of kvm_cpu_exec, (continued)
- [Qemu-devel] [PATCH 03/35] Clean up cpu_inject_x86_mce(), Marcelo Tosatti, 2011/01/06
- [Qemu-devel] [PATCH 17/35] x86: Optionally dump code bytes on cpu_dump_state, Marcelo Tosatti, 2011/01/06
- [Qemu-devel] [PATCH 33/35] kvm: Do not use qemu_fair_mutex, Marcelo Tosatti, 2011/01/06
- [Qemu-devel] [PATCH 15/35] kvm: Stop on all fatal exit reasons, Marcelo Tosatti, 2011/01/06
- [Qemu-devel] [PATCH 16/35] kvm: Improve reporting of fatal errors, Marcelo Tosatti, 2011/01/06
- [Qemu-devel] [PATCH 05/35] Add function for checking mca broadcast of CPU, Marcelo Tosatti, 2011/01/06
- [Qemu-devel] [PATCH 07/35] kvm: kvm_mce_inj_* subroutines for templated error injections, Marcelo Tosatti, 2011/01/06
- [Qemu-devel] [PATCH 04/35] Add "broadcast" option for mce command, Marcelo Tosatti, 2011/01/06
- [Qemu-devel] [PATCH 18/35] kvm: x86: Align kvm_arch_put_registers code with comment, Marcelo Tosatti, 2011/01/06
- [Qemu-devel] [PATCH 06/35] kvm: introduce kvm_mce_in_progress, Marcelo Tosatti, 2011/01/06
- [Qemu-devel] [PATCH 21/35] kvm: x86: Fix xcr0 reset mismerge, Marcelo Tosatti, 2011/01/06
- [Qemu-devel] [PATCH 31/35] kvm: x86: Rework identity map and TSS setup for larger BIOS sizes, Marcelo Tosatti, 2011/01/06
- [Qemu-devel] [PATCH 28/35] kvm: x86: Introduce kvmclock device to save/restore its state, Marcelo Tosatti, 2011/01/06