From patchwork Tue Dec 10 00:07:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jan_H=2E_Sch=C3=B6nherr?= X-Patchwork-Id: 11281085 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 75495138C for ; Tue, 10 Dec 2019 00:08:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 53E0F20828 for ; Tue, 10 Dec 2019 00:08:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amazon.de header.i=@amazon.de header.b="a9JxCM3p" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727104AbfLJAIp (ORCPT ); Mon, 9 Dec 2019 19:08:45 -0500 Received: from smtp-fw-9101.amazon.com ([207.171.184.25]:6165 "EHLO smtp-fw-9101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726495AbfLJAIo (ORCPT ); Mon, 9 Dec 2019 19:08:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1575936524; x=1607472524; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fpv4VG7PIjudrNgaI7UFOxOh5o/9bkkIlS+d2xSAdhI=; b=a9JxCM3pEHc0hF4kMWssEhkOR8fhK0pAtwzp2ty7BFzWT/2NTKzsW2zm yn+C1+1VYc6ZHAQqBeGuXuF5J6JF2vmjO9Jft0J7rYk80KsCGsOkeCmrK daVCNGr1jFpDPoS/bu33rLvuxu0sRTC/7/rtsSwVV3poUfvHsYzD7g2lt w=; IronPort-SDR: 7mN0fRfcHf5mgSLbtzcJ/TUol1ei8kMCusTiSYbu7F8XfET/DGC0HP+u2MQBFlSeWVjYLT/UAM JVcZlVW2ZG4A== X-IronPort-AV: E=Sophos;i="5.69,297,1571702400"; d="scan'208";a="4144095" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-1e-57e1d233.us-east-1.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-9101.sea19.amazon.com with ESMTP; 10 Dec 2019 00:08:33 +0000 Received: from u7588a65da6b65f.ant.amazon.com (iad7-ws-svc-lb50-vlan3.amazon.com [10.0.93.214]) by email-inbound-relay-1e-57e1d233.us-east-1.amazon.com (Postfix) with ESMTPS id 4AE891416B1; Tue, 10 Dec 2019 00:08:29 +0000 (UTC) Received: from u7588a65da6b65f.ant.amazon.com (localhost [127.0.0.1]) by u7588a65da6b65f.ant.amazon.com (8.15.2/8.15.2/Debian-3) with ESMTPS id xBA08OKm018214 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 10 Dec 2019 01:08:24 +0100 Received: (from jschoenh@localhost) by u7588a65da6b65f.ant.amazon.com (8.15.2/8.15.2/Submit) id xBA08Mbg018201; Tue, 10 Dec 2019 01:08:22 +0100 From: =?utf-8?q?Jan_H=2E_Sch=C3=B6nherr?= To: Tony Luck , Borislav Petkov Cc: =?utf-8?q?Jan_H=2E_Sch=C3=B6nherr?= , linux-edac@vger.kernel.org, Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org Subject: [PATCH 1/6] x86/mce: Take action on UCNA/Deferred errors again Date: Tue, 10 Dec 2019 01:07:28 +0100 Message-Id: <20191210000733.17979-2-jschoenh@amazon.de> X-Mailer: git-send-email 2.22.0.3.gb49bb57c8208.dirty In-Reply-To: <20191210000733.17979-1-jschoenh@amazon.de> References: <20191210000733.17979-1-jschoenh@amazon.de> MIME-Version: 1.0 Sender: linux-edac-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org Linux 3.19 commit fa92c5869426 ("x86, mce: Support memory error recovery for both UCNA and Deferred error in machine_check_poll") added handling of UCNA and Deferred errors by adding them to the ring for SRAO errors. Later, Linux 4.3 commit fd4cf79fcc4b ("x86/mce: Remove the MCE ring for Action Optional errors") switched storage from the SRAO ring to the unified pool that is still in use today. In order to only act on the intended errors, a filter for MCE_AO_SEVERITY was used -- effectively removing handling of UCNA/Deferred errors again. Extend the severity filter to include UCNA/Deferred errors once more. Fixes: fd4cf79fcc4b ("x86/mce: Remove the MCE ring for Action Optional errors") Signed-off-by: Jan H. Schönherr --- arch/x86/kernel/cpu/mce/core.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 743370ee4983..d5a8b99f7ba3 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -595,14 +595,16 @@ static int srao_decode_notifier(struct notifier_block *nb, unsigned long val, struct mce *mce = (struct mce *)data; unsigned long pfn; - if (!mce) + if (!mce || !mce_usable_address(mce)) return NOTIFY_DONE; - if (mce_usable_address(mce) && (mce->severity == MCE_AO_SEVERITY)) { - pfn = mce->addr >> PAGE_SHIFT; - if (!memory_failure(pfn, 0)) - set_mce_nospec(pfn); - } + if (mce->severity != MCE_AO_SEVERITY && + mce->severity != MCE_DEFERRED_SEVERITY) + return NOTIFY_DONE; + + pfn = mce->addr >> PAGE_SHIFT; + if (!memory_failure(pfn, 0)) + set_mce_nospec(pfn); return NOTIFY_OK; } From patchwork Tue Dec 10 00:07:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jan_H=2E_Sch=C3=B6nherr?= X-Patchwork-Id: 11281089 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4DD9A14B7 for ; Tue, 10 Dec 2019 00:08:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2C95620838 for ; Tue, 10 Dec 2019 00:08:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amazon.de header.i=@amazon.de header.b="DNv3txke" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727385AbfLJAIt (ORCPT ); Mon, 9 Dec 2019 19:08:49 -0500 Received: from smtp-fw-33001.amazon.com ([207.171.190.10]:64342 "EHLO smtp-fw-33001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727376AbfLJAIs (ORCPT ); Mon, 9 Dec 2019 19:08:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1575936527; x=1607472527; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OHaekBAwMl2x2lGh3VEH7z4c4/wBagr2Y0BFnAx8418=; b=DNv3txkezIQ5oaN4jR1QA4V9ysVA5qBZXe+179szZzRVPZRyJTSMmq72 42Me3shcjb4u3XItj4MB5v4TZ6+/MvVuNI5LFg4vYV9P6/OSUiLAqjtRd aB1h7/mW9n8lZgV4AWdOsIFNItGTTtvWmLxUKKctOdeBqQins1cwhrXs7 w=; IronPort-SDR: b1LrS38+VaIfbQV48Ex2dsSzkjoaqIYAGOQZQYdjhD73H3FWP+FulaD/1XJbzRXKDEKyDpLp31 tuSfWhcsB9TQ== X-IronPort-AV: E=Sophos;i="5.69,297,1571702400"; d="scan'208";a="13925660" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-2a-c5104f52.us-west-2.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 10 Dec 2019 00:08:34 +0000 Received: from u7588a65da6b65f.ant.amazon.com (pdx2-ws-svc-lb17-vlan2.amazon.com [10.247.140.66]) by email-inbound-relay-2a-c5104f52.us-west-2.amazon.com (Postfix) with ESMTPS id 3BC52A1D6A; Tue, 10 Dec 2019 00:08:33 +0000 (UTC) Received: from u7588a65da6b65f.ant.amazon.com (localhost [127.0.0.1]) by u7588a65da6b65f.ant.amazon.com (8.15.2/8.15.2/Debian-3) with ESMTPS id xBA08SO7018233 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 10 Dec 2019 01:08:29 +0100 Received: (from jschoenh@localhost) by u7588a65da6b65f.ant.amazon.com (8.15.2/8.15.2/Submit) id xBA08Q7h018227; Tue, 10 Dec 2019 01:08:26 +0100 From: =?utf-8?q?Jan_H=2E_Sch=C3=B6nherr?= To: Tony Luck , Borislav Petkov Cc: =?utf-8?q?Jan_H=2E_Sch=C3=B6nherr?= , linux-edac@vger.kernel.org, Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org Subject: [PATCH 2/6] x86/mce: Make mce=nobootlog work again Date: Tue, 10 Dec 2019 01:07:29 +0100 Message-Id: <20191210000733.17979-3-jschoenh@amazon.de> X-Mailer: git-send-email 2.22.0.3.gb49bb57c8208.dirty In-Reply-To: <20191210000733.17979-1-jschoenh@amazon.de> References: <20191210000733.17979-1-jschoenh@amazon.de> MIME-Version: 1.0 Sender: linux-edac-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org Since Linux 4.5 commit 8b38937b7ab5 ("x86/mce: Do not enter deferred errors into the generic pool twice") the mce=nobootlog option has become mostly ineffective (after being only slightly ineffective before), as the code is taking actions on MCEs left over from boot when they have a usable address. Move the check for MCP_DONTLOG a bit outward to make it effective again. Also, since Linux 4.12 commit 011d82611172 ("RAS: Add a Corrected Errors Collector") the two branches of the remaining "if" the bottom of machine_check_poll() do the same. Unify them. Signed-off-by: Jan H. Schönherr --- arch/x86/kernel/cpu/mce/core.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index d5a8b99f7ba3..81ab25d5357a 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -760,24 +760,17 @@ bool machine_check_poll(enum mcp_flags flags, mce_banks_t *b) log_it: error_seen = true; - mce_read_aux(&m, i); - - m.severity = mce_severity(&m, mca_cfg.tolerant, NULL, false); - - /* - * Don't get the IP here because it's unlikely to - * have anything to do with the actual error location. - */ - if (!(flags & MCP_DONTLOG) && !mca_cfg.dont_log_ce) - mce_log(&m); - else if (mce_usable_address(&m)) { + if (!(flags & MCP_DONTLOG)) { + mce_read_aux(&m, i); + m.severity = mce_severity(&m, mca_cfg.tolerant, NULL, + false); /* - * Although we skipped logging this, we still want - * to take action. Add to the pool so the registered - * notifiers will see it. + * Don't get the IP here because it's unlikely to + * have anything to do with the actual error location. */ - if (!mce_gen_pool_add(&m)) - mce_schedule_work(); + + if (!mca_cfg.dont_log_ce || mce_usable_address(&m)) + mce_log(&m); } /* From patchwork Tue Dec 10 00:07:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jan_H=2E_Sch=C3=B6nherr?= X-Patchwork-Id: 11281083 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 848FC138C for ; Tue, 10 Dec 2019 00:08:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 634B1207FF for ; Tue, 10 Dec 2019 00:08:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amazon.de header.i=@amazon.de header.b="vcwxagY6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727333AbfLJAIm (ORCPT ); Mon, 9 Dec 2019 19:08:42 -0500 Received: from smtp-fw-6002.amazon.com ([52.95.49.90]:26780 "EHLO smtp-fw-6002.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727104AbfLJAIm (ORCPT ); Mon, 9 Dec 2019 19:08:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1575936521; x=1607472521; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HicyFk+3d8ZmzP7+t6CcJT69ujvdkdzFVSdbujksngc=; b=vcwxagY6j3Tuo2L5Lv9VL1YM4TBsHLEwtABqGZG9KvUWdL91hw/e6tyw umEBAyrgh8MeJePedJ9LVnvLO2Zh789fRLO9Yx62Uy6BtGNmaZpChLQ1Y ay6LeafwSrJfVm62aurQI2CbVUBrHagrYedsgU5+OAkMkLEH1ZwtFAKT8 Y=; IronPort-SDR: ez3FEeS2blQmwMhwslx8x+/APd4ERBvv+LDhRT6+W/JeOvkbo1LG1bpQ7PN1I5hiRe/dydg7zM vCbHFNWlkQSQ== X-IronPort-AV: E=Sophos;i="5.69,297,1571702400"; d="scan'208";a="6901773" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-2b-8cc5d68b.us-west-2.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP; 10 Dec 2019 00:08:38 +0000 Received: from u7588a65da6b65f.ant.amazon.com (pdx2-ws-svc-lb17-vlan2.amazon.com [10.247.140.66]) by email-inbound-relay-2b-8cc5d68b.us-west-2.amazon.com (Postfix) with ESMTPS id 53F50A1DD0; Tue, 10 Dec 2019 00:08:37 +0000 (UTC) Received: from u7588a65da6b65f.ant.amazon.com (localhost [127.0.0.1]) by u7588a65da6b65f.ant.amazon.com (8.15.2/8.15.2/Debian-3) with ESMTPS id xBA08Xpk018257 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 10 Dec 2019 01:08:33 +0100 Received: (from jschoenh@localhost) by u7588a65da6b65f.ant.amazon.com (8.15.2/8.15.2/Submit) id xBA08UvI018248; Tue, 10 Dec 2019 01:08:30 +0100 From: =?utf-8?q?Jan_H=2E_Sch=C3=B6nherr?= To: Tony Luck , Borislav Petkov Cc: =?utf-8?q?Jan_H=2E_Sch=C3=B6nherr?= , linux-edac@vger.kernel.org, Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org Subject: [PATCH 3/6] x86/mce: Fix possibly incorrect severity calculation on AMD Date: Tue, 10 Dec 2019 01:07:30 +0100 Message-Id: <20191210000733.17979-4-jschoenh@amazon.de> X-Mailer: git-send-email 2.22.0.3.gb49bb57c8208.dirty In-Reply-To: <20191210000733.17979-1-jschoenh@amazon.de> References: <20191210000733.17979-1-jschoenh@amazon.de> MIME-Version: 1.0 Sender: linux-edac-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org The function mce_severity_amd_smca() requires m->bank to be initialized for correct operation. Fix the one case, where mce_severity() is called without doing so. Fixes: 6bda529ec42e ("x86/mce: Grade uncorrected errors for SMCA-enabled systems") Fixes: d28af26faa0b ("x86/MCE: Initialize mce.bank in the case of a fatal error in mce_no_way_out()") Signed-off-by: Jan H. Schönherr --- arch/x86/kernel/cpu/mce/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 81ab25d5357a..6afb9de251f2 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -809,8 +809,8 @@ static int mce_no_way_out(struct mce *m, char **msg, unsigned long *validp, if (quirk_no_way_out) quirk_no_way_out(i, m, regs); + m->bank = i; if (mce_severity(m, mca_cfg.tolerant, &tmp, true) >= MCE_PANIC_SEVERITY) { - m->bank = i; mce_read_aux(m, i); *msg = tmp; return 1; From patchwork Tue Dec 10 00:07:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jan_H=2E_Sch=C3=B6nherr?= X-Patchwork-Id: 11281091 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DECEC138C for ; Tue, 10 Dec 2019 00:08:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BC8972073D for ; Tue, 10 Dec 2019 00:08:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amazon.de header.i=@amazon.de header.b="DfRwjri9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727376AbfLJAIt (ORCPT ); Mon, 9 Dec 2019 19:08:49 -0500 Received: from smtp-fw-33001.amazon.com ([207.171.190.10]:64342 "EHLO smtp-fw-33001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726495AbfLJAIt (ORCPT ); Mon, 9 Dec 2019 19:08:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1575936529; x=1607472529; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=diyFI+RzBffASURwBK3Ni++loyuQbTc2IKXMyHuvZtM=; b=DfRwjri9fC2CN6pJxvzcW3JJuSnQMqeHQD7REHarJBl8pUjq1xBdLIEL zHtquvNwZs7f01Vk5dpyb6F/U9y8d9POiHiTJ5hnNPbEIfulRVeNhHHJr Q9AR5bOw8CRN25SFkCQxv71N0gUddU+kZCUei8usjZXQc7STIaFmPuu12 8=; IronPort-SDR: KBPs6GRqDzqTG3zmlI/xsFn3k8Q0+ScvDlijyUu9zAosHvDKpX1W7eM0GnSfPWWUKwLJB72/uT zazJ9f7JqqUA== X-IronPort-AV: E=Sophos;i="5.69,297,1571702400"; d="scan'208";a="13925675" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-2a-6e2fc477.us-west-2.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 10 Dec 2019 00:08:42 +0000 Received: from u7588a65da6b65f.ant.amazon.com (pdx2-ws-svc-lb17-vlan3.amazon.com [10.247.140.70]) by email-inbound-relay-2a-6e2fc477.us-west-2.amazon.com (Postfix) with ESMTPS id 67ADAA1D34; Tue, 10 Dec 2019 00:08:41 +0000 (UTC) Received: from u7588a65da6b65f.ant.amazon.com (localhost [127.0.0.1]) by u7588a65da6b65f.ant.amazon.com (8.15.2/8.15.2/Debian-3) with ESMTPS id xBA08bm2018278 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 10 Dec 2019 01:08:37 +0100 Received: (from jschoenh@localhost) by u7588a65da6b65f.ant.amazon.com (8.15.2/8.15.2/Submit) id xBA08ZB9018272; Tue, 10 Dec 2019 01:08:35 +0100 From: =?utf-8?q?Jan_H=2E_Sch=C3=B6nherr?= To: Tony Luck , Borislav Petkov Cc: =?utf-8?q?Jan_H=2E_Sch=C3=B6nherr?= , linux-edac@vger.kernel.org, Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org Subject: [PATCH 4/6] x86/mce: Fix handling of optional message string Date: Tue, 10 Dec 2019 01:07:31 +0100 Message-Id: <20191210000733.17979-5-jschoenh@amazon.de> X-Mailer: git-send-email 2.22.0.3.gb49bb57c8208.dirty In-Reply-To: <20191210000733.17979-1-jschoenh@amazon.de> References: <20191210000733.17979-1-jschoenh@amazon.de> MIME-Version: 1.0 Sender: linux-edac-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org The function mce_severity() is not required to update its msg argument. In fact, mce_severity_amd() doesn't. Fix some code paths, that assume that it is always updated. In particular, this avoids returning uninitialized data in mce_no_way_out(), which may be used later for printing. Signed-off-by: Jan H. Schönherr --- arch/x86/kernel/cpu/mce/core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 6afb9de251f2..b11a74e3fea9 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -809,10 +809,12 @@ static int mce_no_way_out(struct mce *m, char **msg, unsigned long *validp, if (quirk_no_way_out) quirk_no_way_out(i, m, regs); + tmp = NULL; m->bank = i; if (mce_severity(m, mca_cfg.tolerant, &tmp, true) >= MCE_PANIC_SEVERITY) { mce_read_aux(m, i); - *msg = tmp; + if (tmp) + *msg = tmp; return 1; } } @@ -1313,6 +1315,7 @@ void do_machine_check(struct pt_regs *regs, long error_code) * make sure we have the right "msg". */ if (worst >= MCE_PANIC_SEVERITY && mca_cfg.tolerant < 3) { + msg = "Unknown"; mce_severity(&m, cfg->tolerant, &msg, true); mce_panic("Local fatal machine check!", &m, msg); } From patchwork Tue Dec 10 00:07:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jan_H=2E_Sch=C3=B6nherr?= X-Patchwork-Id: 11281087 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0C3AB138C for ; Tue, 10 Dec 2019 00:08:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D632920838 for ; Tue, 10 Dec 2019 00:08:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amazon.de header.i=@amazon.de header.b="p1vu6kW4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727383AbfLJAIs (ORCPT ); Mon, 9 Dec 2019 19:08:48 -0500 Received: from smtp-fw-6002.amazon.com ([52.95.49.90]:26792 "EHLO smtp-fw-6002.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726495AbfLJAIs (ORCPT ); Mon, 9 Dec 2019 19:08:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1575936527; x=1607472527; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yjeP0QuBYLEgvRSy1iLZMZ2p3fhxAaIk9IqnOA42U9c=; b=p1vu6kW4Wg38uHPFy6eR7lP4tYzlXnXNUIipWY8qj3U0DPH1P4dZSw/B rMofkjyI+ykZmajHoy6sZAnj0c/vHxLGTWT53VPCcRf08I1Tw1k8LilfP lkVi3rYLDExyyoIQuZDC+KbhOmoafPb2LplepnzjKFlelfIT/BCByI6C3 E=; IronPort-SDR: ZxTWYGc3xAQiywURUKXpRF+BOi14qJ40xrlN88Np3HyCPuouUMY9VSQrWT8mmjVOuvdWFyrS3W +vdFYklKOa+w== X-IronPort-AV: E=Sophos;i="5.69,297,1571702400"; d="scan'208";a="6901785" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-2a-d0be17ee.us-west-2.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP; 10 Dec 2019 00:08:46 +0000 Received: from u7588a65da6b65f.ant.amazon.com (pdx2-ws-svc-lb17-vlan2.amazon.com [10.247.140.66]) by email-inbound-relay-2a-d0be17ee.us-west-2.amazon.com (Postfix) with ESMTPS id 85FF9A24A6; Tue, 10 Dec 2019 00:08:45 +0000 (UTC) Received: from u7588a65da6b65f.ant.amazon.com (localhost [127.0.0.1]) by u7588a65da6b65f.ant.amazon.com (8.15.2/8.15.2/Debian-3) with ESMTPS id xBA08ft1018300 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 10 Dec 2019 01:08:41 +0100 Received: (from jschoenh@localhost) by u7588a65da6b65f.ant.amazon.com (8.15.2/8.15.2/Submit) id xBA08dUi018294; Tue, 10 Dec 2019 01:08:39 +0100 From: =?utf-8?q?Jan_H=2E_Sch=C3=B6nherr?= To: Tony Luck , Borislav Petkov Cc: =?utf-8?q?Jan_H=2E_Sch=C3=B6nherr?= , linux-edac@vger.kernel.org, Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org Subject: [PATCH 5/6] x86/mce: Pass MCE message to mce_panic() on failed kernel recovery Date: Tue, 10 Dec 2019 01:07:32 +0100 Message-Id: <20191210000733.17979-6-jschoenh@amazon.de> X-Mailer: git-send-email 2.22.0.3.gb49bb57c8208.dirty In-Reply-To: <20191210000733.17979-1-jschoenh@amazon.de> References: <20191210000733.17979-1-jschoenh@amazon.de> MIME-Version: 1.0 Sender: linux-edac-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org In commit b2f9d678e28c ("x86/mce: Check for faults tagged in EXTABLE_CLASS_FAULT exception table entries") another call to mce_panic() was introduced. Pass the message of the handled MCE to that instance of mce_panic() as well, as there doesn't seem to be a reason not to. Signed-off-by: Jan H. Schönherr --- arch/x86/kernel/cpu/mce/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index b11a74e3fea9..677e9079e5ba 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -1351,7 +1351,7 @@ void do_machine_check(struct pt_regs *regs, long error_code) ist_end_non_atomic(); } else { if (!fixup_exception(regs, X86_TRAP_MC, error_code, 0)) - mce_panic("Failed kernel mode recovery", &m, NULL); + mce_panic("Failed kernel mode recovery", &m, msg); } out_ist: From patchwork Tue Dec 10 00:07:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jan_H=2E_Sch=C3=B6nherr?= X-Patchwork-Id: 11281093 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 527E6138C for ; Tue, 10 Dec 2019 00:08:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2FB9D20838 for ; Tue, 10 Dec 2019 00:08:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amazon.de header.i=@amazon.de header.b="v5O2T21X" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727388AbfLJAIw (ORCPT ); Mon, 9 Dec 2019 19:08:52 -0500 Received: from smtp-fw-9101.amazon.com ([207.171.184.25]:6181 "EHLO smtp-fw-9101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726495AbfLJAIv (ORCPT ); Mon, 9 Dec 2019 19:08:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1575936531; x=1607472531; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PwOP4ZyxB9R575wj8vgIp3jwd7oy+8sBiI9LgJOgFtY=; b=v5O2T21XRuABzqnsjof0negCQIiHOoornFMuqTg1oRNw8a4EdALFFS69 6wKzU62J74OJe2za0bFKCpzQTsRT1cwD4MjaquJWGOn5pDGPnON3zb0pM +twmROslYT5FYH3DlbdaiPRvljTP+FjvPANnPKLFGZloMz0GmgtdBzJpi E=; IronPort-SDR: KWTMxw2eVwcNc0o3ykAP2cyBDQvBHn/I9jlq6UBA5qRN4V4oiSTFEHbZH0TyTs/0XPXzq6e1jG rhej8/w3mE0w== X-IronPort-AV: E=Sophos;i="5.69,297,1571702400"; d="scan'208";a="4144126" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-2b-81e76b79.us-west-2.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-9101.sea19.amazon.com with ESMTP; 10 Dec 2019 00:08:50 +0000 Received: from u7588a65da6b65f.ant.amazon.com (pdx2-ws-svc-lb17-vlan2.amazon.com [10.247.140.66]) by email-inbound-relay-2b-81e76b79.us-west-2.amazon.com (Postfix) with ESMTPS id C86A2A0731; Tue, 10 Dec 2019 00:08:49 +0000 (UTC) Received: from u7588a65da6b65f.ant.amazon.com (localhost [127.0.0.1]) by u7588a65da6b65f.ant.amazon.com (8.15.2/8.15.2/Debian-3) with ESMTPS id xBA08jQ2018322 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 10 Dec 2019 01:08:45 +0100 Received: (from jschoenh@localhost) by u7588a65da6b65f.ant.amazon.com (8.15.2/8.15.2/Submit) id xBA08hT3018312; Tue, 10 Dec 2019 01:08:43 +0100 From: =?utf-8?q?Jan_H=2E_Sch=C3=B6nherr?= To: Tony Luck , Borislav Petkov Cc: =?utf-8?q?Jan_H=2E_Sch=C3=B6nherr?= , linux-edac@vger.kernel.org, Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org Subject: [PATCH 6/6] x86/mce: Remove mce_inject_log() in favor of mce_log() Date: Tue, 10 Dec 2019 01:07:33 +0100 Message-Id: <20191210000733.17979-7-jschoenh@amazon.de> X-Mailer: git-send-email 2.22.0.3.gb49bb57c8208.dirty In-Reply-To: <20191210000733.17979-1-jschoenh@amazon.de> References: <20191210000733.17979-1-jschoenh@amazon.de> MIME-Version: 1.0 Sender: linux-edac-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org The mutex in mce_inject_log() became unnecessary with Linux 4.12 commit 5de97c9f6d85 ("x86/mce: Factor out and deprecate the /dev/mcelog driver"), though the original reason for its presence only vanished with Linux 4.14 commit 7298f08ea887 ("x86/mcelog: Get rid of RCU remnants"). Drop the mutex. And as that makes mce_inject_log() identical to mce_log(), get rid of the former in favor of the latter. Signed-off-by: Jan H. Schönherr --- arch/x86/kernel/cpu/mce/core.c | 11 +---------- arch/x86/kernel/cpu/mce/inject.c | 2 +- arch/x86/kernel/cpu/mce/internal.h | 2 -- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 677e9079e5ba..44cccae097cb 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -53,8 +53,6 @@ #include "internal.h" -static DEFINE_MUTEX(mce_log_mutex); - /* sysfs synchronization */ static DEFINE_MUTEX(mce_sysfs_mutex); @@ -156,14 +154,7 @@ void mce_log(struct mce *m) if (!mce_gen_pool_add(m)) irq_work_queue(&mce_irq_work); } - -void mce_inject_log(struct mce *m) -{ - mutex_lock(&mce_log_mutex); - mce_log(m); - mutex_unlock(&mce_log_mutex); -} -EXPORT_SYMBOL_GPL(mce_inject_log); +EXPORT_SYMBOL_GPL(mce_log); static struct notifier_block mce_srao_nb; diff --git a/arch/x86/kernel/cpu/mce/inject.c b/arch/x86/kernel/cpu/mce/inject.c index 1f30117b24ba..3413b41b8d55 100644 --- a/arch/x86/kernel/cpu/mce/inject.c +++ b/arch/x86/kernel/cpu/mce/inject.c @@ -494,7 +494,7 @@ static void do_inject(void) i_mce.status |= MCI_STATUS_SYNDV; if (inj_type == SW_INJ) { - mce_inject_log(&i_mce); + mce_log(&i_mce); return; } diff --git a/arch/x86/kernel/cpu/mce/internal.h b/arch/x86/kernel/cpu/mce/internal.h index 43031db429d2..1eb1a9343188 100644 --- a/arch/x86/kernel/cpu/mce/internal.h +++ b/arch/x86/kernel/cpu/mce/internal.h @@ -78,8 +78,6 @@ static inline int apei_clear_mce(u64 record_id) } #endif -void mce_inject_log(struct mce *m); - /* * We consider records to be equivalent if bank+status+addr+misc all match. * This is only used when the system is going down because of a fatal error