Skip to content

Commit 0ef283d

Browse files
committed
Merge branch 'ras-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 RAS updates from Thomas Gleixner: - Fix a stack out of bounds write in the MCE error injection code. - Avoid IPIs during CPU hotplug to read the MCx_MISC block address from a remote CPU. That's fragile and pointless because the block addresses are the same on all CPUs. So they can be read once and local. - Add support for MCE broadcasting on newer VIA Centaur CPUs. * 'ras-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/MCE/AMD: Read MCx_MISC block addresses on any CPU x86/MCE: Fix stack out-of-bounds write in mce-inject.c: Flags_read() x86/MCE: Enable MCE broadcasting on new Centaur CPUs
2 parents db020be + fbf96cf commit 0ef283d

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static struct dentry *dfs_inj;
4848

4949
static u8 n_banks;
5050

51-
#define MAX_FLAG_OPT_SIZE 3
51+
#define MAX_FLAG_OPT_SIZE 4
5252
#define NBCFG 0x44
5353

5454
enum injection_type {

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,6 +1727,21 @@ static void __mcheck_cpu_init_early(struct cpuinfo_x86 *c)
17271727
}
17281728
}
17291729

1730+
static void mce_centaur_feature_init(struct cpuinfo_x86 *c)
1731+
{
1732+
struct mca_config *cfg = &mca_cfg;
1733+
1734+
/*
1735+
* All newer Centaur CPUs support MCE broadcasting. Enable
1736+
* synchronization with a one second timeout.
1737+
*/
1738+
if ((c->x86 == 6 && c->x86_model == 0xf && c->x86_stepping >= 0xe) ||
1739+
c->x86 > 6) {
1740+
if (cfg->monarch_timeout < 0)
1741+
cfg->monarch_timeout = USEC_PER_SEC;
1742+
}
1743+
}
1744+
17301745
static void __mcheck_cpu_init_vendor(struct cpuinfo_x86 *c)
17311746
{
17321747
switch (c->x86_vendor) {
@@ -1739,6 +1754,9 @@ static void __mcheck_cpu_init_vendor(struct cpuinfo_x86 *c)
17391754
mce_amd_feature_init(c);
17401755
break;
17411756
}
1757+
case X86_VENDOR_CENTAUR:
1758+
mce_centaur_feature_init(c);
1759+
break;
17421760

17431761
default:
17441762
break;

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,7 @@ static void deferred_error_interrupt_enable(struct cpuinfo_x86 *c)
436436
wrmsr(MSR_CU_DEF_ERR, low, high);
437437
}
438438

439-
static u32 smca_get_block_address(unsigned int cpu, unsigned int bank,
440-
unsigned int block)
439+
static u32 smca_get_block_address(unsigned int bank, unsigned int block)
441440
{
442441
u32 low, high;
443442
u32 addr = 0;
@@ -456,13 +455,13 @@ static u32 smca_get_block_address(unsigned int cpu, unsigned int bank,
456455
* For SMCA enabled processors, BLKPTR field of the first MISC register
457456
* (MCx_MISC0) indicates presence of additional MISC regs set (MISC1-4).
458457
*/
459-
if (rdmsr_safe_on_cpu(cpu, MSR_AMD64_SMCA_MCx_CONFIG(bank), &low, &high))
458+
if (rdmsr_safe(MSR_AMD64_SMCA_MCx_CONFIG(bank), &low, &high))
460459
goto out;
461460

462461
if (!(low & MCI_CONFIG_MCAX))
463462
goto out;
464463

465-
if (!rdmsr_safe_on_cpu(cpu, MSR_AMD64_SMCA_MCx_MISC(bank), &low, &high) &&
464+
if (!rdmsr_safe(MSR_AMD64_SMCA_MCx_MISC(bank), &low, &high) &&
466465
(low & MASK_BLKPTR_LO))
467466
addr = MSR_AMD64_SMCA_MCx_MISCy(bank, block - 1);
468467

@@ -471,7 +470,7 @@ static u32 smca_get_block_address(unsigned int cpu, unsigned int bank,
471470
return addr;
472471
}
473472

474-
static u32 get_block_address(unsigned int cpu, u32 current_addr, u32 low, u32 high,
473+
static u32 get_block_address(u32 current_addr, u32 low, u32 high,
475474
unsigned int bank, unsigned int block)
476475
{
477476
u32 addr = 0, offset = 0;
@@ -480,7 +479,7 @@ static u32 get_block_address(unsigned int cpu, u32 current_addr, u32 low, u32 hi
480479
return addr;
481480

482481
if (mce_flags.smca)
483-
return smca_get_block_address(cpu, bank, block);
482+
return smca_get_block_address(bank, block);
484483

485484
/* Fall back to method we used for older processors: */
486485
switch (block) {
@@ -558,7 +557,7 @@ void mce_amd_feature_init(struct cpuinfo_x86 *c)
558557
smca_configure(bank, cpu);
559558

560559
for (block = 0; block < NR_BLOCKS; ++block) {
561-
address = get_block_address(cpu, address, low, high, bank, block);
560+
address = get_block_address(address, low, high, bank, block);
562561
if (!address)
563562
break;
564563

@@ -1175,7 +1174,7 @@ static int allocate_threshold_blocks(unsigned int cpu, unsigned int bank,
11751174
if (err)
11761175
goto out_free;
11771176
recurse:
1178-
address = get_block_address(cpu, address, low, high, bank, ++block);
1177+
address = get_block_address(address, low, high, bank, ++block);
11791178
if (!address)
11801179
return 0;
11811180

0 commit comments

Comments
 (0)