]> xenbits.xensource.com Git - xen.git/commitdiff
x86 mce: Use MSR_IA32_MCx_* macros consistently
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 9 Jun 2010 13:38:30 +0000 (14:38 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 9 Jun 2010 13:38:30 +0000 (14:38 +0100)
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
xen/arch/x86/cpu/mcheck/amd_k8.c
xen/arch/x86/cpu/mcheck/k7.c
xen/arch/x86/cpu/mcheck/mce.c
xen/arch/x86/cpu/mcheck/mce.h
xen/arch/x86/cpu/mcheck/mce_intel.c
xen/arch/x86/cpu/mcheck/vmce.c

index 9d5e6913b7e3d85729c79a67578b69e8654c8343..9fc32d62750c2fa15e39597b250fda70c1dcee7e 100644 (file)
@@ -90,8 +90,8 @@ enum mcheck_type amd_k8_mcheck_init(struct cpuinfo_x86 *c)
                        mcequirk_amd_apply(quirkflag);
                } else {
                        /* Enable error reporting of all errors */
-                       wrmsrl(MSR_IA32_MC0_CTL + 4 * i, 0xffffffffffffffffULL);
-                       wrmsrl(MSR_IA32_MC0_STATUS + 4 * i, 0x0ULL);
+                       wrmsrl(MSR_IA32_MCx_CTL(i), 0xffffffffffffffffULL);
+                       wrmsrl(MSR_IA32_MCx_STATUS(i), 0x0ULL);
                        break;
                }
        }
