Re: [PATCH -v3] Add savevm/loadvm support for MCE

Jan Kiszka
2010-03-03T23:13:05Z

[-- Attachment #1: Type: text/plain, Size: 2890 bytes --]

Huang Ying wrote:
> 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.

Looks good!

>
> v2:
>
> - Rebased on new CPU registers save/load framework.
>
> Signed-off-by: Huang Ying <ying.huang@intel.com>

Acked-by: Jan Kiszka <jan.kiszka@siemens.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");
>
>

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]