Skip to contentSkip to conversation

x86/mce/AMD: Make sure banks were initialized before accessing them

DISCUSSION Borislav Petkov 1 participant 1 message Dec 18, 2018 EDAC-core

lore
Share & tools
lore

Borislav Petkov

author maintainer
#0 lore raw
Quoted 4 lines · Borislav Petkov

That script could be placed in Documentation/x86/ or so, so that people can decode such early errors.

I'll write up something soonish.

Here's something below. You do:

dmesg | mce-to-inj.py

when dmesg contains the MCE. It should output something like this:

echo 4 > /sys/kernel/debug/mce-inject/cpu
echo 0xd8200000000a0151 > /sys/kernel/debug/mce-inject/status echo 0xd01b0fff00000000 > /sys/kernel/debug/mce-inject/misc echo 0x4a000000 > /sys/kernel/debug/mce-inject/synd echo sw > /sys/kernel/debug/mce-inject/flags
echo 1 > /sys/kernel/debug/mce-inject/bank

For that you need the injection module loaded, i.e.,

CONFIG_X86_MCE_INJECT=m

and modprobe mce-inject

Also, the assumption is that debugfs is mounted on the default /sys/kernel/debug mountpoint.

So when you run those lines above as root, you should see the decoded error in dmesg, i.e., this thing:

[    1.079789] [Hardware Error]: Corrected error, no action required.
[    1.079789] [Hardware Error]: CPU:4 (17:11:0) MC1_STATUS[Over|CE|MiscV|-|-|-|-|SyndV|-]: 0xd8200000000a0151
[    1.079789] [Hardware Error]: IPID: 0x000100b000000000, Syndrome: 0x000000004a000000
[    1.079789] [Hardware Error]: Instruction Fetch Unit Extended Error Code: 10
[    1.079789] [Hardware Error]: Instruction Fetch Unit Error: L1 BTB multi-match error.
[    1.079789] [Hardware Error]: cache level: L1, tx: INSN, mem-tx: IRD

HTH.
---
#!/usr/bin/python

import re
import sys

bank = 0

for line in sys.stdin:

    m = re.match(r'^.*mce:.*CPU (?P<cpu>\d+): Machine Check.*Bank (?P<bank>\d+): (?P<status>[0-9a-f]+)', line)
    if m:
        bank = m.group('bank')
        print ("echo %s > /sys/kernel/debug/mce-inject/cpu" % (m.group('cpu'), ))
        print ("echo 0x%s > /sys/kernel/debug/mce-inject/status" % (m.group('status'), ))
        continue

    m =re.match(r'^.*mce:.*MISC (?P<misc>[0-9a-f]+)', line)
    if m:
        print ("echo 0x%s > /sys/kernel/debug/mce-inject/misc" % (m.group('misc'), ))

    m =re.match(r'^.*mce:.*SYND (?P<synd>[0-9a-f]+)', line)
    if m:
        print ("echo 0x%s > /sys/kernel/debug/mce-inject/synd" % (m.group('synd'), ))

    # last line in the stanza
    m = re.match(r'^.*mce:.*PROCESSOR.*TIME.*SOCKET.*APIC.*microcode', line)
    if m:
        print ("echo sw > /sys/kernel/debug/mce-inject/flags")
        print ("echo %s > /sys/kernel/debug/mce-inject/bank\n" % (bank, ))