linux-edac.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: "Rafał Miłecki" <rafal@milecki.pl>
Cc: "Rafał Miłecki" <zajec5@gmail.com>,
	"John Clemens" <clemej@gmail.com>,
	"Yazen Ghannam" <Yazen.Ghannam@amd.com>,
	"Tony Luck" <tony.luck@intel.com>,
	linux-edac@vger.kernel.org,
	"Aravind Gopalakrishnan" <aravindksg.lkml@gmail.com>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Ingo Molnar" <mingo@redhat.com>,
	"H . Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org
Subject: x86/mce/AMD: Make sure banks were initialized before accessing them
Date: Tue, 18 Dec 2018 20:05:46 +0100	[thread overview]
Message-ID: <20181218190546.GL7485@zn.tnic> (raw)

On Fri, Nov 30, 2018 at 11:59:42AM +0100, Borislav Petkov wrote:
> 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, ))

             reply	other threads:[~2018-12-18 19:05 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-18 19:05 Borislav Petkov [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-03-16 16:42 x86/mce/AMD: Make sure banks were initialized before accessing them Rafal Milecki
2019-03-07 17:08 Borislav Petkov
2019-03-07 16:55 Yazen Ghannam
2019-03-07 16:53 Borislav Petkov
2019-03-07 16:15 Yazen Ghannam
2019-03-07 14:53 Borislav Petkov
2019-03-07 12:55 Rafal Milecki
2018-12-16 22:06 Rafał Miłecki
2018-12-16 10:59 Rafał Miłecki
2018-12-16 10:33 Rafał Miłecki
2018-12-16 10:22 Borislav Petkov
2018-12-15 13:04 Rafał Miłecki
2018-11-30 10:59 Borislav Petkov
2018-11-29 14:30 Rafal Milecki
2018-11-29 13:12 Borislav Petkov
2018-11-29  8:52 Rafal Milecki
2018-11-29  8:37 Borislav Petkov
2018-11-27 16:29 Borislav Petkov
2018-11-27 15:02 Yazen Ghannam
2018-11-27 13:40 Borislav Petkov
2018-11-27 13:33 Rafal Milecki
2018-11-27 13:29 Ingo Molnar
2018-11-27 13:26 Borislav Petkov
2018-11-27 13:06 Rafał Miłecki
2018-11-27 12:38 Borislav Petkov
2018-11-27 12:09 Borislav Petkov
2018-11-27 10:17 Rafał Miłecki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181218190546.GL7485@zn.tnic \
    --to=bp@alien8.de \
    --cc=Yazen.Ghannam@amd.com \
    --cc=aravindksg.lkml@gmail.com \
    --cc=clemej@gmail.com \
    --cc=hpa@zytor.com \
    --cc=linux-edac@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=rafal@milecki.pl \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    --cc=x86@kernel.org \
    --cc=zajec5@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).