From: Borislav Petkov <bp@alien8.de>
To: X86 ML <x86@kernel.org>
Cc: Yazen Ghannam <Yazen.Ghannam@amd.com>,
linux-edac <linux-edac@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 2/7] x86/mce/amd: Init thresholding machinery only on relevant vendors
Date: Fri, 3 Apr 2020 18:19:38 +0200 [thread overview]
Message-ID: <20200403161943.1458-3-bp@alien8.de> (raw)
In-Reply-To: <20200403161943.1458-1-bp@alien8.de>
From: Thomas Gleixner <tglx@linutronix.de>
... and not unconditionally.
[ bp: Add a new vendor_flags bit for that. ]
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
---
arch/x86/kernel/cpu/mce/amd.c | 12 ++++++++++--
arch/x86/kernel/cpu/mce/core.c | 1 +
arch/x86/kernel/cpu/mce/internal.h | 9 ++++++---
3 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c
index 477cf773cf1c..c3b3326ad4ac 100644
--- a/arch/x86/kernel/cpu/mce/amd.c
+++ b/arch/x86/kernel/cpu/mce/amd.c
@@ -1442,15 +1442,20 @@ static void threshold_remove_bank(unsigned int cpu, int bank)
int mce_threshold_remove_device(unsigned int cpu)
{
+ struct threshold_bank **bp = this_cpu_read(threshold_banks);
unsigned int bank;
+ if (!bp)
+ return 0;
+
for (bank = 0; bank < per_cpu(mce_num_banks, cpu); ++bank) {
if (!(per_cpu(bank_map, cpu) & (1 << bank)))
continue;
threshold_remove_bank(cpu, bank);
}
- kfree(per_cpu(threshold_banks, cpu));
- per_cpu(threshold_banks, cpu) = NULL;
+ /* Clear the pointer before freeing the memory */
+ this_cpu_write(threshold_banks, NULL);
+ kfree(bp);
return 0;
}
@@ -1461,6 +1466,9 @@ int mce_threshold_create_device(unsigned int cpu)
struct threshold_bank **bp;
int err = 0;
+ if (!mce_flags.amd_threshold)
+ return 0;
+
bp = per_cpu(threshold_banks, cpu);
if (bp)
return 0;
diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c
index 54165f3569e8..43ca91e14a77 100644
--- a/arch/x86/kernel/cpu/mce/core.c
+++ b/arch/x86/kernel/cpu/mce/core.c
@@ -1756,6 +1756,7 @@ static void __mcheck_cpu_init_early(struct cpuinfo_x86 *c)
mce_flags.overflow_recov = !!cpu_has(c, X86_FEATURE_OVERFLOW_RECOV);
mce_flags.succor = !!cpu_has(c, X86_FEATURE_SUCCOR);
mce_flags.smca = !!cpu_has(c, X86_FEATURE_SMCA);
+ mce_flags.amd_threshold = 1;
if (mce_flags.smca) {
msr_ops.ctl = smca_ctl_reg;
diff --git a/arch/x86/kernel/cpu/mce/internal.h b/arch/x86/kernel/cpu/mce/internal.h
index 3b008172ad73..74a01829c4f4 100644
--- a/arch/x86/kernel/cpu/mce/internal.h
+++ b/arch/x86/kernel/cpu/mce/internal.h
@@ -148,7 +148,7 @@ struct mce_vendor_flags {
* Recovery. It indicates support for data poisoning in HW and deferred
* error interrupts.
*/
- succor : 1,
+ succor : 1,
/*
* (AMD) SMCA: This bit indicates support for Scalable MCA which expands
@@ -156,9 +156,12 @@ struct mce_vendor_flags {
* banks. Also, to accommodate the new banks and registers, the MCA
* register space is moved to a new MSR range.
*/
- smca : 1,
+ smca : 1,
- __reserved_0 : 61;
+ /* AMD-style error thresholding banks present. */
+ amd_threshold : 1,
+
+ __reserved_0 : 60;
};
extern struct mce_vendor_flags mce_flags;
--
2.21.0
next prev parent reply other threads:[~2020-04-03 16:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-03 16:19 [PATCH 0/7] x86/mce/amd: Fix some CPU hotplug insanity Borislav Petkov
2020-04-03 16:19 ` [PATCH 1/7] x86/mce/amd: Do proper cleanup on error paths Borislav Petkov
2020-04-03 16:19 ` Borislav Petkov [this message]
2020-04-03 16:19 ` [PATCH 3/7] x86/mce/amd: Protect a not-fully initialized bank from the thresholding interrupt Borislav Petkov
2020-04-03 16:19 ` [PATCH 4/7] x86/mce/amd: Sanitize thresholding device creation hotplug path Borislav Petkov
2020-04-03 16:19 ` [PATCH 5/7] x86/mce/amd: Straighten CPU " Borislav Petkov
2020-04-03 16:19 ` [PATCH 6/7] x86/mce/amd: Cleanup threshold device remove path Borislav Petkov
2020-04-03 16:19 ` [PATCH 7/7] x86/mce/amd: Make threshold bank setting hotplug robust Borislav Petkov
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=20200403161943.1458-3-bp@alien8.de \
--to=bp@alien8.de \
--cc=Yazen.Ghannam@amd.com \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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 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).