Skip to content

Commit ebb3762

Browse files
committed
Merge branch 'ras-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull RAS fixes from Thomas Gleixner: "Two small fixes for RAS/MCE: - Serialize sysfs changes to avoid concurrent modificaiton of underlying data - Add microcode revision to Machine Check records. This should have been there forever, but now with the broken microcode versions in the wild it has become important" * 'ras-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/MCE: Serialize sysfs changes x86/MCE: Save microcode revision in machine check records
2 parents 8ad4424 + b3b7c47 commit ebb3762

File tree

2 files changed

+25
-2
lines changed
  • arch/x86

2 files changed

+25
-2
lines changed

arch/x86/include/uapi/asm/mce.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ struct mce {
3030
__u64 synd; /* MCA_SYND MSR: only valid on SMCA systems */
3131
__u64 ipid; /* MCA_IPID MSR: only valid on SMCA systems */
3232
__u64 ppin; /* Protected Processor Inventory Number */
33+
__u32 microcode;/* Microcode revision */
3334
};
3435

3536
#define MCE_GET_RECORD_LEN _IOR('M', 1, int)

arch/x86/kernel/cpu/mcheck/mce.c

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@
5656

5757
static DEFINE_MUTEX(mce_log_mutex);
5858

59+
/* sysfs synchronization */
60+
static DEFINE_MUTEX(mce_sysfs_mutex);
61+
5962
#define CREATE_TRACE_POINTS
6063
#include <trace/events/mce.h>
6164

@@ -130,6 +133,8 @@ void mce_setup(struct mce *m)
130133

131134
if (this_cpu_has(X86_FEATURE_INTEL_PPIN))
132135
rdmsrl(MSR_PPIN, m->ppin);
136+
137+
m->microcode = boot_cpu_data.microcode;
133138
}
134139

135140
DEFINE_PER_CPU(struct mce, injectm);
@@ -262,7 +267,7 @@ static void __print_mce(struct mce *m)
262267
*/
263268
pr_emerg(HW_ERR "PROCESSOR %u:%x TIME %llu SOCKET %u APIC %x microcode %x\n",
264269
m->cpuvendor, m->cpuid, m->time, m->socketid, m->apicid,
265-
cpu_data(m->extcpu).microcode);
270+
m->microcode);
266271
}
267272

268273
static void print_mce(struct mce *m)
@@ -2086,6 +2091,7 @@ static ssize_t set_ignore_ce(struct device *s,
20862091
if (kstrtou64(buf, 0, &new) < 0)
20872092
return -EINVAL;
20882093

2094+
mutex_lock(&mce_sysfs_mutex);
20892095
if (mca_cfg.ignore_ce ^ !!new) {
20902096
if (new) {
20912097
/* disable ce features */
@@ -2098,6 +2104,8 @@ static ssize_t set_ignore_ce(struct device *s,
20982104
on_each_cpu(mce_enable_ce, (void *)1, 1);
20992105
}
21002106
}
2107+
mutex_unlock(&mce_sysfs_mutex);
2108+
21012109
return size;
21022110
}
21032111

@@ -2110,6 +2118,7 @@ static ssize_t set_cmci_disabled(struct device *s,
21102118
if (kstrtou64(buf, 0, &new) < 0)
21112119
return -EINVAL;
21122120

2121+
mutex_lock(&mce_sysfs_mutex);
21132122
if (mca_cfg.cmci_disabled ^ !!new) {
21142123
if (new) {
21152124
/* disable cmci */
@@ -2121,15 +2130,28 @@ static ssize_t set_cmci_disabled(struct device *s,
21212130
on_each_cpu(mce_enable_ce, NULL, 1);
21222131
}
21232132
}
2133+
mutex_unlock(&mce_sysfs_mutex);
2134+
21242135
return size;
21252136
}
21262137

21272138
static ssize_t store_int_with_restart(struct device *s,
21282139
struct device_attribute *attr,
21292140
const char *buf, size_t size)
21302141
{
2131-
ssize_t ret = device_store_int(s, attr, buf, size);
2142+
unsigned long old_check_interval = check_interval;
2143+
ssize_t ret = device_store_ulong(s, attr, buf, size);
2144+
2145+
if (check_interval == old_check_interval)
2146+
return ret;
2147+
2148+
if (check_interval < 1)
2149+
check_interval = 1;
2150+
2151+
mutex_lock(&mce_sysfs_mutex);
21322152
mce_restart();
2153+
mutex_unlock(&mce_sysfs_mutex);
2154+
21332155
return ret;
21342156
}
21352157

0 commit comments

Comments
 (0)