@@ -213,12 +213,14 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c);
void mcheck_cpu_clear(struct cpuinfo_x86 *c);
int apei_smca_report_x86_error(struct cper_ia_proc_ctx *ctx_info,
u64 lapic_id);
+bool mce_cpu_is_hotpluggable(unsigned int cpu);
#else
static inline int mcheck_init(void) { return 0; }
static inline void mcheck_cpu_init(struct cpuinfo_x86 *c) {}
static inline void mcheck_cpu_clear(struct cpuinfo_x86 *c) {}
static inline int apei_smca_report_x86_error(struct cper_ia_proc_ctx *ctx_info,
u64 lapic_id) { return -EINVAL; }
+static inline bool mce_cpu_is_hotpluggable(unsigned int cpu) { return true; }
#endif
void mce_prep_record(struct mce *m);
@@ -2775,6 +2775,21 @@ static int mce_cpu_online(unsigned int cpu)
return 0;
}
+bool mce_cpu_is_hotpluggable(unsigned int cpu)
+{
+ 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.
+ */
+ return per_cpu(mce_num_banks, cpu) <= 7;
+}
+
static int mce_cpu_pre_down(unsigned int cpu)
{
struct timer_list *t = this_cpu_ptr(&mce_timer);
@@ -1222,6 +1222,6 @@ __initcall(register_kernel_offset_dumper);
#ifdef CONFIG_HOTPLUG_CPU
bool arch_cpu_is_hotpluggable(int cpu)
{
- return cpu > 0;
+ return cpu > 0 && mce_cpu_is_hotpluggable(cpu);
}
#endif /* CONFIG_HOTPLUG_CPU */
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. Mark a CPU as not hotpluggable if it manages non-core MCA banks. This prevents the CPU from being marked offline from sysfs. Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com> --- arch/x86/include/asm/mce.h | 2 ++ arch/x86/kernel/cpu/mce/core.c | 15 +++++++++++++++ arch/x86/kernel/setup.c | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-)