Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4550358ybb; Tue, 7 Apr 2020 09:36:08 -0700 (PDT) X-Google-Smtp-Source: APiQypKyGxDJOK9H8w+h2BGPOb0WMTCdWj28gifPDzUG13939inTRctYngJvcZAB3arwcLhSBIcb X-Received: by 2002:a9d:728e:: with SMTP id t14mr2404301otj.63.1586277368255; Tue, 07 Apr 2020 09:36:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586277368; cv=none; d=google.com; s=arc-20160816; b=T8KOBIWecMJCsHgovv3rcVTFIRZM1URNcf0w3j5Q4f6WX3/+M26MxabyLbtKWLWveA WVmT3qU7c+l7I7LKMQ4WNhK1kC2hm1Wz9unCi0FJ1ujBU0DRwT4PNGUe2nE8hsmOY/Ja Fw8bpnAJld270iaNPUAiZN3VqliGKHeWbriqhPLlJN53mZPMpKVguNYyvCCkydFRp7Xp SYYs65LQDMixJmqKsA2VSkrsn7ZHK4oFP4Jt0fAj9YcjWcnr2MjmKmGsMCjuHp7Fjyvy Va+EiYaeWVy1OM//9u7OQVWTwo6T9W4nu1LTWTh30CMYR/fHjA2qTxyZFgw/ZFog23au /UCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=L++T/eHJQ4wQj0es+pUzShPUQPqyKRj22HWDQVhzfPI=; b=Fb1HbFXcgK+/cDBdBe+ZOzTsIJ92eii4tUWVCUwOgXO3UfSMEHGKts89YBLxbdOetv yHiZDSdb4Go64QZqUAL3i6beVGgB2R661ZK1XoHbdRXBL4FdrGPzuAMrLJQJqEVzLkyA 2q2ROUWWRHkcvssim8BH4y9XCQtgYgNG3yKhw0T5a9/bpXFOzLu7cypeR+TE/IL6wh5q yrBeI7K1T7QYzIMraVRtzKF5jt57KiNvA1XjvcLKtKqmjVWJKBhHgCNCUnrw2gwfInjr hEebsYa9eu4DxsWymT60mhv2WsBmwMvjGUHrR3eYLx2fXzDYSJBtlKTxtNGZZzNBzMQq 5bng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=JAusqSio; 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=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d21si1392846oof.2.2020.04.07.09.35.55; Tue, 07 Apr 2020 09:36:08 -0700 (PDT) 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=@alien8.de header.s=dkim header.b=JAusqSio; 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=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728667AbgDGQeq (ORCPT + 99 others); Tue, 7 Apr 2020 12:34:46 -0400 Received: from mail.skyhub.de ([5.9.137.197]:53954 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728417AbgDGQeX (ORCPT ); Tue, 7 Apr 2020 12:34:23 -0400 Received: from zn.tnic (p200300EC2F0B2700A94266E658FF3DDD.dip0.t-ipconnect.de [IPv6:2003:ec:2f0b:2700:a942:66e6:58ff:3ddd]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 7FA311EC0CE2; Tue, 7 Apr 2020 18:34:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1586277262; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L++T/eHJQ4wQj0es+pUzShPUQPqyKRj22HWDQVhzfPI=; b=JAusqSiobci4wDF6QYXUWcqDePXyEGiN9+pQWI6uED05IE0Z2/Zd78G2yyThhUXmS12enD I0IGMqEOIHH/oNzG/DqW65JYgzvfCiFT3CiAvW+hJlxdU8sw2fBcwF0uy8uOotpdVJSP03 Gkon4NHsegw2SjhIo2iQnHRyh5bAQqw= From: Borislav Petkov To: Tony Luck Cc: Yazen Ghannam , X86 ML , LKML Subject: [PATCH 3/9] x86/mce: Convert the CEC to use the MCE notifier Date: Tue, 7 Apr 2020 18:34:08 +0200 Message-Id: <20200407163414.18058-4-bp@alien8.de> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200407163414.18058-1-bp@alien8.de> References: <20200212204652.1489-1-tony.luck@intel.com> <20200407163414.18058-1-bp@alien8.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tony Luck The CEC code has its claws in a couple of routines in mce/core.c. Convert it to just register itself on the normal MCE notifier chain. [ bp: Make cec_add_elem() and cec_init() static. ] Signed-off-by: Tony Luck Signed-off-by: Borislav Petkov Link: https://lkml.kernel.org/r/20200214222720.13168-3-tony.luck@intel.com --- arch/x86/kernel/cpu/mce/core.c | 19 ------------------- drivers/ras/cec.c | 30 ++++++++++++++++++++++++++++-- include/linux/ras.h | 5 ----- 3 files changed, 28 insertions(+), 26 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 43b1519ad4e5..b033b3589630 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -544,21 +544,6 @@ bool mce_is_correctable(struct mce *m) } EXPORT_SYMBOL_GPL(mce_is_correctable); -static bool cec_add_mce(struct mce *m) -{ - if (!m) - return false; - - /* We eat only correctable DRAM errors with usable addresses. */ - if (mce_is_memory_error(m) && - mce_is_correctable(m) && - mce_usable_address(m)) - if (!cec_add_elem(m->addr >> PAGE_SHIFT)) - return true; - - return false; -} - static int mce_early_notifier(struct notifier_block *nb, unsigned long val, void *data) { @@ -567,9 +552,6 @@ static int mce_early_notifier(struct notifier_block *nb, unsigned long val, if (!m) return NOTIFY_DONE; - if (cec_add_mce(m)) - return NOTIFY_STOP; - /* Emit the trace record: */ trace_mce_record(m); @@ -2612,7 +2594,6 @@ static int __init mcheck_late_init(void) static_branch_inc(&mcsafe_key); mcheck_debugfs_init(); - cec_init(); /* * Flush out everything that has been logged during early boot, now that diff --git a/drivers/ras/cec.c b/drivers/ras/cec.c index c09cf55e2d20..6b42040bf956 100644 --- a/drivers/ras/cec.c +++ b/drivers/ras/cec.c @@ -309,7 +309,7 @@ static bool sanity_check(struct ce_array *ca) return ret; } -int cec_add_elem(u64 pfn) +static int cec_add_elem(u64 pfn) { struct ce_array *ca = &ce_arr; unsigned int to = 0; @@ -527,7 +527,30 @@ static int __init create_debugfs_nodes(void) return 1; } -void __init cec_init(void) +static int cec_notifier(struct notifier_block *nb, unsigned long val, + void *data) +{ + struct mce *m = (struct mce *)data; + + if (!m) + return NOTIFY_DONE; + + /* We eat only correctable DRAM errors with usable addresses. */ + if (mce_is_memory_error(m) && + mce_is_correctable(m) && + mce_usable_address(m)) + if (!cec_add_elem(m->addr >> PAGE_SHIFT)) + return NOTIFY_STOP; + + return NOTIFY_DONE; +} + +static struct notifier_block cec_nb = { + .notifier_call = cec_notifier, + .priority = MCE_PRIO_CEC, +}; + +static void __init cec_init(void) { if (ce_arr.disabled) return; @@ -546,8 +569,11 @@ void __init cec_init(void) INIT_DELAYED_WORK(&cec_work, cec_work_fn); schedule_delayed_work(&cec_work, CEC_DECAY_DEFAULT_INTERVAL); + mce_register_decode_chain(&cec_nb); + pr_info("Correctable Errors collector initialized.\n"); } +late_initcall(cec_init); int __init parse_cec_param(char *str) { diff --git a/include/linux/ras.h b/include/linux/ras.h index 7c3debb47c87..1f4048bf2674 100644 --- a/include/linux/ras.h +++ b/include/linux/ras.h @@ -17,12 +17,7 @@ static inline int ras_add_daemon_trace(void) { return 0; } #endif #ifdef CONFIG_RAS_CEC -void __init cec_init(void); int __init parse_cec_param(char *str); -int cec_add_elem(u64 pfn); -#else -static inline void __init cec_init(void) { } -static inline int cec_add_elem(u64 pfn) { return -ENODEV; } #endif #ifdef CONFIG_RAS -- 2.21.0