Skip to contentSkip to conversation

x86/MCE/AMD: Always give panic severity for UC errors in kernel context

PATCH New Borislav Petkov 2 participants 4 messages Nov 6, 2017 – Nov 7, 2017

Subsystems (2)
lore
Share & tools
lore

Borislav Petkov

author maintainer
#0 lore raw

PATCH 1/2 x86/MCE/AMD: Always give panic severity for UC errors in kernel context

From: Yazen Ghannam <[email protected]>

The AMD severity grading function was introduced in kernel 4.1. The current logic can possibly give MCE_AR_SEVERITY for uncorrectable errors in kernel context. The system may then get stuck in a loop as memory_failure() will try to handle the bad kernel memory and find it busy.

Return MCE_PANIC_SEVERITY for all UC errors IN_KERNEL context on AMD systems.

After:

b2f9d678e28c ("x86/mce: Check for faults tagged in EXTABLE_CLASS_FAULT exception table entries")

was accepted in v4.6, this issue was masked because of the tail-end attempt at kernel mode recovery in the #MC handler.

However, uncorrectable errors IN_KERNEL context should always be considered unrecoverable and cause a panic.

Cc Tony Luck <[email protected]>
Cc linux-edac <[email protected]>
Cc x86-ml <[email protected]>
Fixes bf80bbd7dcf5 (x86/mce: Add an AMD severities-grading function)
Cc <[email protected]> # 4.9.x
---
 arch/x86/kernel/cpu/mcheck/mce-severity.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/mcheck/mce-severity.c +3 -4
index 87cc9ab7a13c..4b8187639c2d 100644
@@ -245,6 +245,9 @@ static int mce_severity_amd(struct mce *m, int tolerant, char **msg, bool is_exc
 
 	if (m->status & MCI_STATUS_UC) {
 
+		if (ctx == IN_KERNEL)
+			return MCE_PANIC_SEVERITY;
+
 		/*
 		 * On older systems where overflow_recov flag is not present, we
 		 * should simply panic if an error overflow occurs. If
@@ -255,10 +258,6 @@ static int mce_severity_amd(struct mce *m, int tolerant, char **msg, bool is_exc
 			if (mce_flags.smca)
 				return mce_severity_amd_smca(m, ctx);
 
-			/* software can try to contain */
-			if (!(m->mcgstatus & MCG_STATUS_RIPV) && (ctx == IN_KERNEL))
-				return MCE_PANIC_SEVERITY;
-
 			/* kill current process */
 			return MCE_AR_SEVERITY;
 		} else {
Signature · 1 line
2.13.0
author maintainer
#1 lore raw

PATCH 2/2 x86/MCE/AMD: Fix mce_severity_amd_smca() signature

From: Yazen Ghannam <[email protected]>

Change the err_ctx type to "enum context" to match the type passed in.

No functionality change.

---
 arch/x86/kernel/cpu/mcheck/mce-severity.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/mcheck/mce-severity.c +1 -1
index 4b8187639c2d..4ca632a06e0b 100644
@@ -204,7 +204,7 @@ static int error_context(struct mce *m)
 	return IN_KERNEL;
 }
 
-static int mce_severity_amd_smca(struct mce *m, int err_ctx)
+static int mce_severity_amd_smca(struct mce *m, enum context err_ctx)
 {
 	u32 addr = MSR_AMD64_SMCA_MCx_CONFIG(m->bank);
 	u32 low, high;
Signature · 1 line
2.13.0
#2 lore raw

[tip:ras/core] x86/MCE/AMD: Fix mce_severity_amd_smca() signature

x86/MCE/AMD: Fix mce_severity_amd_smca() signature
Commit-ID:  783ca517bfd62ca516178712775e4b273292d5b1
Gitweb:     https://git.kernel.org/tip/783ca517bfd62ca516178712775e4b273292d5b1
Author:     Yazen Ghannam <[email protected]>
AuthorDate: Mon, 6 Nov 2017 18:46:33 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 7 Nov 2017 11:07:50 +0100

x86/MCE/AMD: Fix mce_severity_amd_smca() signature

Change the err_ctx type to "enum context" to match the type passed in.

No functionality change.

---
 arch/x86/kernel/cpu/mcheck/mce-severity.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-edac" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

arch/x86/kernel/cpu/mcheck/mce-severity.c +1 -1
index 4b81876..4ca632a 100644
@@ -204,7 +204,7 @@ static int error_context(struct mce *m)
 	return IN_KERNEL;
 }
 
-static int mce_severity_amd_smca(struct mce *m, int err_ctx)
+static int mce_severity_amd_smca(struct mce *m, enum context err_ctx)
 {
 	u32 addr = MSR_AMD64_SMCA_MCx_CONFIG(m->bank);
 	u32 low, high;
#3 lore raw
In reply to Borislav Petkov
x86/MCE/AMD: Always give panic severity for UC errors in kernel context
Commit-ID:  d65dfc81bb3894fdb68cbc74bbf5fb48d2354071
Gitweb:     https://git.kernel.org/tip/d65dfc81bb3894fdb68cbc74bbf5fb48d2354071
Author:     Yazen Ghannam <[email protected]>
AuthorDate: Mon, 6 Nov 2017 18:46:32 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 7 Nov 2017 11:07:50 +0100

x86/MCE/AMD: Always give panic severity for UC errors in kernel context

The AMD severity grading function was introduced in kernel 4.1. The current logic can possibly give MCE_AR_SEVERITY for uncorrectable errors in kernel context. The system may then get stuck in a loop as memory_failure() will try to handle the bad kernel memory and find it busy.

Return MCE_PANIC_SEVERITY for all UC errors IN_KERNEL context on AMD systems.

After:

b2f9d678e28c ("x86/mce: Check for faults tagged in EXTABLE_CLASS_FAULT exception table entries")

was accepted in v4.6, this issue was masked because of the tail-end attempt at kernel mode recovery in the #MC handler.

However, uncorrectable errors IN_KERNEL context should always be considered unrecoverable and cause a panic.

Cc <[email protected]> # 4.9.x
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Tony Luck <[email protected]>
Cc linux-edac <[email protected]>
Fixes bf80bbd7dcf5 (x86/mce: Add an AMD severities-grading function)
---
 arch/x86/kernel/cpu/mcheck/mce-severity.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-edac" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

arch/x86/kernel/cpu/mcheck/mce-severity.c +3 -4
index 87cc9ab..4b81876 100644
@@ -245,6 +245,9 @@ static int mce_severity_amd(struct mce *m, int tolerant, char **msg, bool is_exc
 
 	if (m->status & MCI_STATUS_UC) {
 
+		if (ctx == IN_KERNEL)
+			return MCE_PANIC_SEVERITY;
+
 		/*
 		 * On older systems where overflow_recov flag is not present, we
 		 * should simply panic if an error overflow occurs. If
@@ -255,10 +258,6 @@ static int mce_severity_amd(struct mce *m, int tolerant, char **msg, bool is_exc
 			if (mce_flags.smca)
 				return mce_severity_amd_smca(m, ctx);
 
-			/* software can try to contain */
-			if (!(m->mcgstatus & MCG_STATUS_RIPV) && (ctx == IN_KERNEL))
-				return MCE_PANIC_SEVERITY;
-
 			/* kill current process */
 			return MCE_AR_SEVERITY;
 		} else {