From: Yazen Ghannam <yazen.ghannam@amd.com>
To: <linux-edac@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <tony.luck@intel.com>,
<x86@kernel.org>, <avadhut.naik@amd.com>, <john.allen@amd.com>,
<boris.ostrovsky@oracle.com>,
Yazen Ghannam <yazen.ghannam@amd.com>
Subject: [PATCH] x86/MCE: Prevent CPU offline for SMCA CPUs with non-core banks
Date: Wed, 21 Aug 2024 09:00:17 -0500 [thread overview]
Message-ID: <20240821140017.330105-1-yazen.ghannam@amd.com> (raw)
Logical CPUs in AMD Scalable MCA (SMCA) systems can manage non-core
banks. Each of these banks represents unique and separate hardware
located within the system. Each bank is managed by a single logical CPU;
they are not shared. Furthermore, the "CPU to MCA bank" assignment
cannot be modified at run time.
The MCE subsystem supports run time CPU hotplug. Many vendors have
non-core MCA banks, so MCA settings are not cleared when a CPU is
offlined for these vendors.
Even though the non-core MCA banks remain enabled, MCA errors will not
be handled (reported, cleared, etc.) on SMCA systems when the managing
CPU is offline.
Check if a CPU manages non-core MCA banks and, if so, prevent it from
being taken offline.
Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com>
---
arch/x86/kernel/cpu/mce/core.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c
index 2a938f429c4d..cf1529d0e6b1 100644
--- a/arch/x86/kernel/cpu/mce/core.c
+++ b/arch/x86/kernel/cpu/mce/core.c
@@ -2770,10 +2770,34 @@ static int mce_cpu_online(unsigned int cpu)
return 0;
}
+static bool mce_cpu_is_hotpluggable(void)
+{
+ if (!mce_flags.smca)
+ return true;
+
+ /*
+ * SMCA systems use banks 0-6 for core units. Banks 7 and later are
+ * used for non-core units.
+ *
+ * Logical CPUs with 7 or fewer banks can be offlined, since they are not
+ * managing any non-core units.
+ *
+ * Check if non-core banks are enabled using MCG_CTL. The hardware may
+ * report MCG_CAP[Count] greater than is actually present, so it is not a
+ * good indicator that a CPU has non-core banks.
+ */
+ return fls_long(mce_rdmsrl(MSR_IA32_MCG_CTL)) <= 7;
+}
+
static int mce_cpu_pre_down(unsigned int cpu)
{
struct timer_list *t = this_cpu_ptr(&mce_timer);
+ if (!mce_cpu_is_hotpluggable()) {
+ pr_info("CPU%d is not hotpluggable\n", cpu);
+ return -EOPNOTSUPP;
+ }
+
mce_disable_cpu();
del_timer_sync(t);
mce_threshold_remove_device(cpu);
--
2.34.1
next reply other threads:[~2024-08-21 14:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-21 14:00 Yazen Ghannam [this message]
2024-08-21 18:35 ` [PATCH] x86/MCE: Prevent CPU offline for SMCA CPUs with non-core banks boris.ostrovsky
2024-08-22 14:14 ` Yazen Ghannam
2024-08-25 11:16 ` Thomas Gleixner
2024-08-26 13:20 ` Yazen Ghannam
2024-08-27 12:50 ` Borislav Petkov
2024-08-27 13:47 ` Yazen Ghannam
2024-08-29 8:39 ` Borislav Petkov
2024-08-29 14:03 ` Yazen Ghannam
2024-08-29 14:14 ` Borislav Petkov
2024-08-29 14:18 ` Yazen Ghannam
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=20240821140017.330105-1-yazen.ghannam@amd.com \
--to=yazen.ghannam@amd.com \
--cc=avadhut.naik@amd.com \
--cc=boris.ostrovsky@oracle.com \
--cc=john.allen@amd.com \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox