Skip to contentSkip to conversation

mcelog: Fix "--ascii" parsing to cope with change in kernel output since v4.10

PATCH Luck, Tony 1 participant 1 message May 22, 2018 EDAC-core

lore
Share & tools
lore

Luck, Tony

author maintainer
#0 lore raw

Linux kernel now includes this change:

commit cd9c57cad3fe ("x86/MCE: Dump MCE to dmesg if no consumers")

which has this fragment:

- pr_emerg(HW_ERR "CPU %d: Machine Check Exception: %Lx Bank %d: %016Lx\n",
- m->extcpu, m->mcgstatus, m->bank, m->status);
+ pr_emerg(HW_ERR "CPU %d: Machine Check%s: %Lx Bank %d: %016Lx\n",

+                m->extcpu,
+                (m->mcgstatus & MCG_STATUS_MCIP ? " Exception" : ""),
+                m->mcgstatus, m->bank, m->status);

that switched from always printing the word "Exception" to only doing so for errors that were logged during aan exception (i.e. when IA32_MSR_MCG_STATUS.MCIP is set to one). This is helpful to human readers of console logs to distinguish between errors that caused machine checks from errors that were found later polling machine check banks. But it broke the "--ascii" parsing code in mcelog(8) :-(

The change went upstream 15 months ago in v4.10. So the horse has left the stable and is over the hills and far away.

Fix the parsing code to treat the word "Exception" as optional.

---
 mcelog.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mcelog.c +1 -1
index 8c09665810ba..2d46afbf9a41 100644
@@ -719,7 +719,7 @@ restart:
 		if (!strncmp(s, "CPU ", 4)) { 
 			unsigned cpu = 0, bank = 0;
 			n = sscanf(s,
-	       "CPU %u: Machine Check Exception: %16Lx Bank %d: %016Lx%n",
+	       "CPU %u: Machine Check%*[ :Ec-x]%16Lx Bank %d: %016Lx%n",
 				   &cpu,
 				   &m.mcgstatus,
 				   &bank,