aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBorislav Petkov <bp@suse.de>2017-10-22 06:47:31 -0400
committerIngo Molnar <mingo@kernel.org>2017-10-22 07:06:02 -0400
commitbfc1168de949cd3e9ca18c3480b5085deff1ea7c (patch)
tree989b48bdcfaf3dfbe900c38dd15f9d91f00e3c8c
parentce56a86e2ade45d052b3228cdfebe913a1ae7381 (diff)
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>
-rw-r--r--arch/x86/kernel/amd_nb.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/arch/x86/kernel/amd_nb.c b/arch/x86/kernel/amd_nb.c
index 458da8509b75..6db28f17ff28 100644
--- a/arch/x86/kernel/amd_nb.c
+++ b/arch/x86/kernel/amd_nb.c
@@ -27,6 +27,8 @@ static const struct pci_device_id amd_root_ids[] = {
27 {} 27 {}
28}; 28};
29 29
30#define PCI_DEVICE_ID_AMD_CNB17H_F4 0x1704
31
30const struct pci_device_id amd_nb_misc_ids[] = { 32const struct pci_device_id amd_nb_misc_ids[] = {
31 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB_MISC) }, 33 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB_MISC) },
32 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_10H_NB_MISC) }, 34 { 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[] = {
37 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_NB_F3) }, 39 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_NB_F3) },
38 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F3) }, 40 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F3) },
39 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_DF_F3) }, 41 { 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) },
40 {} 43 {}
41}; 44};
42EXPORT_SYMBOL_GPL(amd_nb_misc_ids); 45EXPORT_SYMBOL_GPL(amd_nb_misc_ids);
@@ -48,6 +51,7 @@ static const struct pci_device_id amd_nb_link_ids[] = {
48 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_NB_F4) }, 51 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_NB_F4) },
49 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F4) }, 52 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F4) },
50 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_DF_F4) }, 53 { 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) },
51 {} 55 {}
52}; 56};
53 57
@@ -402,11 +406,48 @@ void amd_flush_garts(void)
402} 406}
403EXPORT_SYMBOL_GPL(amd_flush_garts); 407EXPORT_SYMBOL_GPL(amd_flush_garts);
404 408
409static 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. */
418static __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
405static __init int init_amd_nbs(void) 444static __init int init_amd_nbs(void)
406{ 445{
407 amd_cache_northbridges(); 446 amd_cache_northbridges();
408 amd_cache_gart(); 447 amd_cache_gart();
409 448
449 fix_erratum_688();
450
410 return 0; 451 return 0;
411} 452}
412 453