Skip to content

Commit 2f97ce1

Browse files
Shirish Sjfvogel
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] (cherry picked from commit 30aa3d2) Orabug: 29547647 Signed-off-by: Somasundaram Krishnasamy <[email protected]> Reviewed-by: John Donnelly <[email protected]>
1 parent 5ba3d72 commit 2f97ce1

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
@@ -544,13 +544,49 @@ prepare_threshold_block(unsigned int bank, unsigned int block, u32 addr,
544544
return offset;
545545
}
546546

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

588+
disable_err_thresholding(c);
589+
554590
for (bank = 0; bank < mca_cfg.banks; ++bank) {
555591
if (mce_flags.smca)
556592
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
@@ -1628,35 +1628,6 @@ static int __mcheck_cpu_apply_quirks(struct cpuinfo_x86 *c)
16281628
if (c->x86 == 0x15 && c->x86_model <= 0xf)
16291629
mce_flags.overflow_recov = 1;
16301630

1631-
/*
1632-
* Turn off MC4_MISC thresholding banks on all models since
1633-
* they're not supported there.
1634-
*/
1635-
if (c->x86 == 0x15) {
1636-
int i;
1637-
u64 hwcr;
1638-
bool need_toggle;
1639-
u32 msrs[] = {
1640-
0x00000413, /* MC4_MISC0 */
1641-
0xc0000408, /* MC4_MISC1 */
1642-
};
1643-
1644-
rdmsrl(MSR_K7_HWCR, hwcr);
1645-
1646-
/* McStatusWrEn has to be set */
1647-
need_toggle = !(hwcr & BIT(18));
1648-
1649-
if (need_toggle)
1650-
wrmsrl(MSR_K7_HWCR, hwcr | BIT(18));
1651-
1652-
/* Clear CntP bit safely */
1653-
for (i = 0; i < ARRAY_SIZE(msrs); i++)
1654-
msr_clear_bit(msrs[i], 62);
1655-
1656-
/* restore old settings */
1657-
if (need_toggle)
1658-
wrmsrl(MSR_K7_HWCR, hwcr);
1659-
}
16601631
}
16611632

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

0 commit comments

Comments
 (0)