qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: kvm@vger.kernel.org, qemu-devel@nongnu.org
Cc: Dean Nelson <dnelson@redhat.com>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	Huang Ying <ying.huang@intel.com>
Subject: [Qemu-devel] [patch 8/8] Add savevm/loadvm support for MCE
Date: Mon, 11 Oct 2010 15:31:22 -0300	[thread overview]
Message-ID: <20101011183227.115249070@redhat.com> (raw)
In-Reply-To: 20101011183114.455477545@redhat.com

[-- Attachment #1: mce-save-restore --]
[-- Type: text/plain, Size: 2911 bytes --]

Port qemu-kvm's

commit 1bab5d11545d8de5facf46c28630085a2f9651ae
Author: Huang Ying <ying.huang@intel.com>
Date:   Wed Mar 3 16:52:46 2010 +0800

    Add savevm/loadvm support for MCE
    
    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.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

Index: qemu/target-i386/kvm.c
===================================================================
--- qemu.orig/target-i386/kvm.c
+++ qemu/target-i386/kvm.c
@@ -774,7 +774,7 @@ static int kvm_put_msrs(CPUState *env, i
         struct kvm_msr_entry entries[100];
     } msr_data;
     struct kvm_msr_entry *msrs = msr_data.entries;
-    int n = 0;
+    int i, n = 0;
 
     kvm_msr_entry_set(&msrs[n++], MSR_IA32_SYSENTER_CS, env->sysenter_cs);
     kvm_msr_entry_set(&msrs[n++], MSR_IA32_SYSENTER_ESP, env->sysenter_esp);
@@ -794,6 +794,18 @@ static int kvm_put_msrs(CPUState *env, i
                           env->system_time_msr);
         kvm_msr_entry_set(&msrs[n++], MSR_KVM_WALL_CLOCK, env->wall_clock_msr);
     }
+#ifdef KVM_CAP_MCE
+    if (env->mcg_cap) {
+        if (level == KVM_PUT_RESET_STATE)
+            kvm_msr_entry_set(&msrs[n++], MSR_MCG_STATUS, env->mcg_status);
+        else if (level == KVM_PUT_FULL_STATE) {
+            kvm_msr_entry_set(&msrs[n++], MSR_MCG_STATUS, env->mcg_status);
+            kvm_msr_entry_set(&msrs[n++], MSR_MCG_CTL, env->mcg_ctl);
+            for (i = 0; i < (env->mcg_cap & 0xff) * 4; i++)
+                kvm_msr_entry_set(&msrs[n++], MSR_MC0_CTL + i, env->mce_banks[i]);
+        }
+    }
+#endif
 
     msr_data.info.nmsrs = n;
 
