public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@web.de>
To: Huang Ying <ying.huang@intel.com>
Cc: Avi Kivity <avi@redhat.com>,
	Anthony Liguori <anthony@codemonkey.ws>,
	Andi Kleen <andi@firstfloor.org>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>
Subject: Re: [PATCH -v3] Add savevm/loadvm support for MCE
Date: Thu, 04 Mar 2010 00:12:53 +0100	[thread overview]
Message-ID: <4B8EECF5.8000808@web.de> (raw)
In-Reply-To: <1267606366.1640.208.camel@yhuang-dev.sh.intel.com>

[-- 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 --]

  reply	other threads:[~2010-03-03 23:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-03  8:52 [PATCH -v3] Add savevm/loadvm support for MCE Huang Ying
2010-03-03 23:12 ` Jan Kiszka [this message]
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=4B8EECF5.8000808@web.de \
    --to=jan.kiszka@web.de \
    --cc=andi@firstfloor.org \
    --cc=anthony@codemonkey.ws \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --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