[<prev] [next>] [day] [month] [year] [list]
Message-ID: <169627334714.3135.12336854585078188172.tip-bot2@tip-bot2>
Date: Mon, 02 Oct 2023 19:02:27 -0000
From: "tip-bot2 for Zhiquan Li" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Youquan Song <youquan.song@...el.com>,
Zhiquan Li <zhiquan1.li@...el.com>,
Tony Luck <tony.luck@...el.com>,
Ingo Molnar <mingo@...nel.org>,
Naoya Horiguchi <naoya.horiguchi@....com>,
Borislav Petkov <bp@...en8.de>, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: [tip: x86/mm] x86/mce: Set PG_hwpoison page flag to avoid the capture
kernel panic
The following commit has been merged into the x86/mm branch of tip:
Commit-ID: cb17fd1dcdaea8f6508844c690b3ffd5da484800
Gitweb: https://git.kernel.org/tip/cb17fd1dcdaea8f6508844c690b3ffd5da484800
Author: Zhiquan Li <zhiquan1.li@...el.com>
AuthorDate: Thu, 14 Sep 2023 11:05:39 +08:00
Committer: Ingo Molnar <mingo@...nel.org>
CommitterDate: Mon, 02 Oct 2023 20:26:13 +02:00
x86/mce: Set PG_hwpoison page flag to avoid the capture kernel panic
Kdump can exclude the HWPoison page to avoid touching the error page
again, the prerequisite is the PG_hwpoison page flag is set.
However, for some MCE fatal error cases, there is no opportunity
to queue a task for calling memory_failure(), and as a result,
the capture kernel touches the error page again and panics.
Add the mce_set_page_hwpoison_now() function, which marks a page as
HWPoison before kernel panic() for MCE error, so that the dump
program can check and skip the error page and prevent the capture
kernel panic.
[ Tony: Changed TestSetPageHWPoison() to SetPageHWPoison() ]
[ mingo: Fixed the comments & changelog ]
Co-developed-by: Youquan Song <youquan.song@...el.com>
Signed-off-by: Youquan Song <youquan.song@...el.com>
Signed-off-by: Zhiquan Li <zhiquan1.li@...el.com>
Signed-off-by: Tony Luck <tony.luck@...el.com>
Signed-off-by: Ingo Molnar <mingo@...nel.org>
Reviewed-by: Naoya Horiguchi <naoya.horiguchi@....com>
Cc: Borislav Petkov <bp@...en8.de>
Link: https://lore.kernel.org/all/20230719211625.298785-1-tony.luck@intel.com/#t
---
arch/x86/kernel/cpu/mce/core.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c
index 6f35f72..1a14e82 100644
--- a/arch/x86/kernel/cpu/mce/core.c
+++ b/arch/x86/kernel/cpu/mce/core.c
@@ -156,6 +156,22 @@ void mce_unregister_decode_chain(struct notifier_block *nb)
}
EXPORT_SYMBOL_GPL(mce_unregister_decode_chain);
+/*
+ * Kdump can exclude the HWPoison page to avoid touching the error page again,
+ * the prerequisite is that the PG_hwpoison page flag is set. However, for some
+ * MCE fatal error cases, there is no opportunity to queue a task
+ * for calling memory_failure(), and as a result, the capture kernel panics.
+ * This function marks the page as HWPoison before kernel panic() for MCE.
+ */
+static void mce_set_page_hwpoison_now(unsigned long pfn)
+{
+ struct page *p;
+
+ p = pfn_to_online_page(pfn);
+ if (p)
+ SetPageHWPoison(p);
+}
+
static void __print_mce(struct mce *m)
{
pr_emerg(HW_ERR "CPU %d: Machine Check%s: %Lx Bank %d: %016Lx\n",
@@ -286,6 +302,8 @@ static noinstr void mce_panic(const char *msg, struct mce *final, char *exp)
if (!fake_panic) {
if (panic_timeout == 0)
panic_timeout = mca_cfg.panic_timeout;
+ if (final && (final->status & MCI_STATUS_ADDRV))
+ mce_set_page_hwpoison_now(final->addr >> PAGE_SHIFT);
panic(msg);
} else
pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg);
Powered by blists - more mailing lists