@@ -1001,6 +1013,15 @@ static int kvm_get_msrs(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
+
     msr_data.info.nmsrs = n;
     ret = kvm_vcpu_ioctl(env, KVM_GET_MSRS, &msr_data);
     if (ret < 0)
@@ -1043,6 +1064,22 @@ static int kvm_get_msrs(CPUState *env)
         case MSR_KVM_WALL_CLOCK:
             env->wall_clock_msr = msrs[i].data;
             break;
+#ifdef KVM_CAP_MCE
+        case MSR_MCG_STATUS:
+            env->mcg_status = msrs[i].data;
+            break;
+        case MSR_MCG_CTL:
+            env->mcg_ctl = msrs[i].data;
+            break;
+#endif
+        default:
+#ifdef KVM_CAP_MCE
+            if (msrs[i].index >= MSR_MC0_CTL &&
+                msrs[i].index < MSR_MC0_CTL + (env->mcg_cap & 0xff) * 4) {
+                env->mce_banks[msrs[i].index - MSR_MC0_CTL] = msrs[i].data;
+                break;
+            }
+#endif
         }
     }
 

  parent reply	other threads:[~2010-10-11 18:38 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-04 18:54 [Qemu-devel] [patch uq/master 0/8] port qemu-kvm's MCE support Marcelo Tosatti
2010-10-04 18:54 ` [Qemu-devel] [patch uq/master 1/8] signalfd compatibility Marcelo Tosatti
2010-10-04 18:54 ` [Qemu-devel] [patch uq/master 2/8] iothread: use signalfd Marcelo Tosatti
2010-10-04 18:54 ` [Qemu-devel] [patch uq/master 3/8] Expose thread_id in info cpus Marcelo Tosatti
2010-10-04 18:54 ` [Qemu-devel] [patch uq/master 4/8] kvm: x86: add mce support Marcelo Tosatti
2010-10-04 18:54 ` [Qemu-devel] [patch uq/master 5/8] Export qemu_ram_addr_from_host Marcelo Tosatti
2010-10-05 12:57   ` [Qemu-devel] " Anthony Liguori
2010-10-05 20:13     ` Marcelo Tosatti
2010-10-05 20:48       ` Anthony Liguori
2010-10-04 18:54 ` [Qemu-devel] [patch uq/master 6/8] Add RAM -> physical addr mapping in MCE simulation Marcelo Tosatti
2010-10-04 18:54 ` [Qemu-devel] [patch uq/master 7/8] MCE: Relay UCR MCE to guest Marcelo Tosatti
2010-10-06  1:10   ` [Qemu-devel] " Hidetoshi Seto
2010-10-06 16:02     ` Marcelo Tosatti
2010-10-06  1:58   ` Hidetoshi Seto
2010-10-06 16:05     ` Marcelo Tosatti
2010-10-06 18:10       ` Dean Nelson
2010-10-07  3:41         ` Hidetoshi Seto
2010-10-07 15:23           ` Dean Nelson
2010-10-08  3:15           ` Huang Ying
2010-10-08  5:54             ` Hidetoshi Seto
2010-10-08 12:02             ` Dean Nelson
2010-10-08  2:50       ` Huang Ying
2010-10-04 18:54 ` [Qemu-devel] [patch uq/master 8/8] Add savevm/loadvm support for MCE Marcelo Tosatti
2010-10-05 16:31 ` [Qemu-devel] [patch uq/master 0/8] port qemu-kvm's MCE support Andreas Färber
2010-10-05 18:58   ` Chris Wright
2010-10-05 20:24     ` Marcelo Tosatti
2010-10-06 17:34 ` [Qemu-devel] [patch uq/master 0/8] port qemu-kvm's MCE support (v2) Marcelo Tosatti
2010-10-06 17:34   ` [Qemu-devel] [patch uq/master 1/8] signalfd compatibility Marcelo Tosatti
2010-10-06 17:34   ` [Qemu-devel] [patch uq/master 2/8] iothread: use signalfd Marcelo Tosatti
2010-10-06 17:34   ` [Qemu-devel] [patch uq/master 3/8] Expose thread_id in info cpus Marcelo Tosatti
2010-10-06 17:34   ` [Qemu-devel] [patch uq/master 4/8] kvm: x86: add mce support Marcelo Tosatti
2010-10-06 19:32     ` [Qemu-devel] " Anthony Liguori
2010-10-06 17:34   ` [Qemu-devel] [patch uq/master 5/8] Export qemu_ram_addr_from_host Marcelo Tosatti
2010-10-06 17:34   ` [Qemu-devel] [patch uq/master 6/8] Add RAM -> physical addr mapping in MCE simulation Marcelo Tosatti
2010-10-06 17:34   ` [Qemu-devel] [patch uq/master 7/8] MCE: Relay UCR MCE to guest Marcelo Tosatti
2010-10-06 17:34   ` [Qemu-devel] [patch uq/master 8/8] Add savevm/loadvm support for MCE Marcelo Tosatti
2010-10-11 18:31   ` [Qemu-devel] [patch 0/8] port qemu-kvm's MCE support (v3) Marcelo Tosatti
2010-10-11 18:31     ` [Qemu-devel] [patch 1/8] signalfd compatibility Marcelo Tosatti
2010-10-11 18:31     ` [Qemu-devel] [patch 2/8] iothread: use signalfd Marcelo Tosatti
2010-10-11 18:31     ` [Qemu-devel] [patch 3/8] Expose thread_id in info cpus Marcelo Tosatti
2010-10-11 18:31     ` [Qemu-devel] [patch 4/8] kvm: x86: add mce support Marcelo Tosatti
2010-10-11 18:31     ` [Qemu-devel] [patch 5/8] Export qemu_ram_addr_from_host Marcelo Tosatti
2010-10-11 18:31     ` [Qemu-devel] [patch 6/8] Add RAM -> physical addr mapping in MCE simulation Marcelo Tosatti
2010-10-11 18:31     ` [Qemu-devel] [patch 7/8] MCE: Relay UCR MCE to guest Marcelo Tosatti
2010-10-11 18:31     ` Marcelo Tosatti [this message]
2010-10-14 10:25     ` [Qemu-devel] Re: [patch 0/8] port qemu-kvm's MCE support (v3) Avi Kivity
2010-10-14 16:21       ` Marcelo Tosatti
2010-10-17  9:32     ` [Qemu-devel] Re: [patch 0/8] port qemu-kvm's MCE support (v3 resend) Avi Kivity

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=20101011183227.115249070@redhat.com \
    --to=mtosatti@redhat.com \
    --cc=dnelson@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).