index 343b38bdd85813908bf052a46ca5f28b50dacbbc..7b5ea16dc9a3695c8b1c6c17080be6cead19ae55 100644 (file)
@@ -32,7 +32,7 @@ static fastcall void k7_machine_check(struct cpu_user_regs * regs, long error_co
                smp_processor_id(), mcgsth, mcgstl);
 
        for (i=1; i<nr_mce_banks; i++) {
-               rdmsr (MSR_IA32_MC0_STATUS+i*4,low, high);
+               rdmsr (MSR_IA32_MCx_STATUS(i),low, high);
                if (high&(1<<31)) {
                        if (high & (1<<29))
                                recover |= 1;
@@ -41,16 +41,16 @@ static fastcall void k7_machine_check(struct cpu_user_regs * regs, long error_co
                        printk (KERN_EMERG "Bank %d: %08x%08x", i, high, low);
                        high &= ~(1<<31);
                        if (high & (1<<27)) {
-                               rdmsr (MSR_IA32_MC0_MISC+i*4, alow, ahigh);
+                               rdmsr (MSR_IA32_MCx_MISC(i), alow, ahigh);
                                printk ("[%08x%08x]", ahigh, alow);
                        }
                        if (high & (1<<26)) {
-                               rdmsr (MSR_IA32_MC0_ADDR+i*4, alow, ahigh);
+                               rdmsr (MSR_IA32_MCx_ADDR(i), alow, ahigh);
                                printk (" at %08x%08x", ahigh, alow);
                        }
                        printk ("\n");
                        /* Clear it */
-                       wrmsr (MSR_IA32_MC0_STATUS+i*4, 0UL, 0UL);
+                       wrmsr (MSR_IA32_MCx_STATUS(i), 0UL, 0UL);
                        /* Serialize */
                        wmb();
                        add_taint(TAINT_MACHINE_CHECK);
@@ -78,8 +78,8 @@ enum mcheck_type amd_k7_mcheck_init(struct cpuinfo_x86 *c)
         * as some Athlons cause spurious MCEs when its enabled. */
        wrmsr (MSR_IA32_MC0_STATUS, 0x0, 0x0);
        for (i=1; i<nr_mce_banks; i++) {
-               wrmsr (MSR_IA32_MC0_CTL+4*i, 0xffffffff, 0xffffffff);
-               wrmsr (MSR_IA32_MC0_STATUS+4*i, 0x0, 0x0);
+               wrmsr (MSR_IA32_MCx_CTL(i), 0xffffffff, 0xffffffff);
+               wrmsr (MSR_IA32_MCx_STATUS(i), 0x0, 0x0);
        }
 
        return mcheck_amd_k7;
index c6b813949696676330bb3508fe99a2c2e132a46a..ff36ed9d204201eca8104d8c23acf935c2bac6df 100644 (file)
@@ -164,7 +164,7 @@ static struct mcinfo_bank *mca_init_bank(enum mca_source who,
     }
 
     memset(mib, 0, sizeof (struct mcinfo_bank));
-    mca_rdmsrl(MSR_IA32_MC0_STATUS + bank * 4, mib->mc_status);
+    mca_rdmsrl(MSR_IA32_MCx_STATUS(bank), mib->mc_status);
 
     mib->common.type = MC_TYPE_BANK;
     mib->common.size = sizeof (struct mcinfo_bank);
@@ -172,11 +172,11 @@ static struct mcinfo_bank *mca_init_bank(enum mca_source who,
 
     addr = misc = 0;
     if (mib->mc_status & MCi_STATUS_MISCV)
-        mca_rdmsrl(MSR_IA32_MC0_MISC + 4 * bank, mib->mc_misc);
+        mca_rdmsrl(MSR_IA32_MCx_MISC(bank), mib->mc_misc);
 
     if (mib->mc_status & MCi_STATUS_ADDRV)
     {
-        mca_rdmsrl(MSR_IA32_MC0_ADDR + 4 * bank, mib->mc_addr);
+        mca_rdmsrl(MSR_IA32_MCx_ADDR(bank), mib->mc_addr);
 
         if (mfn_valid(paddr_to_pfn(mib->mc_addr))) {
             struct domain *d;
@@ -287,7 +287,7 @@ mctelem_cookie_t mcheck_mca_logout(enum mca_source who, struct mca_banks *bankma
         if (!mcabanks_test(i, bankmask))
             continue;
 
-        mca_rdmsrl(MSR_IA32_MC0_STATUS + i * 4, status);
+        mca_rdmsrl(MSR_IA32_MCx_STATUS(i), status);
         if (!(status & MCi_STATUS_VAL))
             continue; /* this bank has no valid telemetry */
 
@@ -345,7 +345,7 @@ mctelem_cookie_t mcheck_mca_logout(enum mca_source who, struct mca_banks *bankma
         /* By default, need_clear = 1 */
         if (who != MCA_MCE_SCAN && need_clear)
             /* Clear status */
-            mca_wrmsrl(MSR_IA32_MC0_STATUS + 4 * i, 0x0ULL);
+            mca_wrmsrl(MSR_IA32_MCx_STATUS(i), 0x0ULL);
         else if ( who == MCA_MCE_SCAN && need_clear)
             mcabanks_set(i, clear_bank);
 
@@ -605,10 +605,10 @@ void mcheck_mca_clearbanks(struct mca_banks *bankmask)
     for (i = 0; i < 32 && i < nr_mce_banks; i++) {
         if (!mcabanks_test(i, bankmask))
             continue;
-        mca_rdmsrl(MSR_IA32_MC0_STATUS + i * 4, status);
+        mca_rdmsrl(MSR_IA32_MCx_STATUS(i), status);
         if (!(status & MCi_STATUS_VAL))
             continue;
-        mca_wrmsrl(MSR_IA32_MC0_STATUS + 4 * i, 0x0ULL);
+        mca_wrmsrl(MSR_IA32_MCx_STATUS(i), 0x0ULL);
     }
 }
 
@@ -1081,7 +1081,7 @@ void intpose_inval(unsigned int cpu_nr, uint64_t msr)
 
 #define IS_MCA_BANKREG(r) \
     ((r) >= MSR_IA32_MC0_CTL && \
-    (r) <= MSR_IA32_MC0_MISC + (nr_mce_banks - 1) * 4 && \
+    (r) <= MSR_IA32_MCx_MISC(nr_mce_banks - 1) && \
     ((r) - MSR_IA32_MC0_CTL) % 4 != 0) /* excludes MCi_CTL */
 
 static int x86_mc_msrinject_verify(struct xen_mc_msrinject *mci)
index 8e17bc0a5b33cc8e3e766c7d3bdaf85cdac84d84..033ddcf6498e000a6e738401179f1ecae345e31d 100644 (file)
@@ -178,7 +178,7 @@ static inline int mce_vendor_bank_msr(uint32_t msr)
 static inline int mce_bank_msr(uint32_t msr)
 {
     if ( (msr > MSR_IA32_MC0_CTL2 &&
-         msr < (MSR_IA32_MC0_CTL + 4 * nr_mce_banks - 1)) ||
+         msr < (MSR_IA32_MCx_CTL(nr_mce_banks - 1))) ||
         mce_vendor_bank_msr(msr) )
         return 1;
     return 0;
index 7d20f4eafdcfedede24aef8e8d3c4b9706015234..7dc3f54a9a2eb1f253340deda708067409034b19 100644 (file)
@@ -965,13 +965,13 @@ static void mce_init(void)
     {
         /* Some banks are shared across cores, use MCi_CTRL to judge whether
          * this bank has been initialized by other cores already. */
-        rdmsr(MSR_IA32_MC0_CTL + 4*i, l, h);
+        rdmsr(MSR_IA32_MCx_CTL(i), l, h);
         if (!(l | h))
         {
             /* if ctl is 0, this bank is never initialized */
             mce_printk(MCE_VERBOSE, "mce_init: init bank%d\n", i);
-            wrmsr (MSR_IA32_MC0_CTL + 4*i, 0xffffffff, 0xffffffff);
-            wrmsr (MSR_IA32_MC0_STATUS + 4*i, 0x0, 0x0);
+            wrmsr (MSR_IA32_MCx_CTL(i), 0xffffffff, 0xffffffff);
+            wrmsr (MSR_IA32_MCx_STATUS(i), 0x0, 0x0);
         }
     }
     if (firstbank) /* if cmci enabled, firstbank = 0 */
index 353bae4f5b7affa658480a5489dde0e2c8ced229..b2dca25afe83a29f27cfdeaba5a3e4bf36227c89 100644 (file)
@@ -454,7 +454,7 @@ int vmce_init(struct cpuinfo_x86 *c)
         /* Don't care banks before firstbank */
         memset(h_mci_ctrl, 0xff, sizeof(h_mci_ctrl));
         for (i = firstbank; i < nr_mce_banks; i++)
-            rdmsrl(MSR_IA32_MC0_CTL + 4*i, h_mci_ctrl[i]);
+            rdmsrl(MSR_IA32_MCx_CTL(i), h_mci_ctrl[i]);
     }
 
     if (g_mcg_cap & MCG_CTL_P)