From: Jin Dongming <jin.dongming@np.css.fujitsu.com>
To: Avi Kivity <avi@redhat.com>, Marcelo Tosatti <mtosatti@redhat.com>
Cc: Andi Kleen <andi@firstfloor.org>,
Huang Ying <ying.huang@intel.com>,
Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>,
KVM list <kvm@vger.kernel.org>
Subject: [PATCH] Add function for clearing the requested VCPUs' mce registers.
Date: Thu, 25 Nov 2010 10:14:20 +0900 [thread overview]
Message-ID: <4CEDB86C.2050402@np.css.fujitsu.com> (raw)
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
next reply other threads:[~2010-11-25 1:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-25 1:14 Jin Dongming [this message]
2010-11-25 1:27 ` [PATCH] Add function for clearing the requested VCPUs' mce registers Huang Ying
2010-11-25 5:30 ` Jin Dongming
2010-11-25 5:44 ` Huang Ying
2010-11-25 8:43 ` Jin Dongming
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=4CEDB86C.2050402@np.css.fujitsu.com \
--to=jin.dongming@np.css.fujitsu.com \
--cc=andi@firstfloor.org \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=seto.hidetoshi@jp.fujitsu.com \
--cc=ying.huang@intel.com \
/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