lkml.org 
[lkml]   [2022]   [Mar]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/2] x86/mce: Add messages to describe panic machine errors on AMD's MCEs grading
Date
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
\
 
 \ /
  Last update: 2022-03-11 17:53    [W:0.043 / U:1.320 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site