From: "tip-bot2 for Zhiquan Li" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Youquan Song <youquan.song@intel.com>,
Zhiquan Li <zhiquan1.li@intel.com>,
"Borislav Petkov (AMD)" <bp@alien8.de>,
Naoya Horiguchi <naoya.horiguchi@nec.com>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: ras/core] x86/mce: Mark fatal MCE's page as poison to avoid panic in the kdump kernel
Date: Mon, 13 Nov 2023 09:11:50 -0000 [thread overview]
Message-ID: <169986671058.3135.14638395012955463403.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20231014051754.3759099-1-zhiquan1.li@intel.com>
The following commit has been merged into the ras/core branch of tip:
Commit-ID: 9f3b130048bfa2e44a8cfb1b616f826d9d5d8188
Gitweb: https://git.kernel.org/tip/9f3b130048bfa2e44a8cfb1b616f826d9d5d8188
Author: Zhiquan Li <zhiquan1.li@intel.com>
AuthorDate: Thu, 26 Oct 2023 08:39:03 +08:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Mon, 13 Nov 2023 09:53:15 +01:00
x86/mce: Mark fatal MCE's page as poison to avoid panic in the kdump kernel
Memory errors don't happen very often, especially fatal ones. However,
in large-scale scenarios such as data centers, that probability
increases with the amount of machines present.
When a fatal machine check happens, mce_panic() is called based on the
severity grading of that error. The page containing the error is not
marked as poison.
However, when kexec is enabled, tools like makedumpfile understand when
pages are marked as poison and do not touch them so as not to cause
a fatal machine check exception again while dumping the previous
kernel's memory.
Therefore, mark the page containing the error as poisoned so that the
kexec'ed kernel can avoid accessing the page.
[ bp: Rewrite commit message and comment. ]
Co-developed-by: Youquan Song <youquan.song@intel.com>
Signed-off-by: Youquan Song <youquan.song@intel.com>
Signed-off-by: Zhiquan Li <zhiquan1.li@intel.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
Link: https://lore.kernel.org/r/20231014051754.3759099-1-zhiquan1.li@intel.com
---
arch/x86/kernel/cpu/mce/core.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c
index 7b39737..df8d25e 100644
--- a/arch/x86/kernel/cpu/mce/core.c
+++ b/arch/x86/kernel/cpu/mce/core.c
@@ -44,6 +44,7 @@
#include <linux/sync_core.h>
#include <linux/task_work.h>
#include <linux/hardirq.h>
+#include <linux/kexec.h>
#include <asm/intel-family.h>
#include <asm/processor.h>
@@ -233,6 +234,7 @@ static noinstr void mce_panic(const char *msg, struct mce *final, char *exp)
struct llist_node *pending;
struct mce_evt_llist *l;
int apei_err = 0;
+ struct page *p;
/*
* Allow instrumentation around external facilities usage. Not that it
@@ -286,6 +288,20 @@ 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;
+
+ /*
+ * Kdump skips the poisoned page in order to avoid
+ * touching the error bits again. Poison the page even
+ * if the error is fatal and the machine is about to
+ * panic.
+ */
+ if (kexec_crash_loaded()) {
+ if (final && (final->status & MCI_STATUS_ADDRV)) {
+ p = pfn_to_online_page(final->addr >> PAGE_SHIFT);
+ if (p)
+ SetPageHWPoison(p);
+ }
+ }
panic(msg);
} else
pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg);
prev parent reply other threads:[~2023-11-13 9:11 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-14 5:17 [PATCH v3] x86/mce: Set PG_hwpoison page flag to avoid the capture kernel panic Zhiquan Li
2023-10-14 5:12 ` Luck, Tony
2023-10-14 9:34 ` Zhiquan Li
2023-10-14 10:18 ` Borislav Petkov
2023-10-17 1:39 ` Zhiquan Li
2023-10-16 9:11 ` Borislav Petkov
2023-10-17 1:05 ` Zhiquan Li
2023-10-17 1:24 ` Luck, Tony
2023-10-17 11:18 ` Borislav Petkov
2023-10-17 15:00 ` Zhiquan Li
2023-10-17 17:35 ` Luck, Tony
2023-10-23 12:55 ` [tip: ras/core] x86/mce: Mark fatal MCE's page as poison to avoid panic in the kdump kernel tip-bot2 for Zhiquan Li
2023-11-13 9:11 ` tip-bot2 for Zhiquan Li [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=169986671058.3135.14638395012955463403.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=bp@alien8.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=naoya.horiguchi@nec.com \
--cc=x86@kernel.org \
--cc=youquan.song@intel.com \
--cc=zhiquan1.li@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®