xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@novell.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] x86/mce: assorted fixes
Date: Tue, 15 Jun 2010 13:11:08 +0100	[thread overview]
Message-ID: <4C1789FC02000078000067C7@vpn.id2.novell.com> (raw)

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

                 reply	other threads:[~2010-06-15 12:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=4C1789FC02000078000067C7@vpn.id2.novell.com \
    --to=jbeulich@novell.com \
    --cc=xen-devel@lists.xensource.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).