Skip to content

Commit 7d7dc11

Browse files
suryasaimadhuH. Peter Anvin
authored andcommitted
x86, cpu: Convert AMD Erratum 400
Convert AMD erratum 400 to the bug infrastructure. Then, retract all exports for modules since they're not needed now and make the AMD erratum checking machinery local to amd.c. Use forward declarations to avoid shuffling too much code around needlessly. Signed-off-by: Borislav Petkov <bp@suse.de> Link: http://lkml.kernel.org/r/1363788448-31325-7-git-send-email-bp@alien8.de Signed-off-by: H. Peter Anvin <hpa@zytor.com>
1 parent e6ee94d commit 7d7dc11

4 files changed

Lines changed: 18 additions & 27 deletions

File tree

‎arch/x86/include/asm/cpufeature.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@
226226
#define X86_BUG_FDIV X86_BUG(1) /* FPU FDIV */
227227
#define X86_BUG_COMA X86_BUG(2) /* Cyrix 6x86 coma */
228228
#define X86_BUG_AMD_TLB_MMATCH X86_BUG(3) /* AMD Erratum 383 */
229+
#define X86_BUG_AMD_APIC_C1E X86_BUG(4) /* AMD Erratum 400 */
229230

230231
#if defined(__KERNEL__) && !defined(__ASSEMBLY__)
231232

‎arch/x86/include/asm/processor.h‎

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -970,25 +970,6 @@ unsigned long calc_aperfmperf_ratio(struct aperfmperf *old,
970970
return ratio;
971971
}
972972

973-
/*
974-
* AMD errata checking
975-
*/
976-
#ifdef CONFIG_CPU_SUP_AMD
977-
extern const int amd_erratum_400[];
978-
extern bool cpu_has_amd_erratum(const int *);
979-
980-
#define AMD_LEGACY_ERRATUM(...) { -1, __VA_ARGS__, 0 }
981-
#define AMD_OSVW_ERRATUM(osvw_id, ...) { osvw_id, __VA_ARGS__, 0 }
982-
#define AMD_MODEL_RANGE(f, m_start, s_start, m_end, s_end) \
983-
((f << 24) | (m_start << 16) | (s_start << 12) | (m_end << 4) | (s_end))
984-
#define AMD_MODEL_RANGE_FAMILY(range) (((range) >> 24) & 0xff)
985-
#define AMD_MODEL_RANGE_START(range) (((range) >> 12) & 0xfff)
986-
#define AMD_MODEL_RANGE_END(range) ((range) & 0xfff)
987-
988-
#else
989-
#define cpu_has_amd_erratum(x) (false)
990-
#endif /* CONFIG_CPU_SUP_AMD */
991-
992973
extern unsigned long arch_align_stack(unsigned long sp);
993974
extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
994975

‎arch/x86/kernel/cpu/amd.c‎

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,8 @@ static void __cpuinit early_init_amd(struct cpuinfo_x86 *c)
514514
}
515515

516516
static const int amd_erratum_383[];
517+
static const int amd_erratum_400[];
518+
static bool cpu_has_amd_erratum(const int *erratum);
517519

518520
static void __cpuinit init_amd(struct cpuinfo_x86 *c)
519521
{
@@ -734,6 +736,9 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
734736
set_cpu_bug(c, X86_BUG_AMD_TLB_MMATCH);
735737
}
736738

739+
if (cpu_has_amd_erratum(amd_erratum_400))
740+
set_cpu_bug(c, X86_BUG_AMD_APIC_C1E);
741+
737742
rdmsr_safe(MSR_AMD64_PATCH_LEVEL, &c->microcode, &dummy);
738743
}
739744

@@ -852,8 +857,7 @@ cpu_dev_register(amd_cpu_dev);
852857
* AMD_OSVW_ERRATUM() macros. The latter is intended for newer errata that
853858
* have an OSVW id assigned, which it takes as first argument. Both take a
854859
* variable number of family-specific model-stepping ranges created by
855-
* AMD_MODEL_RANGE(). Each erratum also has to be declared as extern const
856-
* int[] in arch/x86/include/asm/processor.h.
860+
* AMD_MODEL_RANGE().
857861
*
858862
* Example:
859863
*
@@ -863,15 +867,22 @@ cpu_dev_register(amd_cpu_dev);
863867
* AMD_MODEL_RANGE(0x10, 0x9, 0x0, 0x9, 0x0));
864868
*/
865869

866-
const int amd_erratum_400[] =
870+
#define AMD_LEGACY_ERRATUM(...) { -1, __VA_ARGS__, 0 }
871+
#define AMD_OSVW_ERRATUM(osvw_id, ...) { osvw_id, __VA_ARGS__, 0 }
872+
#define AMD_MODEL_RANGE(f, m_start, s_start, m_end, s_end) \
873+
((f << 24) | (m_start << 16) | (s_start << 12) | (m_end << 4) | (s_end))
874+
#define AMD_MODEL_RANGE_FAMILY(range) (((range) >> 24) & 0xff)
875+
#define AMD_MODEL_RANGE_START(range) (((range) >> 12) & 0xfff)
876+
#define AMD_MODEL_RANGE_END(range) ((range) & 0xfff)
877+
878+
static const int amd_erratum_400[] =
867879
AMD_OSVW_ERRATUM(1, AMD_MODEL_RANGE(0xf, 0x41, 0x2, 0xff, 0xf),
868880
AMD_MODEL_RANGE(0x10, 0x2, 0x1, 0xff, 0xf));
869-
EXPORT_SYMBOL_GPL(amd_erratum_400);
870881

871882
static const int amd_erratum_383[] =
872883
AMD_OSVW_ERRATUM(3, AMD_MODEL_RANGE(0x10, 0, 0, 0xff, 0xf));
873884

874-
bool cpu_has_amd_erratum(const int *erratum)
885+
static bool cpu_has_amd_erratum(const int *erratum)
875886
{
876887
struct cpuinfo_x86 *cpu = __this_cpu_ptr(&cpu_info);
877888
int osvw_id = *erratum++;
@@ -912,5 +923,3 @@ bool cpu_has_amd_erratum(const int *erratum)
912923

913924
return false;
914925
}
915-
916-
EXPORT_SYMBOL_GPL(cpu_has_amd_erratum);

‎arch/x86/kernel/process.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c)
495495
if (x86_idle)
496496
return;
497497

498-
if (cpu_has_amd_erratum(amd_erratum_400)) {
498+
if (cpu_has_bug(c, X86_BUG_AMD_APIC_C1E)) {
499499
/* E400: APIC timer interrupt does not wake up CPU from C1e */
500500
pr_info("using AMD E400 aware idle routine\n");
501501
x86_idle = amd_e400_idle;

0 commit comments

Comments
 (0)