From: Carlos Bilbao <carlos.bilbao@amd.com>
To: <bp@alien8.de>
Cc: <tglx@linutronix.de>, <mingo@redhat.com>,
<dave.hansen@linux.intel.com>, <x86@kernel.org>,
<yazen.ghannam@amd.com>, <linux-kernel@vger.kernel.org>,
<linux-edac@vger.kernel.org>, <bilbao@vt.edu>,
Carlos Bilbao <carlos.bilbao@amd.com>
Subject: [PATCH 2/2] x86/mce: Add messages to describe panic machine errors on AMD's MCEs grading
Date: Fri, 11 Mar 2022 10:51:17 -0600 [thread overview]
Message-ID: <20220311165114.482074-3-carlos.bilbao@amd.com> (raw)
In-Reply-To: <20220311165114.482074-1-carlos.bilbao@amd.com>
When a machine error is graded as PANIC by AMD grading logic, the MCE
handler calls mce_panic(). The notification chain does not come into effect
so the AMD EDAC driver does not decode the errors. In these cases, the
messages displayed to the user are more cryptic and miss information
that might be relevant, like the context in which the error took place.
Fix the above issue including messages on AMD's grading logic for machine
errors graded as PANIC.
Signed-off-by: Carlos Bilbao <carlos.bilbao@amd.com>
---
arch/x86/kernel/cpu/mce/severity.c | 33 ++++++++++++++++++++++++++----
1 file changed, 29 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/cpu/mce/severity.c b/arch/x86/kernel/cpu/mce/severity.c
index 4a089e9dbbaf..11be63eaf7e5 100644
--- a/arch/x86/kernel/cpu/mce/severity.c
+++ b/arch/x86/kernel/cpu/mce/severity.c
@@ -330,10 +330,12 @@ static __always_inline int mce_severity_amd_smca(struct mce *m, enum context err
* Evaluate the severity of an overflow error for AMD systems, dependent on
* the recoverable features available.
*/
-static noinstr int mce_grade_overflow_amd(struct mce *m, enum context ctx)
+static noinstr int mce_grade_overflow_amd(struct mce *m, enum context ctx, char **msg)
{
int ret;
+ WARN_ON(!msg);
+
/*
* On older systems where overflow_recov flag is not present, we
* should simply panic if an error overflow occurs. If
@@ -343,6 +345,8 @@ static noinstr int mce_grade_overflow_amd(struct mce *m, enum context ctx)
if (mce_flags.overflow_recov) {
if (mce_flags.smca) {
ret = mce_severity_amd_smca(m, ctx);
+ if (ret == MCE_PANIC_SEVERITY)
+ *msg = "Uncorrected unrecoverable error";
} else {
/* kill current process */
ret = MCE_AR_SEVERITY;
@@ -351,8 +355,10 @@ static noinstr int mce_grade_overflow_amd(struct mce *m, enum context ctx)
}
/* at least one error was not logged */
- if (m->status & MCI_STATUS_OVER)
+ if (m->status & MCI_STATUS_OVER) {
+ *msg = "Overflow uncorrected";
return MCE_PANIC_SEVERITY;
+ }
/*
* For any other case, return MCE_UC_SEVERITY so that we log the
@@ -367,6 +373,7 @@ static noinstr int mce_grade_overflow_amd(struct mce *m, enum context ctx)
static noinstr int mce_severity_amd(struct mce *m, struct pt_regs *regs, char **msg, bool is_excp)
{
enum context ctx = error_context(m, regs);
+ char *severity_msg;
int ret;
/*
@@ -411,13 +418,16 @@ static noinstr int mce_severity_amd(struct mce *m, struct pt_regs *regs, char **
#ifdef CONFIG_MEMORY_FAILURE
ret = MCE_AR_SEVERITY;
#else
+ severity_msg = "Consumed poisoned data in kernel recoverable area";
ret = MCE_PANIC_SEVERITY;
#endif
break;
case IN_KERNEL:
+ severity_msg = "Attempt to consume poisoned data in kernel context";
ret = MCE_PANIC_SEVERITY;
break;
default:
+ severity_msg = "Attempt to consume poisoned data in unknown context";
ret = MCE_PANIC_SEVERITY;
}
@@ -426,6 +436,7 @@ static noinstr int mce_severity_amd(struct mce *m, struct pt_regs *regs, char **
/* Processor Context Corrupt, no need to fumble too much, die! */
if (m->status & MCI_STATUS_PCC) {
+ severity_msg = "Processor Context Corrupt";
ret = MCE_PANIC_SEVERITY;
goto amd_severity;
}
@@ -441,9 +452,11 @@ static noinstr int mce_severity_amd(struct mce *m, struct pt_regs *regs, char **
ret = MCE_AR_SEVERITY;
break;
case IN_KERNEL:
+ severity_msg = "Data load error in unrecoverable kernel context";
ret = MCE_PANIC_SEVERITY;
break;
default:
+ severity_msg = "Data load error in unknown context";
ret = MCE_PANIC_SEVERITY;
}
@@ -464,13 +477,16 @@ static noinstr int mce_severity_amd(struct mce *m, struct pt_regs *regs, char **
#ifdef CONFIG_MEMORY_FAILURE
ret = MCE_AR_SEVERITY;
#else
+ severity_msg = "Instruction fetch error in kernel recoverable area";
ret = MCE_PANIC_SEVERITY;
#endif
break;
case IN_KERNEL:
+ severity_msg = "Instruction fetch error in kernel context";
ret = MCE_PANIC_SEVERITY;
break;
default:
+ severity_msg = "Instruction fetch error in unknown context";
ret = MCE_PANIC_SEVERITY;
}
@@ -478,15 +494,24 @@ static noinstr int mce_severity_amd(struct mce *m, struct pt_regs *regs, char **
}
if (m->status & MCI_STATUS_OVER) {
- ret = mce_grade_overflow_amd(m, ctx);
+ ret = mce_grade_overflow_amd(m, ctx, &severity_msg);
goto amd_severity;
}
- if (ctx == IN_KERNEL)
+ if (ctx == IN_KERNEL) {
+ severity_msg = "Uncorrectable error in kernel context";
ret = MCE_PANIC_SEVERITY;
+ }
amd_severity:
+ /*
+ * It only makes sense to provide a message on panic scenarios,
+ * as otherwise EDAC will be notified and conduct the decoding.
+ */
+ if (msg && ret == MCE_PANIC_SEVERITY)
+ *msg = severity_msg;
+
return ret;
}
--
2.27.0
next prev parent reply other threads:[~2022-03-11 16:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-11 16:51 [PATCH 0/2] x86/mce: Grade new machine errors for AMD MCEs and include messages for panic cases Carlos Bilbao
2022-03-11 16:51 ` [PATCH 1/2] x86/mce: Extend AMD severity grading function with new types of errors Carlos Bilbao
2022-03-11 16:51 ` Carlos Bilbao [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-03-28 13:41 [PATCH 0/2] x86/mce: Grade new machine errors for AMD MCEs and include messages for panic cases Carlos Bilbao
2022-03-28 13:41 ` [PATCH 2/2] x86/mce: Add messages to describe panic machine errors on AMD's MCEs grading Carlos Bilbao
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=20220311165114.482074-3-carlos.bilbao@amd.com \
--to=carlos.bilbao@amd.com \
--cc=bilbao@vt.edu \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=yazen.ghannam@amd.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