}
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);
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;
}
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);
}
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;
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:
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 */
/* 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);
/* 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 */
/* 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 */
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);
}
}
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)
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;
/* 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);