WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] mce: Enhance the vmce injection check log

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] mce: Enhance the vmce injection check logic
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 16 Jun 2010 00:15:13 -0700
Delivery-date: Wed, 16 Jun 2010 00:15:35 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1276598053 -3600
# Node ID fec9666c216b04bcd3daaa9ed82eeb28270304d4
# Parent  06c384172152e52df06ede4c517fa5d59b5837ad
mce: Enhance the vmce injection check logic

Currently we will not inject vMCE if guest has different mca control
register setup.

This is not enough, we need consider more. If guest has different
family/model, we should not inject guest, because the MCA error code
include model specific information. If guest has not enabled MCE
(i.e. CR4.X86_CR4_MCE is clear), we should not inject vMCE.

One thing need notice. In the memory error handler, we didn't kill the
guest if vMCE is not ready, instead, we will simply ignore the
vMCE. In native, system will reboot if MCE in CR4 is not enabled. We
need contain guest access to the broken memory through eithe software
or hardware method.

Signed-off-by: Jiang, Yunhong <yunhong.jiang@xxxxxxxxx>
---
 xen/arch/x86/cpu/mcheck/mce.h       |    3 -
 xen/arch/x86/cpu/mcheck/mce_intel.c |    4 -
 xen/arch/x86/cpu/mcheck/vmce.c      |   78 +++++++++++++++++++++++++++++++++++-
 3 files changed, 81 insertions(+), 4 deletions(-)

diff -r 06c384172152 -r fec9666c216b xen/arch/x86/cpu/mcheck/mce.h
--- a/xen/arch/x86/cpu/mcheck/mce.h     Fri Jun 11 17:47:49 2010 +0100
+++ b/xen/arch/x86/cpu/mcheck/mce.h     Tue Jun 15 11:34:13 2010 +0100
@@ -48,9 +48,10 @@ void mce_intel_feature_init(struct cpuin
 void mce_intel_feature_init(struct cpuinfo_x86 *c);
 void amd_nonfatal_mcheck_init(struct cpuinfo_x86 *c);
 
+int is_vmce_ready(struct mcinfo_bank *bank, struct domain *d);
+
 u64 mce_cap_init(void);
 extern int firstbank;
-int mca_ctl_conflict(struct mcinfo_bank *bank, struct domain *d);
 
 int intel_mce_rdmsr(uint32_t msr, uint64_t *val);
 int intel_mce_wrmsr(uint32_t msr, uint64_t val);
diff -r 06c384172152 -r fec9666c216b xen/arch/x86/cpu/mcheck/mce_intel.c
--- a/xen/arch/x86/cpu/mcheck/mce_intel.c       Fri Jun 11 17:47:49 2010 +0100
+++ b/xen/arch/x86/cpu/mcheck/mce_intel.c       Tue Jun 15 11:34:13 2010 +0100
@@ -654,9 +654,9 @@ static void intel_memerr_dhandler(int bn
             BUG_ON( result->owner == DOMID_COW );
             if ( result->owner != DOMID_XEN ) {
                 d = get_domain_by_id(result->owner);
-                if ( mca_ctl_conflict(bank, d) )
+                if ( !is_vmce_ready(bank, d) )
                 {
-                    /* Guest has different MCE ctl with hypervisor */
+                    /* Should not inject vMCE to guest */
                     if ( d )
                         put_domain(d);
                     return;
diff -r 06c384172152 -r fec9666c216b xen/arch/x86/cpu/mcheck/vmce.c
--- a/xen/arch/x86/cpu/mcheck/vmce.c    Fri Jun 11 17:47:49 2010 +0100
+++ b/xen/arch/x86/cpu/mcheck/vmce.c    Tue Jun 15 11:34:13 2010 +0100
@@ -468,7 +468,7 @@ int vmce_init(struct cpuinfo_x86 *c)
     return 0;
 }
 
-int mca_ctl_conflict(struct mcinfo_bank *bank, struct domain *d)
+static int mca_ctl_conflict(struct mcinfo_bank *bank, struct domain *d)
 {
     int bank_nr;
 
@@ -484,3 +484,79 @@ int mca_ctl_conflict(struct mcinfo_bank 
         return 1;
     return 0;
 }
+
+static int is_hvm_vmce_ready(struct mcinfo_bank *bank, struct domain *d)
+{
+    struct vcpu *v;
+    int no_vmce = 0, i;
+
+    if (!is_hvm_domain(d))
+        return 0;
+
+    /* kill guest if not enabled vMCE */
+    for_each_vcpu(d, v)
+    {
+        if (!(v->arch.hvm_vcpu.guest_cr[4] & X86_CR4_MCE))
+        {
+            no_vmce = 1;
+            break;
+        }
+
+        if (!mce_broadcast)
+            break;
+    }
+
+    if (no_vmce)
+        return 0;
+
+    /* Guest has virtualized family/model information */
+    for ( i = 0; i < MAX_CPUID_INPUT; i++ )
+    {
+        if (d->arch.cpuids[i].input[0] == 0x1)
+        {
+            uint32_t veax = d->arch.cpuids[i].eax, vfam, vmod;
+
+                       vfam = (veax >> 8) & 15;
+                       vmod = (veax >> 4) & 15;
+
+            if (vfam == 0x6 || vfam == 0xf)
+                vmod += ((veax >> 16) & 0xF) << 4;
+                       if (vfam == 0xf)
+                               vfam += (veax >> 20) & 0xff;
+
+            if ( ( vfam != boot_cpu_data.x86 ) ||
+                 (vmod != boot_cpu_data.x86_model) )
+            {
+                dprintk(XENLOG_WARNING,
+                    "No vmce for different virtual family/model cpuid\n");
+                no_vmce = 1;
+            }
+            break;
+        }
+    }
+
+    if (no_vmce)
+        return 0;
+
+    /* Guest has different MCE ctl value setting */
+    if (mca_ctl_conflict(bank, d))
+    {
+        dprintk(XENLOG_WARNING,
+          "No vmce, guest has different mca control setting\n");
+        return 0;
+    }
+
+    return 1;
+}
+
+int is_vmce_ready(struct mcinfo_bank *bank, struct domain *d)
+{
+    if ( d == dom0)
+        return dom0_vmce_enabled();
+
+    /* No vMCE to HVM guest now */
+    if ( is_hvm_domain(d) )
+        return is_hvm_vmce_ready(bank, d);
+
+    return 0;
+}

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] mce: Enhance the vmce injection check logic, Xen patchbot-unstable <=