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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>

Acked-by: Jan Kiszka <jan.kiszka@xxxxxxxxxxx>

> ---
>  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: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux