Received: by 10.223.185.116 with SMTP id b49csp1118259wrg; Sat, 3 Mar 2018 16:06:45 -0800 (PST) X-Google-Smtp-Source: AG47ELtqUELPOLu+WJNg2yFvgHg9lKj8rP2bpGYLrF995PD+3H5I+OXyJD0Kl8OgKgtJdEFC3Ipc X-Received: by 10.99.136.195 with SMTP id l186mr7609091pgd.427.1520122005270; Sat, 03 Mar 2018 16:06:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520122005; cv=none; d=google.com; s=arc-20160816; b=KUptKuotpaj35CxavnPCyhI3PPhnTfIUppRJ6JNckl0xtgL1xcOlbVlgN1GDe9aoU+ U7B7PJFyTIXa060+SsMqy95fwhj5ao1GJCQgTOmYnXDmFWgt6JcNSXxqFUua6icOdKAD yIwBd8UkjkE8hXe0bI8NFvqj74KC/MoZfyUfLOJUQQYKLF0gJWsKrXSlkv/M7FQblI6M cDlizmw53m6r/ErFpvYpqYVcP7gxU60we2O3kc784o6lZ7ROy8cMvrgDiA4zUuktLbwJ a3L2z6w/hTWJGHnMjGiOlizgoZ/rNbYy9WKccVQKli7qRqFZjXPgYZuGkCWl3NuJd6VB v+Ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=j2GyNVWPMS2SJMmGZuW9QEYkXdc2CkJ2FCHVsM4F7H0=; b=fSK1gIITWW0UBg9RDjgZd0HD9U82qhI8/45HZLD9lJXjwfTuD4sy/Q54z8ExbRojOP 63IjFOMgxGR4jbZl9zB3cuT6Lu+Er4Z3SyhU1S4qMYohQ+A5HBrxTUQkZ1n0nu0lMaKn 7JF1S0qPXsS5iGoF1OzJ9jt49EM/yIGuSPN8B9dVLEpfdKrSVd0tdRWnZpEk+N8WDh6y aayRlFTNIUHblITuWwLsF3JEOx/A+eI/HxoEprnLtun2KYbBt6midRQmZIIOcRWziGVf 0WskPj/5PB+g/ZcwlgDQGxhLv9+9Cvj97oR1QRTgIB8KQXo9NYNgypl5MwlcwekscP6i myFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=UUR5xqIA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u29si6169548pgn.770.2018.03.03.16.06.31; Sat, 03 Mar 2018 16:06:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=UUR5xqIA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933486AbeCDAEt (ORCPT + 99 others); Sat, 3 Mar 2018 19:04:49 -0500 Received: from mail-sn1nam01on0113.outbound.protection.outlook.com ([104.47.32.113]:58832 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933579AbeCCWbW (ORCPT ); Sat, 3 Mar 2018 17:31:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=j2GyNVWPMS2SJMmGZuW9QEYkXdc2CkJ2FCHVsM4F7H0=; b=UUR5xqIAArgNsXGLAw6DwQVFPe4eChRzhRvdX76gYom7vr5JDKGJgDe1gqtuJq3+goJRekwo/B9fpywPXDKDbWzdn3vite/rFa/1LEVBwly3ISwpg2pDGQCdwvUI4h9E0wenGMuz+TM/2kwZaW1cMXJH1O+haJZMaXgBOxcXcQM= Received: from MW2PR2101MB1034.namprd21.prod.outlook.com (52.132.149.10) by MW2PR2101MB0970.namprd21.prod.outlook.com (52.132.146.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.567.3; Sat, 3 Mar 2018 22:31:19 +0000 Received: from MW2PR2101MB1034.namprd21.prod.outlook.com ([fe80::1d56:338f:e2b:cec0]) by MW2PR2101MB1034.namprd21.prod.outlook.com ([fe80::1d56:338f:e2b:cec0%3]) with mapi id 15.20.0567.006; Sat, 3 Mar 2018 22:31:19 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Xunlei Pang , Borislav Petkov , Naoya Horiguchi , "kexec@lists.infradead.org" , linux-edac , Thomas Gleixner , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 024/219] x86/mce: Handle broadcasted MCE gracefully with kexec Thread-Topic: [PATCH AUTOSEL for 4.9 024/219] x86/mce: Handle broadcasted MCE gracefully with kexec Thread-Index: AQHTsz7o4St1KjASoUSgEQKNPoODmw== Date: Sat, 3 Mar 2018 22:28:09 +0000 Message-ID: <20180303222716.26640-24-alexander.levin@microsoft.com> References: <20180303222716.26640-1-alexander.levin@microsoft.com> In-Reply-To: <20180303222716.26640-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MW2PR2101MB0970;7:ytEN/UpkOLp3+VPGqlafAVRs1+VHibJ+0O9nUew8jGB9xzjEAq0BpQ7XCxDEgUkCo9AlpoKyypfv6wXq+hi8nY/0WwCjN0Y+M/kG1ihQBGaaFdHWlMI/K9+nFlOt0MXi8KLwLJQKdHywPLGnUO3K7EWdowHQABqgo1EZd+qKA80iknANTAc/ufPAhhiZGd25s8nIHiFTTp9V+nMsgiETySJC9OsnIAEKNSve7wIMWIBf9SskQXq8j+yyirKsHZnz x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: c8d81519-814d-46e6-c7c4-08d581567c3c x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(3008032)(2017052603307)(7193020);SRVR:MW2PR2101MB0970; x-ms-traffictypediagnostic: MW2PR2101MB0970: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(9452136761055)(258649278758335)(42068640409301)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040501)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3002001)(3231220)(944501244)(52105095)(6055026)(61426038)(61427038)(6041288)(20161123562045)(20161123558120)(20161123560045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:MW2PR2101MB0970;BCL:0;PCL:0;RULEID:;SRVR:MW2PR2101MB0970; x-forefront-prvs: 0600F93FE1 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(376002)(39380400002)(366004)(396003)(39860400002)(346002)(199004)(189003)(575784001)(86362001)(110136005)(4326008)(6506007)(14454004)(99286004)(8936002)(1076002)(36756003)(2906002)(102836004)(76176011)(25786009)(6486002)(316002)(478600001)(3280700002)(107886003)(186003)(54906003)(26005)(81166006)(966005)(7736002)(8676002)(6512007)(6306002)(81156014)(305945005)(72206003)(6436002)(53936002)(6116002)(6666003)(86612001)(68736007)(3846002)(2950100002)(3660700001)(10290500003)(22452003)(10090500001)(2900100001)(106356001)(2501003)(66066001)(97736004)(5660300001)(5250100002)(105586002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:MW2PR2101MB0970;H:MW2PR2101MB1034.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: wHERh0ua41c9kgDawFBh7xKS3mOWRe+xoU85hfBhNU/KNLkt2q9CZCa820OpDYeFx+MfinRW/gIpt/ddRsvIOwdtkILsNWI08LLizPtRllvqRxn4eArL4W8kTDmtZhmAP6JP52sy6qo6CFQqHt7lZBZcGUQzfFG61BP+ZwA2boQ= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: c8d81519-814d-46e6-c7c4-08d581567c3c X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Mar 2018 22:28:09.6037 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR2101MB0970 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xunlei Pang [ Upstream commit 5bc329503e8191c91c4c40836f062ef771d8ba83 ] When we are about to kexec a crash kernel and right then and there a broadcasted MCE fires while we're still in the first kernel and while the other CPUs remain in a holding pattern, the #MC handler of the first kernel will timeout and then panic due to never completing MCE synchronization. Handle this in a similar way as to when the CPUs are offlined when that broadcasted MCE happens. [ Boris: rewrote commit message and comments. ] Suggested-by: Borislav Petkov Signed-off-by: Xunlei Pang Signed-off-by: Borislav Petkov Acked-by: Tony Luck Cc: Naoya Horiguchi Cc: kexec@lists.infradead.org Cc: linux-edac Link: http://lkml.kernel.org/r/1487857012-9059-1-git-send-email-xlpang@redh= at.com Link: http://lkml.kernel.org/r/20170313095019.19351-1-bp@alien8.de Signed-off-by: Thomas Gleixner Signed-off-by: Sasha Levin --- arch/x86/include/asm/reboot.h | 1 + arch/x86/kernel/cpu/mcheck/mce.c | 18 ++++++++++++++++-- arch/x86/kernel/reboot.c | 5 +++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h index 2cb1cc253d51..fc62ba8dce93 100644 --- a/arch/x86/include/asm/reboot.h +++ b/arch/x86/include/asm/reboot.h @@ -15,6 +15,7 @@ struct machine_ops { }; =20 extern struct machine_ops machine_ops; +extern int crashing_cpu; =20 void native_machine_crash_shutdown(struct pt_regs *regs); void native_machine_shutdown(void); diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/= mce.c index fe5cd6ea1f0e..b0cc7bd26ab5 100644 --- a/arch/x86/kernel/cpu/mcheck/mce.c +++ b/arch/x86/kernel/cpu/mcheck/mce.c @@ -48,6 +48,7 @@ #include #include #include +#include =20 #include "mce-internal.h" =20 @@ -1078,9 +1079,22 @@ void do_machine_check(struct pt_regs *regs, long err= or_code) * on Intel. */ int lmce =3D 1; + int cpu =3D smp_processor_id(); =20 - /* If this CPU is offline, just bail out. */ - if (cpu_is_offline(smp_processor_id())) { + /* + * Cases where we avoid rendezvous handler timeout: + * 1) If this CPU is offline. + * + * 2) If crashing_cpu was set, e.g. we're entering kdump and we need to + * skip those CPUs which remain looping in the 1st kernel - see + * crash_nmi_callback(). + * + * Note: there still is a small window between kexec-ing and the new, + * kdump kernel establishing a new #MC handler where a broadcasted MCE + * might not get handled properly. + */ + if (cpu_is_offline(cpu) || + (crashing_cpu !=3D -1 && crashing_cpu !=3D cpu)) { u64 mcgstatus; =20 mcgstatus =3D mce_rdmsrl(MSR_IA32_MCG_STATUS); diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c index ce020a69bba9..03f21dbfaa9d 100644 --- a/arch/x86/kernel/reboot.c +++ b/arch/x86/kernel/reboot.c @@ -769,10 +769,11 @@ void machine_crash_shutdown(struct pt_regs *regs) #endif =20 =20 +/* This is the CPU performing the emergency shutdown work. */ +int crashing_cpu =3D -1; + #if defined(CONFIG_SMP) =20 -/* This keeps a track of which one is crashing cpu. */ -static int crashing_cpu; static nmi_shootdown_cb shootdown_callback; =20 static atomic_t waiting_for_crash_ipi; --=20 2.14.1