From: "Rafał Miłecki" <zajec5@gmail.com>
To: Tony Luck <tony.luck@intel.com>, Borislav Petkov <bp@alien8.de>
Cc: linux-edac@vger.kernel.org,
"Yazen Ghannam" <Yazen.Ghannam@amd.com>,
"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, "John Clemens" <clemej@gmail.com>,
"Rafał Miłecki" <rafal@milecki.pl>
Subject: x86/mce/AMD: Make sure banks were initialized before accessing them
Date: Tue, 27 Nov 2018 11:17:00 +0100 [thread overview]
Message-ID: <20181127101700.2964-1-zajec5@gmail.com> (raw)
From: Rafał Miłecki <rafal@milecki.pl>
It may happen amd_threshold_interrupt() fires before banks get setup as
part of the threshold_init_device() call. Such a case requires a proper
check to avoid NULL pointer dereference.
This problem has been noticed on HP EliteBook 745 G5 (Ryzen 2500U) with
BIOS 1.03.01. It doesn't boot unless mce is disabled (e.g. with
"mce=off").
This fixes a regression introduced in kernel 4.10. It was the first
kernel referencing "threshold_banks" variable in the
amd_threshold_interrupt().
Reported-by: John Clemens <clemej@gmail.com>
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=201291
Fixes: 18807ddb7f88 ("x86/mce/AMD: Reset Threshold Limit after logging error")
Cc: stable@vger.kernel.org # v4.10+
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
arch/x86/kernel/cpu/mcheck/mce_amd.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c
index dd33c357548f..379f54afc266 100644
--- a/arch/x86/kernel/cpu/mcheck/mce_amd.c
+++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c
@@ -935,12 +935,19 @@ static void amd_threshold_interrupt(void)
{
struct threshold_block *first_block = NULL, *block = NULL, *tmp = NULL;
unsigned int bank, cpu = smp_processor_id();
+ struct threshold_bank **banks;
+
+ banks = per_cpu(threshold_banks, cpu);
+ if (!banks) {
+ pr_warn("Threshold interrupt fired before MCE setup\n");
+ return;
+ }
for (bank = 0; bank < mca_cfg.banks; ++bank) {
if (!(per_cpu(bank_map, cpu) & (1 << bank)))
continue;
- first_block = per_cpu(threshold_banks, cpu)[bank]->blocks;
+ first_block = banks[bank]->blocks;
if (!first_block)
continue;
next reply other threads:[~2018-11-27 10:17 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-27 10:17 Rafał Miłecki [this message]
2018-11-28 9:21 ` [tip:x86/urgent] x86/MCE/AMD: Fix the thresholding machinery initialization order tip-bot for Borislav Petkov
-- strict thread matches above, loose matches on Subject: below --
2018-11-27 12:09 x86/mce/AMD: Make sure banks were initialized before accessing them Borislav Petkov
2018-11-27 12:38 Borislav Petkov
2018-11-27 13:06 Rafał Miłecki
2018-11-27 13:26 Borislav Petkov
2018-11-27 13:29 Ingo Molnar
2018-11-27 13:33 Rafal Milecki
2018-11-27 13:40 Borislav Petkov
2018-11-27 15:02 Yazen Ghannam
2018-11-27 16:29 Borislav Petkov
2018-11-29 8:37 Borislav Petkov
2018-11-29 8:52 Rafal Milecki
2018-11-29 13:12 Borislav Petkov
2018-11-29 14:30 Rafal Milecki
2018-11-30 10:59 Borislav Petkov
2018-12-15 13:04 Rafał Miłecki
2018-12-16 10:22 Borislav Petkov
2018-12-16 10:33 Rafał Miłecki
2018-12-16 10:59 Rafał Miłecki
2018-12-16 22:06 Rafał Miłecki
2018-12-18 19:05 Borislav Petkov
2019-03-07 12:55 Rafal Milecki
2019-03-07 14:53 Borislav Petkov
2019-03-07 16:15 Yazen Ghannam
2019-03-07 16:53 Borislav Petkov
2019-03-07 16:55 Yazen Ghannam
2019-03-07 17:08 Borislav Petkov
2019-03-16 16:42 Rafal Milecki
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=20181127101700.2964-1-zajec5@gmail.com \
--to=zajec5@gmail.com \
--cc=Yazen.Ghannam@amd.com \
--cc=aravindksg.lkml@gmail.com \
--cc=bp@alien8.de \
--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 \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.