Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1839751pxb; Mon, 13 Sep 2021 06:41:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxr+VQV7Ly+FeK5fDOy1nf9p0ZnGGhCwEkIXPnTEn20AtLxpn8Aksh88Y3rUn/sr7pz5OaZ X-Received: by 2002:a6b:3f08:: with SMTP id m8mr9128852ioa.117.1631540508157; Mon, 13 Sep 2021 06:41:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631540508; cv=none; d=google.com; s=arc-20160816; b=jA4qhZAsONId4Eyi8nOq5vfZwNITHbP+TnLpwWSDOCmcqRZEdnOMHa+G2+p5AO+mND Q7+3iWGsDCSR74NfCdkKTX9rn1KiTCcGJTcPpmH/huRTuflpyiQRWTSkgdN1Skjxs0gw YoLCTl/fOYQB9sFo9/Zjr/9IcRj0L9yCW7fELk6PivR4nsu6SoR3lIUz4deAFeQTQMeW bQdqcMKLdiQItZctBZKlcvcrmWJbkQ3EsVR7y2hwrUkz2Sv79dIXk/I+eEWnGStLYunV WEHWYRQB/yb/RaoHoj/uszFN/8miBikdH8mD12EqSfoFHBd4sz0NZMqNpFvjxLuYPO2Y nsFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lZ3qqSeCdP4UD4ehKCaja6mGUjHVHizMJTkYz8ZnlLs=; b=Tj99H9A3riuhDKBbNNNwZx1kmhZW0U7LduLrzSsVzgc0eUDAZcpKmvN4+oUl0dkVDa f8C+XX9FJQcE9+TKtmaC0s3PhlsOTTBoDAal+oE+I+IyTVsVMf+yuzj7C/xUg228YKwg 5zjLx90u6nVM7YySIczTvQtha5W2k8E8XEuc876se+nFtDpaKwEj8laQjiJYsW4nccZv Y+uTARVxx4dWhWj81w5IltKKbTwNaqR1ToNzWL+a59ob9cM00ukfiw5hMFLb0Z6MA/gJ 46u14nCU5PEuFYVGDoLeRS9Jy0FInPGbnDAwQS5pC+ZhNzMGbcikQBcKaY1LvTiBDN9w o5oQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QfVl2bur; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z16si6529864ill.147.2021.09.13.06.41.36; Mon, 13 Sep 2021 06:41:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QfVl2bur; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240160AbhIMNl2 (ORCPT + 99 others); Mon, 13 Sep 2021 09:41:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:32892 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242005AbhIMNgR (ORCPT ); Mon, 13 Sep 2021 09:36:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7D13C61373; Mon, 13 Sep 2021 13:27:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631539645; bh=Dj0oXM8LCAxqhjKn3UcUE+1OU4mFu/cC0JVlL2RvwQo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QfVl2burSAA43WNdZKm8fVkmJjl0Bxbu3BYv7T2WhkSKasSZgKptodD/QIfEDFNsm 2Hitxj9xHRVm6Dx3HoryedkkO1QMYUhzqjA4Kp7y/Ar/V0atomcGwtajX2dCfxBb9w nMTLYoFPxA0W3pq/N688vfM2j9UgR6M9NS/VbP8c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sumanth Kamatala , Borislav Petkov , Tony Luck , Sasha Levin Subject: [PATCH 5.10 061/236] x86/mce: Defer processing of early errors Date: Mon, 13 Sep 2021 15:12:46 +0200 Message-Id: <20210913131102.444635157@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131100.316353015@linuxfoundation.org> References: <20210913131100.316353015@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Borislav Petkov [ Upstream commit 3bff147b187d5dfccfca1ee231b0761a89f1eff5 ] When a fatal machine check results in a system reset, Linux does not clear the error(s) from machine check bank(s) - hardware preserves the machine check banks across a warm reset. During initialization of the kernel after the reboot, Linux reads, logs, and clears all machine check banks. But there is a problem. In: 5de97c9f6d85 ("x86/mce: Factor out and deprecate the /dev/mcelog driver") the call to mce_register_decode_chain() moved later in the boot sequence. This means that /dev/mcelog doesn't see those early error logs. This was partially fixed by: cd9c57cad3fe ("x86/MCE: Dump MCE to dmesg if no consumers") which made sure that the logs were not lost completely by printing to the console. But parsing console logs is error prone. Users of /dev/mcelog should expect to find any early errors logged to standard places. Add a new flag MCP_QUEUE_LOG to machine_check_poll() to be used in early machine check initialization to indicate that any errors found should just be queued to genpool. When mcheck_late_init() is called it will call mce_schedule_work() to actually log and flush any errors queued in the genpool. [ Based on an original patch, commit message by and completely productized by Tony Luck. ] Fixes: 5de97c9f6d85 ("x86/mce: Factor out and deprecate the /dev/mcelog driver") Reported-by: Sumanth Kamatala Signed-off-by: Borislav Petkov Signed-off-by: Tony Luck Signed-off-by: Borislav Petkov Link: https://lkml.kernel.org/r/20210824003129.GA1642753@agluck-desk2.amr.corp.intel.com Signed-off-by: Sasha Levin --- arch/x86/include/asm/mce.h | 1 + arch/x86/kernel/cpu/mce/core.c | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h index fc25c88c7ff2..9b5ff423e939 100644 --- a/arch/x86/include/asm/mce.h +++ b/arch/x86/include/asm/mce.h @@ -259,6 +259,7 @@ enum mcp_flags { MCP_TIMESTAMP = BIT(0), /* log time stamp */ MCP_UC = BIT(1), /* log uncorrected errors */ MCP_DONTLOG = BIT(2), /* only clear, don't log */ + MCP_QUEUE_LOG = BIT(3), /* only queue to genpool */ }; bool machine_check_poll(enum mcp_flags flags, mce_banks_t *b); diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index b7a27589dfa0..056d0367864e 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -817,7 +817,10 @@ log_it: if (mca_cfg.dont_log_ce && !mce_usable_address(&m)) goto clear_it; - mce_log(&m); + if (flags & MCP_QUEUE_LOG) + mce_gen_pool_add(&m); + else + mce_log(&m); clear_it: /* @@ -1628,10 +1631,12 @@ static void __mcheck_cpu_init_generic(void) m_fl = MCP_DONTLOG; /* - * Log the machine checks left over from the previous reset. + * Log the machine checks left over from the previous reset. Log them + * only, do not start processing them. That will happen in mcheck_late_init() + * when all consumers have been registered on the notifier chain. */ bitmap_fill(all_banks, MAX_NR_BANKS); - machine_check_poll(MCP_UC | m_fl, &all_banks); + machine_check_poll(MCP_UC | MCP_QUEUE_LOG | m_fl, &all_banks); cr4_set_bits(X86_CR4_MCE); -- 2.30.2