diff options
Diffstat (limited to 'arch/x86/kernel/cpu/amd.c')
-rw-r--r-- | arch/x86/kernel/cpu/amd.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index bca023bdd6b2..c67ffa686064 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c | |||
@@ -1,5 +1,4 @@ | |||
1 | #include <linux/export.h> | 1 | #include <linux/export.h> |
2 | #include <linux/init.h> | ||
3 | #include <linux/bitops.h> | 2 | #include <linux/bitops.h> |
4 | #include <linux/elf.h> | 3 | #include <linux/elf.h> |
5 | #include <linux/mm.h> | 4 | #include <linux/mm.h> |
@@ -487,7 +486,7 @@ static void early_init_amd(struct cpuinfo_x86 *c) | |||
487 | set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC); | 486 | set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC); |
488 | set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC); | 487 | set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC); |
489 | if (!check_tsc_unstable()) | 488 | if (!check_tsc_unstable()) |
490 | sched_clock_stable = 1; | 489 | set_sched_clock_stable(); |
491 | } | 490 | } |
492 | 491 | ||
493 | #ifdef CONFIG_X86_64 | 492 | #ifdef CONFIG_X86_64 |
@@ -508,6 +507,16 @@ static void early_init_amd(struct cpuinfo_x86 *c) | |||
508 | set_cpu_cap(c, X86_FEATURE_EXTD_APICID); | 507 | set_cpu_cap(c, X86_FEATURE_EXTD_APICID); |
509 | } | 508 | } |
510 | #endif | 509 | #endif |
510 | |||
511 | /* F16h erratum 793, CVE-2013-6885 */ | ||
512 | if (c->x86 == 0x16 && c->x86_model <= 0xf) { | ||
513 | u64 val; | ||
514 | |||
515 | rdmsrl(MSR_AMD64_LS_CFG, val); | ||
516 | if (!(val & BIT(15))) | ||
517 | wrmsrl(MSR_AMD64_LS_CFG, val | BIT(15)); | ||
518 | } | ||
519 | |||
511 | } | 520 | } |
512 | 521 | ||
513 | static const int amd_erratum_383[]; | 522 | static const int amd_erratum_383[]; |
@@ -758,10 +767,7 @@ static unsigned int amd_size_cache(struct cpuinfo_x86 *c, unsigned int size) | |||
758 | 767 | ||
759 | static void cpu_set_tlb_flushall_shift(struct cpuinfo_x86 *c) | 768 | static void cpu_set_tlb_flushall_shift(struct cpuinfo_x86 *c) |
760 | { | 769 | { |
761 | tlb_flushall_shift = 5; | 770 | tlb_flushall_shift = 6; |
762 | |||
763 | if (c->x86 <= 0x11) | ||
764 | tlb_flushall_shift = 4; | ||
765 | } | 771 | } |
766 | 772 | ||
767 | static void cpu_detect_tlb_amd(struct cpuinfo_x86 *c) | 773 | static void cpu_detect_tlb_amd(struct cpuinfo_x86 *c) |
@@ -790,14 +796,10 @@ static void cpu_detect_tlb_amd(struct cpuinfo_x86 *c) | |||
790 | } | 796 | } |
791 | 797 | ||
792 | /* Handle DTLB 2M and 4M sizes, fall back to L1 if L2 is disabled */ | 798 | /* Handle DTLB 2M and 4M sizes, fall back to L1 if L2 is disabled */ |
793 | if (!((eax >> 16) & mask)) { | 799 | if (!((eax >> 16) & mask)) |
794 | u32 a, b, c, d; | 800 | tlb_lld_2m[ENTRIES] = (cpuid_eax(0x80000005) >> 16) & 0xff; |
795 | 801 | else | |
796 | cpuid(0x80000005, &a, &b, &c, &d); | ||
797 | tlb_lld_2m[ENTRIES] = (a >> 16) & 0xff; | ||
798 | } else { | ||
799 | tlb_lld_2m[ENTRIES] = (eax >> 16) & mask; | 802 | tlb_lld_2m[ENTRIES] = (eax >> 16) & mask; |
800 | } | ||
801 | 803 | ||
802 | /* a 4M entry uses two 2M entries */ | 804 | /* a 4M entry uses two 2M entries */ |
803 | tlb_lld_4m[ENTRIES] = tlb_lld_2m[ENTRIES] >> 1; | 805 | tlb_lld_4m[ENTRIES] = tlb_lld_2m[ENTRIES] >> 1; |