From: Huang Ying <ying.huang@intel.com>
To: Avi Kivity <avi@redhat.com>,
Anthony Liguori <anthony@codemonkey.ws>,
Jan Kiszka <jan.kiszka@siemens.com>
Cc: Andi Kleen <andi@firstfloor.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>
Subject: [PATCH -v3] Add savevm/loadvm support for MCE
Date: Wed, 03 Mar 2010 16:52:46 +0800 [thread overview]
Message-ID: <1267606366.1640.208.camel@yhuang-dev.sh.intel.com> (raw)
MCE registers are saved/load into/from CPUState in
kvm_arch_save/load_regs. To simulate the MCG_STATUS clearing upon
reset, MSR_MCG_STATUS is set to 0 for KVM_PUT_RESET_STATE.
v3:
- use msrs[] in kvm_arch_load/save_regs and get_msr_entry directly.
v2:
- Rebased on new CPU registers save/load framework.
Signed-off-by: Huang Ying <ying.huang@intel.com>
---
qemu-kvm-x86.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
--- a/qemu-kvm-x86.c
+++ b/qemu-kvm-x86.c
@@ -748,7 +748,22 @@ static int get_msr_entry(struct kvm_msr_
case MSR_KVM_WALL_CLOCK:
env->wall_clock_msr = entry->data;
break;
+#ifdef KVM_CAP_MCE
+ case MSR_MCG_STATUS:
+ env->mcg_status = entry->data;
+ break;
+ case MSR_MCG_CTL:
+ env->mcg_ctl = entry->data;
+ break;
+#endif
default:
+#ifdef KVM_CAP_MCE
+ if (entry->index >= MSR_MC0_CTL && \
+ entry->index < MSR_MC0_CTL + (env->mcg_cap & 0xff) * 4) {
+ env->mce_banks[entry->index - MSR_MC0_CTL] = entry->data;
+ break;
+ }
+#endif
printf("Warning unknown msr index 0x%x\n", entry->index);
return 1;
}
@@ -979,6 +994,18 @@ void kvm_arch_load_regs(CPUState *env, i
set_msr_entry(&msrs[n++], MSR_KVM_SYSTEM_TIME, env->system_time_msr);
set_msr_entry(&msrs[n++], MSR_KVM_WALL_CLOCK, env->wall_clock_msr);
}
+#ifdef KVM_CAP_MCE
+ if (env->mcg_cap) {
+ if (level == KVM_PUT_RESET_STATE)
+ set_msr_entry(&msrs[n++], MSR_MCG_STATUS, env->mcg_status);
+ else if (level == KVM_PUT_FULL_STATE) {
+ set_msr_entry(&msrs[n++], MSR_MCG_STATUS, env->mcg_status);
+ set_msr_entry(&msrs[n++], MSR_MCG_CTL, env->mcg_ctl);
+ for (i = 0; i < (env->mcg_cap & 0xff); i++)
+ set_msr_entry(&msrs[n++], MSR_MC0_CTL + i, env->mce_banks[i]);
+ }
+ }
+#endif
rc = kvm_set_msrs(env, msrs, n);
if (rc == -1)
@@ -1144,6 +1171,15 @@ void kvm_arch_save_regs(CPUState *env)
msrs[n++].index = MSR_KVM_SYSTEM_TIME;
msrs[n++].index = MSR_KVM_WALL_CLOCK;
+#ifdef KVM_CAP_MCE
+ if (env->mcg_cap) {
+ msrs[n++].index = MSR_MCG_STATUS;
+ msrs[n++].index = MSR_MCG_CTL;
+ for (i = 0; i < (env->mcg_cap & 0xff) * 4; i++)
+ msrs[n++].index = MSR_MC0_CTL + i;
+ }
+#endif
+
rc = kvm_get_msrs(env, msrs, n);
if (rc == -1) {
perror("kvm_get_msrs FAILED");
next reply other threads:[~2010-03-03 8:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-03 8:52 Huang Ying [this message]
2010-03-03 23:12 ` [PATCH -v3] Add savevm/loadvm support for MCE Jan Kiszka
2010-03-04 11:36 ` Marcelo Tosatti
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=1267606366.1640.208.camel@yhuang-dev.sh.intel.com \
--to=ying.huang@intel.com \
--cc=andi@firstfloor.org \
--cc=anthony@codemonkey.ws \
--cc=avi@redhat.com \
--cc=jan.kiszka@siemens.com \
--cc=kvm@vger.kernel.org \
/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