Skip to content

Commit bfc1168

Browse files
suryasaimadhuIngo Molnar
authored andcommitted
x86/cpu/AMD: Apply the Erratum 688 fix when the BIOS doesn't
Some F14h machines have an erratum which, "under a highly specific and detailed set of internal timing conditions" can lead to skipping instructions and RIP corruption. Add the fix for those machines when their BIOS doesn't apply it or there simply isn't BIOS update for them. Tested-by: <mirh@protonmail.ch> Signed-off-by: Borislav Petkov <bp@suse.de> Cc: <stable@vger.kernel.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Sherry Hurwitz <sherry.hurwitz@amd.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Yazen Ghannam <Yazen.Ghannam@amd.com> Link: http://lkml.kernel.org/r/20171022104731.28249-1-bp@alien8.de Link: https://bugzilla.kernel.org/show_bug.cgi?id=197285 [ Added pr_info() that we activated the workaround. ] Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent ce56a86 commit bfc1168

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

arch/x86/kernel/amd_nb.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ static const struct pci_device_id amd_root_ids[] = {
2727
{}
2828
};
2929

30+
#define PCI_DEVICE_ID_AMD_CNB17H_F4 0x1704
31+
3032
const struct pci_device_id amd_nb_misc_ids[] = {
3133
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB_MISC) },
3234
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_10H_NB_MISC) },
@@ -37,6 +39,7 @@ const struct pci_device_id amd_nb_misc_ids[] = {
3739
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_NB_F3) },
3840
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F3) },
3941
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_DF_F3) },
42+
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CNB17H_F3) },
4043
{}
4144
};
4245
EXPORT_SYMBOL_GPL(amd_nb_misc_ids);
@@ -48,6 +51,7 @@ static const struct pci_device_id amd_nb_link_ids[] = {
4851
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_NB_F4) },
4952
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F4) },
5053
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_DF_F4) },
54+
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CNB17H_F4) },
5155
{}
5256
};
5357

@@ -402,11 +406,48 @@ void amd_flush_garts(void)
402406
}
403407
EXPORT_SYMBOL_GPL(amd_flush_garts);
404408

409+
static void __fix_erratum_688(void *info)
410+
{
411+
#define MSR_AMD64_IC_CFG 0xC0011021
412+
413+
msr_set_bit(MSR_AMD64_IC_CFG, 3);
414+
msr_set_bit(MSR_AMD64_IC_CFG, 14);
415+
}
416+
417+
/* Apply erratum 688 fix so machines without a BIOS fix work. */
418+
static __init void fix_erratum_688(void)
419+
{
420+
struct pci_dev *F4;
421+
u32 val;
422+
423+
if (boot_cpu_data.x86 != 0x14)
424+
return;
425+
426+
if (!amd_northbridges.num)
427+
return;
428+
429+
F4 = node_to_amd_nb(0)->link;
430+
if (!F4)
431+
return;
432+
433+
if (pci_read_config_dword(F4, 0x164, &val))
434+
return;
435+
436+
if (val & BIT(2))
437+
return;
438+
439+
on_each_cpu(__fix_erratum_688, NULL, 0);
440+
441+
pr_info("x86/cpu/AMD: CPU erratum 688 worked around\n");
442+
}
443+
405444
static __init int init_amd_nbs(void)
406445
{
407446
amd_cache_northbridges();
408447
amd_cache_gart();
409448

449+
fix_erratum_688();
450+
410451
return 0;
411452
}
412453

0 commit comments

Comments
 (0)