diff options
author | Borislav Petkov <bp@suse.de> | 2013-03-20 10:07:27 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2013-04-02 13:12:54 -0400 |
commit | e6ee94d58dfd06ec64c55f91581f00d4f98bf1f6 (patch) | |
tree | 81bfb5b71e3d579675c5490be0f77f405995a9d4 | |
parent | c5b41a67505cc3c9744d8f105c63a3bf3c443a01 (diff) |
x86, cpu: Convert AMD Erratum 383
Convert the AMD erratum 383 testing code to the bug infrastructure. This
allows keeping the AMD-specific erratum testing machinery private to
amd.c and not export symbols to modules needlessly.
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: http://lkml.kernel.org/r/1363788448-31325-6-git-send-email-bp@alien8.de
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r-- | arch/x86/include/asm/cpufeature.h | 1 | ||||
-rw-r--r-- | arch/x86/include/asm/processor.h | 1 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/amd.c | 8 | ||||
-rw-r--r-- | arch/x86/kvm/svm.c | 2 |
4 files changed, 8 insertions, 4 deletions
diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h index a2b65c11081e..4cfb5c9f6029 100644 --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h | |||
@@ -225,6 +225,7 @@ | |||
225 | #define X86_BUG_F00F X86_BUG(0) /* Intel F00F */ | 225 | #define X86_BUG_F00F X86_BUG(0) /* Intel F00F */ |
226 | #define X86_BUG_FDIV X86_BUG(1) /* FPU FDIV */ | 226 | #define X86_BUG_FDIV X86_BUG(1) /* FPU FDIV */ |
227 | #define X86_BUG_COMA X86_BUG(2) /* Cyrix 6x86 coma */ | 227 | #define X86_BUG_COMA X86_BUG(2) /* Cyrix 6x86 coma */ |
228 | #define X86_BUG_AMD_TLB_MMATCH X86_BUG(3) /* AMD Erratum 383 */ | ||
228 | 229 | ||
229 | #if defined(__KERNEL__) && !defined(__ASSEMBLY__) | 230 | #if defined(__KERNEL__) && !defined(__ASSEMBLY__) |
230 | 231 | ||
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 4e2fa2859e39..e044ef35f91f 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h | |||
@@ -974,7 +974,6 @@ unsigned long calc_aperfmperf_ratio(struct aperfmperf *old, | |||
974 | * AMD errata checking | 974 | * AMD errata checking |
975 | */ | 975 | */ |
976 | #ifdef CONFIG_CPU_SUP_AMD | 976 | #ifdef CONFIG_CPU_SUP_AMD |
977 | extern const int amd_erratum_383[]; | ||
978 | extern const int amd_erratum_400[]; | 977 | extern const int amd_erratum_400[]; |
979 | extern bool cpu_has_amd_erratum(const int *); | 978 | extern bool cpu_has_amd_erratum(const int *); |
980 | 979 | ||
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index fa96eb0d02fb..85f84e13d2dd 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c | |||
@@ -513,6 +513,8 @@ static void __cpuinit early_init_amd(struct cpuinfo_x86 *c) | |||
513 | #endif | 513 | #endif |
514 | } | 514 | } |
515 | 515 | ||
516 | static const int amd_erratum_383[]; | ||
517 | |||
516 | static void __cpuinit init_amd(struct cpuinfo_x86 *c) | 518 | static void __cpuinit init_amd(struct cpuinfo_x86 *c) |
517 | { | 519 | { |
518 | u32 dummy; | 520 | u32 dummy; |
@@ -727,6 +729,9 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c) | |||
727 | rdmsrl_safe(MSR_AMD64_BU_CFG2, &value); | 729 | rdmsrl_safe(MSR_AMD64_BU_CFG2, &value); |
728 | value &= ~(1ULL << 24); | 730 | value &= ~(1ULL << 24); |
729 | wrmsrl_safe(MSR_AMD64_BU_CFG2, value); | 731 | wrmsrl_safe(MSR_AMD64_BU_CFG2, value); |
732 | |||
733 | if (cpu_has_amd_erratum(amd_erratum_383)) | ||
734 | set_cpu_bug(c, X86_BUG_AMD_TLB_MMATCH); | ||
730 | } | 735 | } |
731 | 736 | ||
732 | rdmsr_safe(MSR_AMD64_PATCH_LEVEL, &c->microcode, &dummy); | 737 | rdmsr_safe(MSR_AMD64_PATCH_LEVEL, &c->microcode, &dummy); |
@@ -863,9 +868,8 @@ const int amd_erratum_400[] = | |||
863 | AMD_MODEL_RANGE(0x10, 0x2, 0x1, 0xff, 0xf)); | 868 | AMD_MODEL_RANGE(0x10, 0x2, 0x1, 0xff, 0xf)); |
864 | EXPORT_SYMBOL_GPL(amd_erratum_400); | 869 | EXPORT_SYMBOL_GPL(amd_erratum_400); |
865 | 870 | ||
866 | const int amd_erratum_383[] = | 871 | static const int amd_erratum_383[] = |
867 | AMD_OSVW_ERRATUM(3, AMD_MODEL_RANGE(0x10, 0, 0, 0xff, 0xf)); | 872 | AMD_OSVW_ERRATUM(3, AMD_MODEL_RANGE(0x10, 0, 0, 0xff, 0xf)); |
868 | EXPORT_SYMBOL_GPL(amd_erratum_383); | ||
869 | 873 | ||
870 | bool cpu_has_amd_erratum(const int *erratum) | 874 | bool cpu_has_amd_erratum(const int *erratum) |
871 | { | 875 | { |
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index e1b1ce21bc00..7d39d70647e3 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c | |||
@@ -555,7 +555,7 @@ static void svm_init_erratum_383(void) | |||
555 | int err; | 555 | int err; |
556 | u64 val; | 556 | u64 val; |
557 | 557 | ||
558 | if (!cpu_has_amd_erratum(amd_erratum_383)) | 558 | if (!static_cpu_has_bug(X86_BUG_AMD_TLB_MMATCH)) |
559 | return; | 559 | return; |
560 | 560 | ||
561 | /* Use _safe variants to not break nested virtualization */ | 561 | /* Use _safe variants to not break nested virtualization */ |