]> xenbits.xensource.com Git - xen.git/commitdiff
mce: clean up msr handling
authorKeir Fraser <keir.fraser@citrix.com>
Fri, 11 Jun 2010 14:22:12 +0000 (15:22 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Fri, 11 Jun 2010 14:22:12 +0000 (15:22 +0100)
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
xen/arch/x86/cpu/mcheck/amd_f10.c
xen/arch/x86/cpu/mcheck/amd_nonfatal.c
xen/arch/x86/cpu/mcheck/mce.c
xen/arch/x86/cpu/mcheck/mce.h
xen/arch/x86/cpu/mcheck/mce_intel.c

index 420bc41c6e140fa7b054d259add732f32edfdb77..0b643d093c60262a5a3cf926afb5f31671660674 100644 (file)
@@ -81,9 +81,9 @@ amd_f10_handler(struct mc_info *mi, uint16_t bank, uint64_t status)
        mc_ext->mc_msr[1].reg = MSR_F10_MC4_MISC2;
        mc_ext->mc_msr[2].reg = MSR_F10_MC4_MISC3;
 
-       mca_rdmsrl(MSR_F10_MC4_MISC1, mc_ext->mc_msr[0].value);
-       mca_rdmsrl(MSR_F10_MC4_MISC2, mc_ext->mc_msr[1].value);
-       mca_rdmsrl(MSR_F10_MC4_MISC3, mc_ext->mc_msr[2].value);
+       mc_ext->mc_msr[0].value = mca_rdmsr(MSR_F10_MC4_MISC1);
+       mc_ext->mc_msr[1].value = mca_rdmsr(MSR_F10_MC4_MISC2);
+       mc_ext->mc_msr[2].value = mca_rdmsr(MSR_F10_MC4_MISC3);
 
        return mc_ext;
 }
index 68d2e1fee6ec2d8fd6bf6c7bddec1b1290cc733a..d0eb69c39e0f21746302b2ebd5350ec9b8dd9069 100644 (file)
@@ -144,7 +144,7 @@ static void mce_amd_work_fn(void *data)
                uint64_t value;
                uint32_t counter;
 
-               mca_rdmsrl(MSR_IA32_MC4_MISC, value);
+               value = mca_rdmsr(MSR_IA32_MC4_MISC);
                /* Only the error counter field is of interest
                 * Bit field is described in AMD K8 BKDG chapter 6.4.5.5
                 */
@@ -169,7 +169,7 @@ static void mce_amd_work_fn(void *data)
                        value &= ~(0x60FFF00000000ULL);
                        /* Counter enable */
                        value |= (1ULL << 51);
-                       mca_wrmsrl(MSR_IA32_MC4_MISC, value);
+                       mca_wrmsr(MSR_IA32_MC4_MISC, value);
                        wmb();
                }
        }
index c35659b6dc6e2591f9e6e903ee18769ec5783e9c..237ebd125eb657b16c11ea67ff775648429ee4f8 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_MCx_STATUS(bank), mib->mc_status);
+    mib->mc_status = mca_rdmsr(MSR_IA32_MCx_STATUS(bank));
 
     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_MCx_MISC(bank), mib->mc_misc);
