Re: [PATCH v6] x86: mce: kexec: switch MCE handler for kexec/kdump

Borislav Petkov
2015-03-06T08:35:38Z

On Fri, Mar 06, 2015 at 02:59:13AM +0000, Naoya Horiguchi wrote:
> From 8890e9976c525a4b480bf5f86008641688de8c11 Mon Sep 17 00:00:00 2001
> From: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> Date: Fri, 6 Mar 2015 11:52:10 +0900
> Subject: [PATCH v6] x86: mce: kexec: switch MCE handler for kexec/kdump
>
> kexec disables (or "shoots down") all CPUs other than a crashing CPU before
> entering the 2nd kernel. But the MCE handler is still enabled after that,
> so if MCE happens and broadcasts over the CPUs after the main thread starts
> the 2nd kernel (which might not initialize MCE device yet, or might decide
> not to enable it,) MCE handler runs only on the other CPUs (not on the main
> thread,) leading to kernel panic with MCE synchronization. The user-visible
> effect of this bug is kdump failure.
>
> Our standard MCE handler do_machine_check() assumes some about system's
> status and it's hard to alter it to cover kexec/kdump context, so let's add
> another kdump-specific one and switch to it.
>
> Note that this problem exists since current MCE handler was implemented in
> 2.6.32, and recently commit 716079f66eac ("mce: Panic when a core has reached
> a timeout") made it more visible by changing the default behavior of the
> synchronization timeout from "ignore" to "panic".
>
> Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>

...

> +static void machine_check_under_kdump(struct pt_regs *regs, long error_code)
> +{
> + struct mce m = {};
> + char *msg = NULL;
> + char *nmsg = NULL;
> + int i;
> + int worst = 0;
> + int severity;
> + int ret;

if you do here

if (mce_cfg.disabled)
return;

you can use the simple rdmsrl variants and not the _safe() ones with
exception handling.

--
Regards/Gruss,
Boris.

ECO tip #101: Trim your mails when you reply.
--