Skip to content

Commit 30aa3d2

Browse files
Shirish Ssuryasaimadhu
authored andcommitted
x86/MCE/AMD: Carve out the MC4_MISC thresholding quirk
The MC4_MISC thresholding quirk needs to be applied during S5 -> S0 and S3 -> S0 state transitions, which follow different code paths. Carve it out into a separate function and call it mce_amd_feature_init() where the two code paths of the state transitions converge. [ bp: massage commit message and the carved out function. ] Signed-off-by: Shirish S <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Kees Cook <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Tony Luck <[email protected]> Cc: Vishal Verma <[email protected]> Cc: Yazen Ghannam <[email protected]> Cc: x86-ml <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent c95b323 commit 30aa3d2

File tree

2 files changed

+36
-29
lines changed

2 files changed

+36
-29
lines changed

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,13 +545,49 @@ prepare_threshold_block(unsigned int bank, unsigned int block, u32 addr,
545545
return offset;
546546
}
547547

548+
/*
549+
* Turn off MC4_MISC thresholding banks on all family 0x15 models since
550+
* they're not supported there.
551+
*/
552+
void disable_err_thresholding(struct cpuinfo_x86 *c)
553+
{
554+
int i;
555+
u64 hwcr;
556+
bool need_toggle;
557+
u32 msrs[] = {
558+
0x00000413, /* MC4_MISC0 */
559+
0xc0000408, /* MC4_MISC1 */
560+
};
561+
562+
if (c->x86 != 0x15)
563+
return;
564+
565+
rdmsrl(MSR_K7_HWCR, hwcr);
566+
567+
/* McStatusWrEn has to be set */
568+
need_toggle = !(hwcr & BIT(18));
569+
570+
if (need_toggle)
571+
wrmsrl(MSR_K7_HWCR, hwcr | BIT(18));
572+
573+
/* Clear CntP bit safely */
574+
for (i = 0; i < ARRAY_SIZE(msrs); i++)
575+
msr_clear_bit(msrs[i], 62);
576+
577+
/* restore old settings */
578+
if (need_toggle)
579+
wrmsrl(MSR_K7_HWCR, hwcr);
580+
}
581+
548582
/* cpu init entry point, called from mce.c with preempt off */
549583
void mce_amd_feature_init(struct cpuinfo_x86 *c)
550584
{
551585
u32 low = 0, high = 0, address = 0;
552586
unsigned int bank, block, cpu = smp_processor_id();
553587
int offset = -1;
554588

589+
disable_err_thresholding(c);
590+
555591
for (bank = 0; bank < mca_cfg.banks; ++bank) {
556592
if (mce_flags.smca)
557593
smca_configure(bank, cpu);

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

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,35 +1611,6 @@ static int __mcheck_cpu_apply_quirks(struct cpuinfo_x86 *c)
16111611
if (c->x86 == 0x15 && c->x86_model <= 0xf)
16121612
mce_flags.overflow_recov = 1;
16131613

1614-
/*
1615-
* Turn off MC4_MISC thresholding banks on all models since
1616-
* they're not supported there.
1617-
*/
1618-
if (c->x86 == 0x15) {
1619-
int i;
1620-
u64 hwcr;
1621-
bool need_toggle;
1622-
u32 msrs[] = {
1623-
0x00000413, /* MC4_MISC0 */
1624-
0xc0000408, /* MC4_MISC1 */
1625-
};
1626-
1627-
rdmsrl(MSR_K7_HWCR, hwcr);
1628-
1629-
/* McStatusWrEn has to be set */
1630-
need_toggle = !(hwcr & BIT(18));
1631-
1632-
if (need_toggle)
1633-
wrmsrl(MSR_K7_HWCR, hwcr | BIT(18));
1634-
1635-
/* Clear CntP bit safely */
1636-
for (i = 0; i < ARRAY_SIZE(msrs); i++)
1637-
msr_clear_bit(msrs[i], 62);
1638-
1639-
/* restore old settings */
1640-
if (need_toggle)
1641-
wrmsrl(MSR_K7_HWCR, hwcr);
1642-
}
16431614
}
16441615

16451616
if (c->x86_vendor == X86_VENDOR_INTEL) {

0 commit comments

Comments
 (0)