Re: [PATCH] x86/mce: Do not overwrite MCi_STATUS in mce_no_way_out()

From: Luck, Tony
Date: Thu Jun 21 2018 - 16:00:08 EST


On Thu, Jun 21, 2018 at 09:17:11PM +0200, Borislav Petkov wrote:
> On Thu, Jun 21, 2018 at 11:18:09AM -0700, Luck, Tony wrote:
> > Counter proposal. We don't need the temp mci_status because we exit the
> > loop early. Nor the "ret" variable.
> >
> >
> > How does this look?
>
> Yap, better. I'll test it later or tomorrow:
>

Or even better. Just adds the "mce_read_aux()" to check ADDRV and MISCV
and populate more of the struct mce.

-Tony

diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index e4cf6ff1c2e1..5e64e973c02b 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -772,23 +772,24 @@ EXPORT_SYMBOL_GPL(machine_check_poll);
static int mce_no_way_out(struct mce *m, char **msg, unsigned long *validp,
struct pt_regs *regs)
{
- int i, ret = 0;
+ int i;
char *tmp;

for (i = 0; i < mca_cfg.banks; i++) {
m->status = mce_rdmsrl(msr_ops.status(i));
- if (m->status & MCI_STATUS_VAL) {
- __set_bit(i, validp);
- if (quirk_no_way_out)
- quirk_no_way_out(i, m, regs);
- }
+ if (!(m->status & MCI_STATUS_VAL))
+ continue;
+ __set_bit(i, validp);
+ if (quirk_no_way_out)
+ quirk_no_way_out(i, m, regs);

if (mce_severity(m, mca_cfg.tolerant, &tmp, true) >= MCE_PANIC_SEVERITY) {
+ mce_read_aux(m, i);
*msg = tmp;
- ret = 1;
+ return 1;
}
}
- return ret;
+ return 0;
}

/*