* [PATCH 1/2] x86/mce: Simplify AMD severity grading logic
2022-04-05 18:32 [PATCH 0/2] x86/mce: Simplify AMD MCEs severity grading and include messages for panic cases Carlos Bilbao
@ 2022-04-05 18:32 ` Carlos Bilbao
2022-04-10 13:04 ` Yazen Ghannam
2022-04-05 18:32 ` [PATCH 2/2] x86/mce: Add messages for panic errors in AMD's MCE grading Carlos Bilbao
1 sibling, 1 reply; 5+ messages in thread
From: Carlos Bilbao @ 2022-04-05 18:32 UTC (permalink / raw)
To: bp, yazen.ghannam
Cc: tglx, mingo, dave.hansen, x86, linux-kernel, linux-edac, bilbao,
Carlos Bilbao
The MCE handler needs to understand the severity of the machine errors to
act accordingly. Simplify the AMD grading logic following a logic that
closely resembles the descriptions of the public PPR documents. This will
help include more fine-grained grading of errors in the future.
Signed-off-by: Carlos Bilbao <carlos.bilbao@amd.com>
---
arch/x86/kernel/cpu/mce/severity.c | 104 +++++++++++------------------
1 file changed, 39 insertions(+), 65 deletions(-)
diff --git a/arch/x86/kernel/cpu/mce/severity.c b/arch/x86/kernel/cpu/mce/severity.c
index 1add86935349..25aec5a27899 100644
--- a/arch/x86/kernel/cpu/mce/severity.c
+++ b/arch/x86/kernel/cpu/mce/severity.c
@@ -301,85 +301,59 @@ static noinstr int error_context(struct mce *m, struct pt_regs *regs)
}
}
-static __always_inline int mce_severity_amd_smca(struct mce *m, enum context err_ctx)
-{
- u64 mcx_cfg;
-
- /*
- * We need to look at the following bits:
- * - "succor" bit (data poisoning support), and
- * - TCC bit (Task Context Corrupt)
- * in MCi_STATUS to determine error severity.
- */
- if (!mce_flags.succor)
- return MCE_PANIC_SEVERITY;
-
- mcx_cfg = mce_rdmsrl(MSR_AMD64_SMCA_MCx_CONFIG(m->bank));
-
- /* TCC (Task context corrupt). If set and if IN_KERNEL, panic. */
- if ((mcx_cfg & MCI_CONFIG_MCAX) &&
- (m->status & MCI_STATUS_TCC) &&
- (err_ctx == IN_KERNEL))
- return MCE_PANIC_SEVERITY;
-
- /* ...otherwise invoke hwpoison handler. */
- return MCE_AR_SEVERITY;
-}
-
/*
- * See AMD Error Scope Hierarchy table in a newer BKDG. For example
- * 49125_15h_Models_30h-3Fh_BKDG.pdf, section "RAS Features"
+ * See AMD PPR(s) section Machine Check Error Handling
*/
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);
-
- /* Processor Context Corrupt, no need to fumble too much, die! */
- if (m->status & MCI_STATUS_PCC)
- return MCE_PANIC_SEVERITY;
+ int ret;
- if (m->status & MCI_STATUS_UC) {
+ /*
+ * Default return value: Action required, the error must be handled
+ * immediately.
+ */
+ ret = MCE_AR_SEVERITY;
- if (ctx == IN_KERNEL)
- return MCE_PANIC_SEVERITY;
+ /* Processor Context Corrupt, no need to fumble too much, die! */
+ if (m->status & MCI_STATUS_PCC) {
+ ret = MCE_PANIC_SEVERITY;
+ goto out_amd_severity;
+ }
- /*
- * On older systems where overflow_recov flag is not present, we
- * should simply panic if an error overflow occurs. If
- * overflow_recov flag is present and set, then software can try
- * to at least kill process to prolong system operation.
- */
- if (mce_flags.overflow_recov) {
- if (mce_flags.smca)
- return mce_severity_amd_smca(m, ctx);
-
- /* kill current process */
- return MCE_AR_SEVERITY;
- } else {
- /* at least one error was not logged */
- if (m->status & MCI_STATUS_OVER)
- return MCE_PANIC_SEVERITY;
- }
-
- /*
- * For any other case, return MCE_UC_SEVERITY so that we log the
- * error and exit #MC handler.
- */
- return MCE_UC_SEVERITY;
+ if (m->status & MCI_STATUS_DEFERRED) {
+ ret = MCE_DEFERRED_SEVERITY;
+ goto out_amd_severity;
}
/*
- * deferred error: poll handler catches these and adds to mce_ring so
- * memory-failure can take recovery actions.
+ * If the UC bit is not set, the system either corrected or deferred
+ * the error. No action will be required after logging the error.
*/
- if (m->status & MCI_STATUS_DEFERRED)
- return MCE_DEFERRED_SEVERITY;
+ if (!(m->status & MCI_STATUS_UC)) {
+ ret = MCE_KEEP_SEVERITY;
+ goto out_amd_severity;
+ }
/*
- * corrected error: poll handler catches these and passes responsibility
- * of decoding the error to EDAC
+ * On MCA Overflow, without the MCA Overflow recovery feature the
+ * system will not be able to recover.
*/
- return MCE_KEEP_SEVERITY;
+ if ((m->status & MCI_STATUS_OVER) && !mce_flags.overflow_recov) {
+ ret = MCE_PANIC_SEVERITY;
+ goto out_amd_severity;
+ }
+
+ if (!mce_flags.succor) {
+ ret = MCE_PANIC_SEVERITY;
+ goto out_amd_severity;
+ }
+
+ if (error_context(m, regs) == IN_KERNEL)
+ ret = MCE_PANIC_SEVERITY;
+
+out_amd_severity:
+
+ return ret;
}
static noinstr int mce_severity_intel(struct mce *m, struct pt_regs *regs, char **msg, bool is_excp)
--
2.31.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 2/2] x86/mce: Add messages for panic errors in AMD's MCE grading
2022-04-05 18:32 [PATCH 0/2] x86/mce: Simplify AMD MCEs severity grading and include messages for panic cases Carlos Bilbao
2022-04-05 18:32 ` [PATCH 1/2] x86/mce: Simplify AMD severity grading logic Carlos Bilbao
@ 2022-04-05 18:32 ` Carlos Bilbao
2022-04-10 13:06 ` Yazen Ghannam
1 sibling, 1 reply; 5+ messages in thread
From: Carlos Bilbao @ 2022-04-05 18:32 UTC (permalink / raw)
To: bp, yazen.ghannam
Cc: tglx, mingo, dave.hansen, x86, linux-kernel, linux-edac, bilbao,
Carlos Bilbao
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 | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/cpu/mce/severity.c b/arch/x86/kernel/cpu/mce/severity.c
index 25aec5a27899..c09fa4f01616 100644
--- a/arch/x86/kernel/cpu/mce/severity.c
+++ b/arch/x86/kernel/cpu/mce/severity.c
@@ -306,6 +306,7 @@ static noinstr int error_context(struct mce *m, struct pt_regs *regs)
*/
static noinstr int mce_severity_amd(struct mce *m, struct pt_regs *regs, char **msg, bool is_excp)
{
+ char *panic_msg = NULL;
int ret;
/*
@@ -316,6 +317,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) {
+ panic_msg = "Processor Context Corrupt";
ret = MCE_PANIC_SEVERITY;
goto out_amd_severity;
}
@@ -339,20 +341,27 @@ static noinstr int mce_severity_amd(struct mce *m, struct pt_regs *regs, char **
* system will not be able to recover.
*/
if ((m->status & MCI_STATUS_OVER) && !mce_flags.overflow_recov) {
+ panic_msg = "Overflowed uncorrected error without MCA Overflow Recovery";
ret = MCE_PANIC_SEVERITY;
goto out_amd_severity;
}
if (!mce_flags.succor) {
+ panic_msg = "Uncorrected error without MCA Recovery";
ret = MCE_PANIC_SEVERITY;
goto out_amd_severity;
}
- if (error_context(m, regs) == IN_KERNEL)
+ if (error_context(m, regs) == IN_KERNEL) {
+ panic_msg = "Uncorrected unrecoverable error in kernel context";
ret = MCE_PANIC_SEVERITY;
+ }
out_amd_severity:
+ if (msg && panic_msg)
+ *msg = panic_msg;
+
return ret;
}
--
2.31.1
^ permalink raw reply related [flat|nested] 5+ messages in thread