* [PATCH] Add function for clearing the requested VCPUs' mce registers.
@ 2010-11-25 1:14 Jin Dongming
2010-11-25 1:27 ` Huang Ying
0 siblings, 1 reply; 5+ messages in thread
From: Jin Dongming @ 2010-11-25 1:14 UTC (permalink / raw)
To: Avi Kivity, Marcelo Tosatti
Cc: Andi Kleen, Huang Ying, Hidetoshi Seto, KVM list
In some case of mce test, the injected data can be remained
in the registers and ca affect to the result of following test cases.
So add codes for clearing mce registers of given VCPU.
mce registers of give VCPU could be cleared from kernel by calling
the function in this patch. What need to be paid attention is that
the status and mcg_status of mce must be set with 0. If not, mce
registers will not be cleared.
Signed-off-by: Jin Dongming <jin.dongming@np.css.fujitsu.com>
---
arch/x86/kvm/x86.c | 28 +++++++++++++++++++++++++++-
1 files changed, 27 insertions(+), 1 deletions(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 3a09c62..9c2cdfc 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2246,6 +2246,25 @@ out:
return r;
}
+static void kvm_vcpu_x86_clear_mce(struct kvm_vcpu *vcpu,
+ struct kvm_x86_mce *mce)
+{
+ u64 *banks = vcpu->arch.mce_banks;
+ u64 mcg_cap = vcpu->arch.mcg_cap;
+
+ unsigned bank_num = mcg_cap & 0xff;
+ int i = 0;
+
+ for (i = 0; i < bank_num; i++) {
+ banks[1] = 0;
+ banks[2] = 0;
+ banks[3] = 0;
+ banks += 4;
+ }
+
+ vcpu->arch.mcg_status = 0;
+}
+
static int kvm_vcpu_ioctl_x86_set_mce(struct kvm_vcpu *vcpu,
struct kvm_x86_mce *mce)
{
@@ -2253,8 +2272,15 @@ static int kvm_vcpu_ioctl_x86_set_mce(struct kvm_vcpu *vcpu,
unsigned bank_num = mcg_cap & 0xff;
u64 *banks = vcpu->arch.mce_banks;
- if (mce->bank >= bank_num || !(mce->status & MCI_STATUS_VAL))
+ if (mce->bank >= bank_num)
return -EINVAL;
+ if (!(mce->status & MCI_STATUS_VAL)) {
+ if (!mce->status && !mce->mcg_status) {
+ kvm_vcpu_x86_clear_mce(vcpu, mce);
+ return 0;
+ }
+ return -EINVAL;
+ }
/*
* if IA32_MCG_CTL is not all 1s, the uncorrected error
* reporting is disabled
--
1.7.1.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Add function for clearing the requested VCPUs' mce registers.
2010-11-25 1:14 [PATCH] Add function for clearing the requested VCPUs' mce registers Jin Dongming
@ 2010-11-25 1:27 ` Huang Ying
2010-11-25 5:30 ` Jin Dongming
0 siblings, 1 reply; 5+ messages in thread
From: Huang Ying @ 2010-11-25 1:27 UTC (permalink / raw)
To: Jin Dongming
Cc: Avi Kivity, Marcelo Tosatti, Andi Kleen, Hidetoshi Seto, KVM list
Hi, Dongming,
On Thu, 2010-11-25 at 09:14 +0800, Jin Dongming wrote:
> In some case of mce test, the injected data can be remained
> in the registers and ca affect to the result of following test cases.
> So add codes for clearing mce registers of given VCPU.
>
> mce registers of give VCPU could be cleared from kernel by calling
> the function in this patch. What need to be paid attention is that
> the status and mcg_status of mce must be set with 0. If not, mce
> registers will not be cleared.
Why do you need this? To use "mce=3" in guest Linux MCE testing?
If it is, why not use full reboot? MCE registers are not cleared in real
machine too. And it is not so pain to reboot the guest.
Best Regards,
Huang Ying
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Add function for clearing the requested VCPUs' mce registers.
2010-11-25 1:27 ` Huang Ying
@ 2010-11-25 5:30 ` Jin Dongming
2010-11-25 5:44 ` Huang Ying
0 siblings, 1 reply; 5+ messages in thread
From: Jin Dongming @ 2010-11-25 5:30 UTC (permalink / raw)
To: Huang Ying
Cc: Avi Kivity, Marcelo Tosatti, Andi Kleen, Hidetoshi Seto, KVM list
Hi, Huang-san
(2010/11/25 10:27), Huang Ying wrote:
> Hi, Dongming,
>
> On Thu, 2010-11-25 at 09:14 +0800, Jin Dongming wrote:
>> In some case of mce test, the injected data can be remained
>> in the registers and ca affect to the result of following test cases.
>> So add codes for clearing mce registers of given VCPU.
>>
>> mce registers of give VCPU could be cleared from kernel by calling
>> the function in this patch. What need to be paid attention is that
>> the status and mcg_status of mce must be set with 0. If not, mce
>> registers will not be cleared.
>
> Why do you need this? To use "mce=3" in guest Linux MCE testing?
When I set fake_panic==1 on Guest OS and tested mce via qemu-monitor,
I got the wrong result sometimes. The reason why I got the wrong result
was that mce registers were not cleared. So I made this patch.
>
> If it is, why not use full reboot? MCE registers are not cleared in real
> machine too. And it is not so pain to reboot the guest.
Though we know that mce registers could be cleared by rebooting the Guest
Machine and the reboot of Guest Machine could save much more time than
the reboot of Host Machine, it is still slower than setting
fake_panic==1 to mce test.
Best Regards,
Jin Dongming
>
> Best Regards,
> Huang Ying
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Add function for clearing the requested VCPUs' mce registers.
2010-11-25 5:30 ` Jin Dongming
@ 2010-11-25 5:44 ` Huang Ying
2010-11-25 8:43 ` Jin Dongming
0 siblings, 1 reply; 5+ messages in thread
From: Huang Ying @ 2010-11-25 5:44 UTC (permalink / raw)
To: Jin Dongming
Cc: Avi Kivity, Marcelo Tosatti, Andi Kleen, Hidetoshi Seto, KVM list
On Thu, 2010-11-25 at 13:30 +0800, Jin Dongming wrote:
> Hi, Huang-san
>
> (2010/11/25 10:27), Huang Ying wrote:
> > Hi, Dongming,
> >
> > On Thu, 2010-11-25 at 09:14 +0800, Jin Dongming wrote:
> >> In some case of mce test, the injected data can be remained
> >> in the registers and ca affect to the result of following test cases.
> >> So add codes for clearing mce registers of given VCPU.
> >>
> >> mce registers of give VCPU could be cleared from kernel by calling
> >> the function in this patch. What need to be paid attention is that
> >> the status and mcg_status of mce must be set with 0. If not, mce
> >> registers will not be cleared.
> >
> > Why do you need this? To use "mce=3" in guest Linux MCE testing?
> When I set fake_panic==1 on Guest OS and tested mce via qemu-monitor,
> I got the wrong result sometimes. The reason why I got the wrong result
> was that mce registers were not cleared. So I made this patch.
This can be done in QEMU via KVM_SET_MSRS too.
> > If it is, why not use full reboot? MCE registers are not cleared in real
> > machine too. And it is not so pain to reboot the guest.
> Though we know that mce registers could be cleared by rebooting the Guest
> Machine and the reboot of Guest Machine could save much more time than
> the reboot of Host Machine, it is still slower than setting
> fake_panic==1 to mce test.
Best Regards,
Huang Ying
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Add function for clearing the requested VCPUs' mce registers.
2010-11-25 5:44 ` Huang Ying
@ 2010-11-25 8:43 ` Jin Dongming
0 siblings, 0 replies; 5+ messages in thread
From: Jin Dongming @ 2010-11-25 8:43 UTC (permalink / raw)
To: Huang Ying
Cc: Avi Kivity, Marcelo Tosatti, Andi Kleen, Hidetoshi Seto, KVM list
Hi, Huang-san
(2010/11/25 14:44), Huang Ying wrote:
> On Thu, 2010-11-25 at 13:30 +0800, Jin Dongming wrote:
>> Hi, Huang-san
>>
>> (2010/11/25 10:27), Huang Ying wrote:
>>> Hi, Dongming,
>>>
>>> On Thu, 2010-11-25 at 09:14 +0800, Jin Dongming wrote:
>>>> In some case of mce test, the injected data can be remained
>>>> in the registers and ca affect to the result of following test cases.
>>>> So add codes for clearing mce registers of given VCPU.
>>>>
>>>> mce registers of give VCPU could be cleared from kernel by calling
>>>> the function in this patch. What need to be paid attention is that
>>>> the status and mcg_status of mce must be set with 0. If not, mce
>>>> registers will not be cleared.
>>>
>>> Why do you need this? To use "mce=3" in guest Linux MCE testing?
>> When I set fake_panic==1 on Guest OS and tested mce via qemu-monitor,
>> I got the wrong result sometimes. The reason why I got the wrong result
>> was that mce registers were not cleared. So I made this patch.
>
> This can be done in QEMU via KVM_SET_MSRS too.
Yes, it could be done in Guest OS with APL. So I will cancel this patch.
Best Regards,
Jin Dongming
>
>>> If it is, why not use full reboot? MCE registers are not cleared in real
>>> machine too. And it is not so pain to reboot the guest.
>> Though we know that mce registers could be cleared by rebooting the Guest
>> Machine and the reboot of Guest Machine could save much more time than
>> the reboot of Host Machine, it is still slower than setting
>> fake_panic==1 to mce test.
>
> Best Regards,
> Huang Ying
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-11-25 8:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-25 1:14 [PATCH] Add function for clearing the requested VCPUs' mce registers Jin Dongming
2010-11-25 1:27 ` Huang Ying
2010-11-25 5:30 ` Jin Dongming
2010-11-25 5:44 ` Huang Ying
2010-11-25 8:43 ` Jin Dongming
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox