xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/mce: assorted fixes
@ 2010-06-15 12:11 Jan Beulich
  0 siblings, 0 replies; only message in thread
From: Jan Beulich @ 2010-06-15 12:11 UTC (permalink / raw)
  To: xen-devel

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

- correct various range checks (avoids bogus warnings on domains
  modifying virtualized MSRs)
- correct consistency check (so that APs get checked instead of the
  BP [against uninitialized data])
- reduce verbosity (capabilities printed only once, but then all of
  the relevant values)

Signed-off-by: Jan Beulich <jbeulich@novell.com>

--- 2010-06-15.orig/xen/arch/x86/cpu/mcheck/mce.h	2010-06-14 08:49:36.000000000 +0200
+++ 2010-06-15/xen/arch/x86/cpu/mcheck/mce.h	2010-06-15 12:06:59.000000000 +0200
@@ -173,15 +173,14 @@ extern unsigned int nr_mce_banks;
 static inline int mce_vendor_bank_msr(uint32_t msr)
 {
     if ( boot_cpu_data.x86_vendor == X86_VENDOR_INTEL &&
-        (msr > MSR_IA32_MC0_CTL2 && msr < (MSR_IA32_MC0_CTL2 + nr_mce_banks)) )
+         msr >= MSR_IA32_MC0_CTL2 && msr < (MSR_IA32_MC0_CTL2 + nr_mce_banks) )
           return 1;
     return 0;
 }
 
 static inline int mce_bank_msr(uint32_t msr)
 {
-    if ( (msr > MSR_IA32_MC0_CTL2 &&
-         msr < (MSR_IA32_MCx_CTL(nr_mce_banks - 1))) ||
+    if ( (msr >= MSR_IA32_MC0_CTL && msr < MSR_IA32_MCx_CTL(nr_mce_banks)) ||
         mce_vendor_bank_msr(msr) )
         return 1;
     return 0;
--- 2010-06-15.orig/xen/arch/x86/cpu/mcheck/mce_intel.c	2010-06-14 08:49:36.000000000 +0200
+++ 2010-06-15/xen/arch/x86/cpu/mcheck/mce_intel.c	2010-06-15 12:08:53.000000000 +0200
@@ -1145,26 +1145,26 @@ static void intel_init_mca(struct cpuinf
 
     first = mce_firstbank(c);
 
-    dprintk(XENLOG_INFO, "MCA Capaility: CPU %x SER %x"
-       "CMCI %x firstbank %x extended MCE MSR %x\n",
-       smp_processor_id(), ser, cmci, first, ext_num);
-
-    if (smp_processor_id())
+    if (smp_processor_id() == 0)
     {
+        dprintk(XENLOG_INFO, "MCA Capability: BCAST %x SER %x"
+                " CMCI %x firstbank %x extended MCE MSR %x\n",
+                broadcast, ser, cmci, first, ext_num);
+
         mce_broadcast = broadcast;
         cmci_support = cmci;
         ser_support = ser;
         nr_intel_ext_msrs = ext_num;
         firstbank = first;
     }
-    else
-    {
-        if (cmci != cmci_support || ser != ser_support ||
-            broadcast != mce_broadcast ||
-            first != firstbank)
-            dprintk(XENLOG_WARNING,
-              "CPU %x has different MCA capability with BSP\n"
-              "may cause undetermined result!!!\n", smp_processor_id());
+    else if (cmci != cmci_support || ser != ser_support ||
+             broadcast != mce_broadcast ||
+             first != firstbank || ext_num != nr_intel_ext_msrs)
+    {
+        dprintk(XENLOG_WARNING,
+                "CPU %u has different MCA capability (%x,%x,%x,%x,%x)"
+                " than BSP, may cause undetermined result!!!\n",
+                smp_processor_id(), broadcast, ser, cmci, first, ext_num);
     }
 }
 
@@ -1264,8 +1264,7 @@ int intel_mce_wrmsr(uint32_t msr, uint64
 {
     int ret = 0;
 
-    if (msr > MSR_IA32_MC0_CTL2 &&
-        msr < (MSR_IA32_MC0_CTL2 + nr_mce_banks - 1))
+    if (msr >= MSR_IA32_MC0_CTL2 && msr < (MSR_IA32_MC0_CTL2 + nr_mce_banks))
     {
         mce_printk(MCE_QUIET, "We have disabled CMCI capability, "
                  "Guest should not write this MSR!\n");
@@ -1279,8 +1278,7 @@ int intel_mce_rdmsr(uint32_t msr, uint64
 {
     int ret = 0;
 
-    if (msr > MSR_IA32_MC0_CTL2 &&
-        msr < (MSR_IA32_MC0_CTL2 + nr_mce_banks - 1))
+    if (msr >= MSR_IA32_MC0_CTL2 && msr < (MSR_IA32_MC0_CTL2 + nr_mce_banks))
     {
         mce_printk(MCE_QUIET, "We have disabled CMCI capability, "
                  "Guest should not read this MSR!\n");




[-- Attachment #2: x86-mce-intel.patch --]
[-- Type: text/plain, Size: 3673 bytes --]

- correct various range checks (avoids bogus warnings on domains
  modifying virtualized MSRs)
- correct consistency check (so that APs get checked instead of the
  BP [against uninitialized data])
- reduce verbosity (capabilities printed only once, but then all of
  the relevant values)

Signed-off-by: Jan Beulich <jbeulich@novell.com>

--- 2010-06-15.orig/xen/arch/x86/cpu/mcheck/mce.h	2010-06-14 08:49:36.000000000 +0200
+++ 2010-06-15/xen/arch/x86/cpu/mcheck/mce.h	2010-06-15 12:06:59.000000000 +0200
@@ -173,15 +173,14 @@ extern unsigned int nr_mce_banks;
 static inline int mce_vendor_bank_msr(uint32_t msr)
 {
     if ( boot_cpu_data.x86_vendor == X86_VENDOR_INTEL &&
-        (msr > MSR_IA32_MC0_CTL2 && msr < (MSR_IA32_MC0_CTL2 + nr_mce_banks)) )
+         msr >= MSR_IA32_MC0_CTL2 && msr < (MSR_IA32_MC0_CTL2 + nr_mce_banks) )
           return 1;
     return 0;
 }
 
 static inline int mce_bank_msr(uint32_t msr)
 {
-    if ( (msr > MSR_IA32_MC0_CTL2 &&
-         msr < (MSR_IA32_MCx_CTL(nr_mce_banks - 1))) ||
+    if ( (msr >= MSR_IA32_MC0_CTL && msr < MSR_IA32_MCx_CTL(nr_mce_banks)) ||
         mce_vendor_bank_msr(msr) )
         return 1;
     return 0;
--- 2010-06-15.orig/xen/arch/x86/cpu/mcheck/mce_intel.c	2010-06-14 08:49:36.000000000 +0200
+++ 2010-06-15/xen/arch/x86/cpu/mcheck/mce_intel.c	2010-06-15 12:08:53.000000000 +0200
@@ -1145,26 +1145,26 @@ static void intel_init_mca(struct cpuinf
 
     first = mce_firstbank(c);
 
-    dprintk(XENLOG_INFO, "MCA Capaility: CPU %x SER %x"
-       "CMCI %x firstbank %x extended MCE MSR %x\n",
-       smp_processor_id(), ser, cmci, first, ext_num);
-
-    if (smp_processor_id())
+    if (smp_processor_id() == 0)
     {
+        dprintk(XENLOG_INFO, "MCA Capability: BCAST %x SER %x"
+                " CMCI %x firstbank %x extended MCE MSR %x\n",
+                broadcast, ser, cmci, first, ext_num);
+
         mce_broadcast = broadcast;
         cmci_support = cmci;
         ser_support = ser;
         nr_intel_ext_msrs = ext_num;
         firstbank = first;
     }
-    else
-    {
-        if (cmci != cmci_support || ser != ser_support ||
-            broadcast != mce_broadcast ||
-            first != firstbank)
-            dprintk(XENLOG_WARNING,
-              "CPU %x has different MCA capability with BSP\n"
-              "may cause undetermined result!!!\n", smp_processor_id());
+    else if (cmci != cmci_support || ser != ser_support ||
+             broadcast != mce_broadcast ||
+             first != firstbank || ext_num != nr_intel_ext_msrs)
+    {
+        dprintk(XENLOG_WARNING,
+                "CPU %u has different MCA capability (%x,%x,%x,%x,%x)"
+                " than BSP, may cause undetermined result!!!\n",
+                smp_processor_id(), broadcast, ser, cmci, first, ext_num);
     }
 }
 
@@ -1264,8 +1264,7 @@ int intel_mce_wrmsr(uint32_t msr, uint64
 {
     int ret = 0;
 
-    if (msr > MSR_IA32_MC0_CTL2 &&
-        msr < (MSR_IA32_MC0_CTL2 + nr_mce_banks - 1))
+    if (msr >= MSR_IA32_MC0_CTL2 && msr < (MSR_IA32_MC0_CTL2 + nr_mce_banks))
     {
         mce_printk(MCE_QUIET, "We have disabled CMCI capability, "
                  "Guest should not write this MSR!\n");
@@ -1279,8 +1278,7 @@ int intel_mce_rdmsr(uint32_t msr, uint64
 {
     int ret = 0;
 
-    if (msr > MSR_IA32_MC0_CTL2 &&
-        msr < (MSR_IA32_MC0_CTL2 + nr_mce_banks - 1))
+    if (msr >= MSR_IA32_MC0_CTL2 && msr < (MSR_IA32_MC0_CTL2 + nr_mce_banks))
     {
         mce_printk(MCE_QUIET, "We have disabled CMCI capability, "
                  "Guest should not read this MSR!\n");

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-06-15 12:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-15 12:11 [PATCH] x86/mce: assorted fixes Jan Beulich

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).