+        mib->mc_misc = mca_rdmsr(MSR_IA32_MCx_MISC(bank));
 
     if (mib->mc_status & MCi_STATUS_ADDRV)
     {
-        mca_rdmsrl(MSR_IA32_MCx_ADDR(bank), mib->mc_addr);
+        mib->mc_addr = mca_rdmsr(MSR_IA32_MCx_ADDR(bank));
 
         if (mfn_valid(paddr_to_pfn(mib->mc_addr))) {
             struct domain *d;
@@ -189,7 +189,7 @@ static struct mcinfo_bank *mca_init_bank(enum mca_source who,
     }
 
     if (who == MCA_CMCI_HANDLER) {
-        mca_rdmsrl(MSR_IA32_MC0_CTL2 + bank, mib->mc_ctrl2);
+        mib->mc_ctrl2 = mca_rdmsr(MSR_IA32_MC0_CTL2 + bank);
         rdtscll(mib->mc_tsc);
     }
 
@@ -207,7 +207,7 @@ static int mca_init_global(uint32_t flags, struct mcinfo_global *mig)
     memset(mig, 0, sizeof (struct mcinfo_global));
     mig->common.type = MC_TYPE_GLOBAL;
     mig->common.size = sizeof (struct mcinfo_global);
-    mca_rdmsrl(MSR_IA32_MCG_STATUS, status);
+    status = mca_rdmsr(MSR_IA32_MCG_STATUS);
     mig->mc_gstatus = status;
     mig->mc_domid = mig->mc_vcpuid = -1;
     mig->mc_flags = flags;
@@ -252,7 +252,7 @@ mctelem_cookie_t mcheck_mca_logout(enum mca_source who, struct mca_banks *bankma
     int errcnt = 0;
     int i;
 
-    mca_rdmsrl(MSR_IA32_MCG_STATUS, gstatus);
+    gstatus = mca_rdmsr(MSR_IA32_MCG_STATUS);
     switch (who) {
     case MCA_MCE_HANDLER:
     case MCA_MCE_SCAN:
@@ -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_MCx_STATUS(i), status);
+        status = mca_rdmsr(MSR_IA32_MCx_STATUS(i));
         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_MCx_STATUS(i), 0x0ULL);
+            mca_wrmsr(MSR_IA32_MCx_STATUS(i), 0x0ULL);
         else if ( who == MCA_MCE_SCAN && need_clear)
             mcabanks_set(i, clear_bank);
 
@@ -407,7 +407,7 @@ void mcheck_cmn_handler(struct cpu_user_regs *regs, long error_code,
 
     /* Read global status;  if it does not indicate machine check
      * in progress then bail as long as we have a valid ip to return to. */
-    mca_rdmsrl(MSR_IA32_MCG_STATUS, gstatus);
+    gstatus = mca_rdmsr(MSR_IA32_MCG_STATUS);
     ripv = ((gstatus & MCG_STATUS_RIPV) != 0);
     if (!(gstatus & MCG_STATUS_MCIP) && ripv) {
         add_taint(TAINT_MACHINE_CHECK); /* questionable */
@@ -426,7 +426,7 @@ void mcheck_cmn_handler(struct cpu_user_regs *regs, long error_code,
 
     /* Clear MCIP or another #MC will enter shutdown state */
     gstatus &= ~MCG_STATUS_MCIP;
-    mca_wrmsrl(MSR_IA32_MCG_STATUS, gstatus);
+    mca_wrmsr(MSR_IA32_MCG_STATUS, gstatus);
     wmb();
 
     /* If no valid errors and our stack is intact, we're done */
@@ -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_MCx_STATUS(i), status);
+        status = mca_rdmsr(MSR_IA32_MCx_STATUS(i));
         if (!(status & MCi_STATUS_VAL))
             continue;
-        mca_wrmsrl(MSR_IA32_MCx_STATUS(i), 0x0ULL);
+        mca_wrmsr(MSR_IA32_MCx_STATUS(i), 0x0ULL);
     }
 }
 
index 033ddcf6498e000a6e738401179f1ecae345e31d..637daca755a49482ac4b297cf1d5a5c3b6fa66af 100644 (file)
@@ -83,13 +83,16 @@ extern struct intpose_ent *intpose_lookup(unsigned int, uint64_t,
     uint64_t *);
 extern void intpose_inval(unsigned int, uint64_t);
 
-#define mca_rdmsrl(msr, var) do { \
-       if (intpose_lookup(smp_processor_id(), msr, &var) == NULL) \
-               rdmsrl(msr, var); \
-} while (0)
+static inline uint64_t mca_rdmsr(unsigned int msr)
+{
+       uint64_t val;
+       if (intpose_lookup(smp_processor_id(), msr, &val) == NULL)
+               rdmsrl(msr, val);
+       return val;
+}
 
 /* Write an MSR, invalidating any interposed value */
-#define        mca_wrmsrl(msr, val) do { \
+#define mca_wrmsr(msr, val) do { \
        intpose_inval(smp_processor_id(), msr); \
        wrmsrl(msr, val); \
 } while (0)
index 0e288935899bd1e8f4d1f148caa1db4c3816cbfa..573838c4d4055937f60472f87d3b323e195c4355 100644 (file)
@@ -339,7 +339,7 @@ static int mce_urgent_action(struct cpu_user_regs *regs,
     if ( mctc == NULL)
         return 0;
 
-    mca_rdmsrl(MSR_IA32_MCG_STATUS, gstatus);
+    gstatus = mca_rdmsr(MSR_IA32_MCG_STATUS);
     /* Xen is not pre-emptible */
     if ( !(gstatus & MCG_STATUS_RIPV) && !guest_mode(regs))
         return 0;
@@ -819,10 +819,10 @@ static void intel_machine_check(struct cpu_user_regs * regs, long error_code)
 
     /* Clear flags after above fatal check */
     mce_barrier_enter(&mce_trap_bar);
-    mca_rdmsrl(MSR_IA32_MCG_STATUS, gstatus);
+    gstatus = mca_rdmsr(MSR_IA32_MCG_STATUS);
     if ((gstatus & MCG_STATUS_MCIP) != 0) {
         mce_printk(MCE_CRITICAL, "MCE: Clear MCIP@ last step");
-        mca_wrmsrl(MSR_IA32_MCG_STATUS, gstatus & ~MCG_STATUS_MCIP);
+        mca_wrmsr(MSR_IA32_MCG_STATUS, gstatus & ~MCG_STATUS_MCIP);
     }
     mce_barrier_exit(&mce_trap_bar);