From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750755AbdAWIAV (ORCPT ); Mon, 23 Jan 2017 03:00:21 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39844 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750703AbdAWIAU (ORCPT ); Mon, 23 Jan 2017 03:00:20 -0500 From: Xunlei Pang To: x86@kernel.org, linux-kernel@vger.kernel.org, kexec@lists.infradead.org Cc: Tony Luck , Borislav Petkov , Ingo Molnar , Dave Young , Prarit Bhargava , Junichi Nomura , Kiyoshi Ueda , Xunlei Pang , Naoya Horiguchi Subject: [PATCH] x86/mce: Keep quiet in case of broadcasted mce after system panic Date: Mon, 23 Jan 2017 16:01:51 +0800 Message-Id: <1485158511-22374-1-git-send-email-xlpang@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 23 Jan 2017 08:00:21 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We met an issue for kdump: after kdump kernel boots up, and there comes a broadcasted mce in first kernel, the other cpus remaining in first kernel will enter the old mce handler of first kernel, then timeout and panic due to MCE synchronization, finally reset the kdump cpus. This patch lets cpus stay quiet when panic happens, so before crash cpu shots them down or after kdump boots, they should not do anything except clearing MCG_STATUS in case of broadcasted mce. This is useful for kdump to let the vmcore dumping perform as hard as it can. Previous efforts: https://patchwork.kernel.org/patch/6167631/ https://lists.gt.net/linux/kernel/2146557 Cc: Naoya Horiguchi Signed-off-by: Xunlei Pang --- arch/x86/kernel/cpu/mcheck/mce.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c index 00ef432..0c2bf77 100644 --- a/arch/x86/kernel/cpu/mcheck/mce.c +++ b/arch/x86/kernel/cpu/mcheck/mce.c @@ -1157,6 +1157,23 @@ void do_machine_check(struct pt_regs *regs, long error_code) mce_gather_info(&m, regs); + /* + * Check if this MCE is signaled to only this logical processor, + * on Intel only. + */ + if (m.cpuvendor == X86_VENDOR_INTEL) + lmce = m.mcgstatus & MCG_STATUS_LMCES; + + /* + * Special treatment for Intel broadcasted machine check: + * To avoid panic due to MCE synchronization in case of kdump, + * after system panic, clear global status and bail out. + */ + if (!lmce && atomic_read(&panic_cpu) != PANIC_CPU_INVALID) { + wrmsrl(MSR_IA32_MCG_STATUS, 0); + goto out; + } + final = this_cpu_ptr(&mces_seen); *final = m; @@ -1174,13 +1191,6 @@ void do_machine_check(struct pt_regs *regs, long error_code) kill_it = 1; /* - * Check if this MCE is signaled to only this logical processor, - * on Intel only. - */ - if (m.cpuvendor == X86_VENDOR_INTEL) - lmce = m.mcgstatus & MCG_STATUS_LMCES; - - /* * Go through all banks in exclusion of the other CPUs. This way we * don't report duplicated events on shared banks because the first one * to see it will clear it. If this is a Local MCE, then no need to -- 1.8.3.1