x86, cpu: Expand ->x86_capability flags with bugs bitvector, v2
Subsystems (4)
Borislav Petkov
maintainercover x86, cpu: Expand ->x86_capability flags with bugs bitvector, v2
From: Borislav Petkov <[email protected]>
Hi,
this is v2, with some added functionality in patches 5 and 6. It all looks pretty straight-forward and testing it in kvm (even with lying to the guest it is running on a Cyrix) works, as well as on bare metal.
Comments and suggestions appreciated,
Thanks.
Borislav Petkov (6):
x86, cpu: Expand cpufeature facility to include cpu bugs x86, cpu: Convert F00F bug detection
x86, cpu: Convert FDIV bug detection
x86, cpu: Convert Cyrix coma bug detection
x86, cpu: Convert AMD Erratum 383
x86, cpu: Convert AMD Erratum 400
arch/x86/include/asm/cpufeature.h | 19 +++++++++++++++++++ arch/x86/include/asm/processor.h | 25 +------------------------ arch/x86/kernel/alternative.c | 2 +- arch/x86/kernel/cpu/amd.c | 31 ++++++++++++++++++++++--------- arch/x86/kernel/cpu/bugs.c | 7 ++++--- arch/x86/kernel/cpu/common.c | 4 ++++ arch/x86/kernel/cpu/cyrix.c | 5 +++-- arch/x86/kernel/cpu/intel.c | 4 ++-- arch/x86/kernel/cpu/proc.c | 6 +++--- arch/x86/kernel/process.c | 2 +- arch/x86/kernel/setup.c | 2 -- arch/x86/kvm/svm.c | 2 +- arch/x86/mm/fault.c | 2 +- 13 files changed, 62 insertions(+), 49 deletions(-)
Signature · 1 line
1.8.1.3.535.ga923c31
Borislav Petkov
maintainerPATCH 1/6 x86, cpu: Expand cpufeature facility to include cpu bugs
From: Borislav Petkov <[email protected]>
We add another 32-bit vector at the end of the ->x86_capability bitvector which collects bugs present in CPUs. After all, a CPU bug is a kind of a capability, albeit a strange one.
--- arch/x86/include/asm/cpufeature.h | 13 +++++++++++++ arch/x86/include/asm/processor.h | 2 +- arch/x86/kernel/alternative.c | 2 +- arch/x86/kernel/cpu/common.c | 4 ++++ 4 files changed, 19 insertions(+), 2 deletions(-)
arch/x86/include/asm/cpufeature.h +13 -0
@@ -9,6 +9,7 @@#endif #define NCAPINTS 10/* N 32-bit words worth of info */ +#define NBUGINTS 1/* N 32-bit bug flags */ /* * Note: If the comment begins with a quoted string, that string is used
@@ -216,6 +217,11 @@#define X86_FEATURE_ADX (9*32+19)/* The ADCX and ADOX instructions */ #define X86_FEATURE_SMAP (9*32+20)/* Supervisor Mode Access Prevention */ +/* +* BUG word(s) +*/ +#define X86_BUG (x) (NCAPINTS*32 + (x)) +#if defined(__KERNEL__) && !defined(__ASSEMBLY__)#include <asm/asm.h>
@@ -401,6 +407,13 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)#define static_cpu_has (bit) boot_cpu_has(bit)#endif +#define cpu_has_bug (c, bit) cpu_has(c, (bit)) +#define set_cpu_bug (c, bit) set_cpu_cap(c, (bit)) +#define clear_cpu_bug (c, bit) clear_cpu_cap(c, (bit)); + +#define static_cpu_has_bug (bit) static_cpu_has((bit)) +#define boot_cpu_has_bug (bit) cpu_has_bug(&boot_cpu_data, (bit)) +#endif /* defined(__KERNEL__) && !defined(__ASSEMBLY__) */ #endif /* _ASM_X86_CPUFEATURE_H */
arch/x86/include/asm/processor.h +1 -1
@@ -107,7 +107,7 @@ struct cpuinfo_x86 {__u32 extended_cpuid_level;/* Maximum supported CPUID level, -1=no CPUID: */ int cpuid_level; -__u32 x86_capability[NCAPINTS ]; +__u32 x86_capability[NCAPINTS +NBUGINTS ];char x86_vendor_id[16 ];char x86_model_id[64 ];/* in KB - valid for CPUS which support this call: */
arch/x86/kernel/alternative.c +1 -1
@@ -271,7 +271,7 @@ void __init_or_module apply_alternatives(struct alt_instr *start, replacement = (u8 *)&a->repl_offset + a->repl_offset;BUG_ON (a->replacementlen > a->instrlen);BUG_ON (a->instrlen >sizeof (insnbuf)); -BUG_ON (a->cpuid >=NCAPINTS *32 ); +BUG_ON (a->cpuid >= (NCAPINTS +NBUGINTS ) *32 );if (!boot_cpu_has (a->cpuid))continue ;
arch/x86/kernel/cpu/common.c +4 -0
@@ -920,6 +920,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)/* AND the already accumulated flags with these */ for (i =0 ; i <NCAPINTS ; i++) boot_cpu_data.x86_capability[i] &= c->x86_capability[i]; + +/* OR, i.e. replicate the bug flags */ +for (i =NCAPINTS ; i <NCAPINTS +NBUGINTS ; i++) + c->x86_capability[i] |= boot_cpu_data.x86_capability[i]; }/* Init Machine Check Exception if available. */
Signature · 1 line
1.8.1.3.535.ga923c31
tip-bot for Borislav Petkov
merge bot[tip:x86/cpu] x86, cpu: Expand cpufeature facility to include cpu bugs
x86, cpu: Expand cpufeature facility to include cpu bugs
Commit-ID: 65fc985b37dc241c4db7cd32adcbc989193fe3c8 Gitweb: http://git.kernel.org/tip/65fc985b37dc241c4db7cd32adcbc989193fe3c8 Author: Borislav Petkov <[email protected]> AuthorDate: Wed, 20 Mar 2013 15:07:23 +0100 Committer: H. Peter Anvin <[email protected]> CommitDate: Tue, 2 Apr 2013 10:12:52 -0700
x86, cpu: Expand cpufeature facility to include cpu bugs
We add another 32-bit vector at the end of the ->x86_capability bitvector which collects bugs present in CPUs. After all, a CPU bug is a kind of a capability, albeit a strange one.
--- arch/x86/include/asm/cpufeature.h | 13 +++++++++++++ arch/x86/include/asm/processor.h | 2 +- arch/x86/kernel/alternative.c | 2 +- arch/x86/kernel/cpu/common.c | 4 ++++ 4 files changed, 19 insertions(+), 2 deletions(-)
arch/x86/include/asm/cpufeature.h +13 -0
@@ -9,6 +9,7 @@#endif #define NCAPINTS 10/* N 32-bit words worth of info */ +#define NBUGINTS 1/* N 32-bit bug flags */ /* * Note: If the comment begins with a quoted string, that string is used
@@ -216,6 +217,11 @@#define X86_FEATURE_ADX (9*32+19)/* The ADCX and ADOX instructions */ #define X86_FEATURE_SMAP (9*32+20)/* Supervisor Mode Access Prevention */ +/* +* BUG word(s) +*/ +#define X86_BUG (x) (NCAPINTS*32 + (x)) +#if defined(__KERNEL__) && !defined(__ASSEMBLY__)#include <asm/asm.h>
@@ -401,6 +407,13 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)#define static_cpu_has (bit) boot_cpu_has(bit)#endif +#define cpu_has_bug (c, bit) cpu_has(c, (bit)) +#define set_cpu_bug (c, bit) set_cpu_cap(c, (bit)) +#define clear_cpu_bug (c, bit) clear_cpu_cap(c, (bit)); + +#define static_cpu_has_bug (bit) static_cpu_has((bit)) +#define boot_cpu_has_bug (bit) cpu_has_bug(&boot_cpu_data, (bit)) +#endif /* defined(__KERNEL__) && !defined(__ASSEMBLY__) */ #endif /* _ASM_X86_CPUFEATURE_H */
arch/x86/include/asm/processor.h +1 -1
@@ -107,7 +107,7 @@ struct cpuinfo_x86 {__u32 extended_cpuid_level;/* Maximum supported CPUID level, -1=no CPUID: */ int cpuid_level; -__u32 x86_capability[NCAPINTS ]; +__u32 x86_capability[NCAPINTS +NBUGINTS ];char x86_vendor_id[16 ];char x86_model_id[64 ];/* in KB - valid for CPUS which support this call: */
arch/x86/kernel/alternative.c +1 -1
@@ -271,7 +271,7 @@ void __init_or_module apply_alternatives(struct alt_instr *start, replacement = (u8 *)&a->repl_offset + a->repl_offset;BUG_ON (a->replacementlen > a->instrlen);BUG_ON (a->instrlen >sizeof (insnbuf)); -BUG_ON (a->cpuid >=NCAPINTS *32 ); +BUG_ON (a->cpuid >= (NCAPINTS +NBUGINTS ) *32 );if (!boot_cpu_has (a->cpuid))continue ;
arch/x86/kernel/cpu/common.c +4 -0
@@ -920,6 +920,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)/* AND the already accumulated flags with these */ for (i =0 ; i <NCAPINTS ; i++) boot_cpu_data.x86_capability[i] &= c->x86_capability[i]; + +/* OR, i.e. replicate the bug flags */ +for (i =NCAPINTS ; i <NCAPINTS +NBUGINTS ; i++) + c->x86_capability[i] |= boot_cpu_data.x86_capability[i]; }/* Init Machine Check Exception if available. */
Borislav Petkov
maintainerPATCH 2/6 x86, cpu: Convert F00F bug detection
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
... to using the new facility and drop the cpuinfo_x86 member.
--- arch/x86/include/asm/cpufeature.h | 2 ++ arch/x86/include/asm/processor.h | 1 - arch/x86/kernel/cpu/intel.c | 4 ++-- arch/x86/kernel/cpu/proc.c | 2 +- arch/x86/mm/fault.c | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-)
arch/x86/include/asm/cpufeature.h +2 -0
@@ -222,6 +222,8 @@*/ #define X86_BUG (x) (NCAPINTS*32 + (x)) +#define X86_BUG_F00F X86_BUG(0)/* Intel F00F */ +#if defined(__KERNEL__) && !defined(__ASSEMBLY__)#include <asm/asm.h>
arch/x86/include/asm/processor.h +0 -1
@@ -92,7 +92,6 @@ struct cpuinfo_x86 {char hard_math;char rfu;char fdiv_bug; -char f00f_bug;char coma_bug;char pad0;#else
arch/x86/kernel/cpu/intel.c +2 -2
@@ -209,11 +209,11 @@ static void __cpuinit intel_workarounds(struct cpuinfo_x86 *c)* system. * Note that the workaround only should be initialized once... */ - c->f00f_bug =0 ; +clear_cpu_bug (c,X86_BUG_F00F );if (!paravirt_enabled () && c->x86 ==5 ) {static int f00f_workaround_enabled; - c->f00f_bug =1 ; +set_cpu_bug (c,X86_BUG_F00F );if (!f00f_workaround_enabled) {trap_init_f00f_bug ();printk (KERN_NOTICE "Intel Pentium with F0 0F bug - workaround enabled.\n" );
arch/x86/kernel/cpu/proc.c +1 -1
@@ -35,7 +35,7 @@ static void show_cpuinfo_misc(struct seq_file *m, struct cpuinfo_x86 *c)"cpuid level\t: %d\n" "wp\t\t: %s\n" , c->fdiv_bug ?"yes" :"no" , - c->f00f_bug ?"yes" :"no" , +static_cpu_has_bug (X86_BUG_F00F ) ?"yes" :"no" , c->coma_bug ?"yes" :"no" , c->hard_math ?"yes" :"no" , c->hard_math ? "yes" : "no",
arch/x86/mm/fault.c +1 -1
@@ -555,7 +555,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)/* * Pentium F0 0F C7 C8 bug workaround: */ -if (boot_cpu_data.f00f_bug) { +if (boot_cpu_has_bug (X86_BUG_F00F )) { nr = (address - idt_descr.address) >>3 ;if (nr ==6 ) {
Signature · 1 line
1.8.1.3.535.ga923c31
tip-bot for Borislav Petkov
merge bot[tip:x86/cpu] x86, cpu: Convert F00F bug detection
x86, cpu: Convert F00F bug detection
Commit-ID: e2604b49e8a8827e8bc5b61bc0c5a889e028fdad Gitweb: http://git.kernel.org/tip/e2604b49e8a8827e8bc5b61bc0c5a889e028fdad Author: Borislav Petkov <[email protected]> AuthorDate: Wed, 20 Mar 2013 15:07:24 +0100 Committer: H. Peter Anvin <[email protected]> CommitDate: Tue, 2 Apr 2013 10:12:52 -0700
x86, cpu: Convert F00F bug detection
... to using the new facility and drop the cpuinfo_x86 member.
--- arch/x86/include/asm/cpufeature.h | 2 ++ arch/x86/include/asm/processor.h | 1 - arch/x86/kernel/cpu/intel.c | 4 ++-- arch/x86/kernel/cpu/proc.c | 2 +- arch/x86/mm/fault.c | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-)
arch/x86/include/asm/cpufeature.h +2 -0
@@ -222,6 +222,8 @@*/ #define X86_BUG (x) (NCAPINTS*32 + (x)) +#define X86_BUG_F00F X86_BUG(0)/* Intel F00F */ +#if defined(__KERNEL__) && !defined(__ASSEMBLY__)#include <asm/asm.h>
arch/x86/include/asm/processor.h +0 -1
@@ -92,7 +92,6 @@ struct cpuinfo_x86 {char hard_math;char rfu;char fdiv_bug; -char f00f_bug;char coma_bug;char pad0;#else
arch/x86/kernel/cpu/intel.c +2 -2
@@ -209,11 +209,11 @@ static void __cpuinit intel_workarounds(struct cpuinfo_x86 *c)* system. * Note that the workaround only should be initialized once... */ - c->f00f_bug =0 ; +clear_cpu_bug (c,X86_BUG_F00F );if (!paravirt_enabled () && c->x86 ==5 ) {static int f00f_workaround_enabled; - c->f00f_bug =1 ; +set_cpu_bug (c,X86_BUG_F00F );if (!f00f_workaround_enabled) {trap_init_f00f_bug ();printk (KERN_NOTICE "Intel Pentium with F0 0F bug - workaround enabled.\n" );
arch/x86/kernel/cpu/proc.c +1 -1
@@ -35,7 +35,7 @@ static void show_cpuinfo_misc(struct seq_file *m, struct cpuinfo_x86 *c)"cpuid level\t: %d\n" "wp\t\t: %s\n" , c->fdiv_bug ?"yes" :"no" , - c->f00f_bug ?"yes" :"no" , +static_cpu_has_bug (X86_BUG_F00F ) ?"yes" :"no" , c->coma_bug ?"yes" :"no" , c->hard_math ?"yes" :"no" , c->hard_math ? "yes" : "no",
arch/x86/mm/fault.c +1 -1
@@ -555,7 +555,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)/* * Pentium F0 0F C7 C8 bug workaround: */ -if (boot_cpu_data.f00f_bug) { +if (boot_cpu_has_bug (X86_BUG_F00F )) { nr = (address - idt_descr.address) >>3 ;if (nr ==6 ) {
Borislav Petkov
maintainerPATCH 3/6 x86, cpu: Convert FDIV bug detection
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
... to the new facility. Add a reference to the wikipedia article explaining the FDIV test we're doing here.
--- arch/x86/include/asm/cpufeature.h | 1 + arch/x86/include/asm/processor.h | 1 - arch/x86/kernel/cpu/bugs.c | 7 ++++--- arch/x86/kernel/cpu/proc.c | 2 +- arch/x86/kernel/setup.c | 2 -- 5 files changed, 6 insertions(+), 7 deletions(-)
arch/x86/include/asm/cpufeature.h +1 -0
@@ -223,6 +223,7 @@#define X86_BUG (x) (NCAPINTS*32 + (x))#define X86_BUG_F00F X86_BUG(0)/* Intel F00F */ +#define X86_BUG_FDIV X86_BUG(1)/* FPU FDIV */ #if defined(__KERNEL__) && !defined(__ASSEMBLY__)
arch/x86/include/asm/processor.h +0 -1
@@ -91,7 +91,6 @@ struct cpuinfo_x86 {/* Problems on some 486Dx4's and old 386's: */ char hard_math;char rfu; -char fdiv_bug;char coma_bug;char pad0;#else
arch/x86/kernel/cpu/bugs.c +4 -3
@@ -59,7 +59,7 @@ static void __init check_fpu(void)* trap_init() enabled FXSR and company _before_ testing for FP * problems here. * -* Test for the divl bug.. +* Test for the divl bug: http://en.wikipedia.org/wiki/Fdiv_bug */ __asm__("fninit\n\t" "fldl %1\n\t"
@@ -75,9 +75,10 @@ static void __init check_fpu(void)kernel_fpu_end (); - boot_cpu_data.fdiv_bug = fdiv_bug; -if (boot_cpu_data.fdiv_bug) +if (fdiv_bug) { +set_cpu_bug (&boot_cpu_data,X86_BUG_FDIV );pr_warn ("Hmm, FPU with FDIV bug\n" ); + } }/*
arch/x86/kernel/cpu/proc.c +1 -1
@@ -34,7 +34,7 @@ static void show_cpuinfo_misc(struct seq_file *m, struct cpuinfo_x86 *c)"fpu_exception\t: %s\n" "cpuid level\t: %d\n" "wp\t\t: %s\n" , - c->fdiv_bug ?"yes" :"no" , +static_cpu_has_bug (X86_BUG_FDIV ) ?"yes" :"no" ,static_cpu_has_bug (X86_BUG_F00F ) ?"yes" :"no" , c->coma_bug ?"yes" :"no" , c->hard_math ? "yes" : "no",
arch/x86/kernel/setup.c +0 -2
@@ -173,12 +173,10 @@ static struct resource bss_resource = {/* cpu data as detected by the assembly code in head.S */ struct cpuinfo_x86 new_cpu_data__cpuinitdata = { .wp_works_ok =-1 , - .fdiv_bug =-1 , };/* common cpu data for all cpus */ struct cpuinfo_x86 boot_cpu_data__read_mostly = { .wp_works_ok =-1 , - .fdiv_bug =-1 , };EXPORT_SYMBOL (boot_cpu_data);
Signature · 1 line
1.8.1.3.535.ga923c31
tip-bot for Borislav Petkov
merge bot[tip:x86/cpu] x86, cpu: Convert FDIV bug detection
x86, cpu: Convert FDIV bug detection
Commit-ID: 93a829e8e2c292f1d30155f64803101ca1cb7d3d Gitweb: http://git.kernel.org/tip/93a829e8e2c292f1d30155f64803101ca1cb7d3d Author: Borislav Petkov <[email protected]> AuthorDate: Wed, 20 Mar 2013 15:07:25 +0100 Committer: H. Peter Anvin <[email protected]> CommitDate: Tue, 2 Apr 2013 10:12:53 -0700
x86, cpu: Convert FDIV bug detection
... to the new facility. Add a reference to the wikipedia article explaining the FDIV test we're doing here.
--- arch/x86/include/asm/cpufeature.h | 1 + arch/x86/include/asm/processor.h | 1 - arch/x86/kernel/cpu/bugs.c | 7 ++++--- arch/x86/kernel/cpu/proc.c | 2 +- arch/x86/kernel/setup.c | 2 -- 5 files changed, 6 insertions(+), 7 deletions(-)
arch/x86/include/asm/cpufeature.h +1 -0
@@ -223,6 +223,7 @@#define X86_BUG (x) (NCAPINTS*32 + (x))#define X86_BUG_F00F X86_BUG(0)/* Intel F00F */ +#define X86_BUG_FDIV X86_BUG(1)/* FPU FDIV */ #if defined(__KERNEL__) && !defined(__ASSEMBLY__)
arch/x86/include/asm/processor.h +0 -1
@@ -91,7 +91,6 @@ struct cpuinfo_x86 {/* Problems on some 486Dx4's and old 386's: */ char hard_math;char rfu; -char fdiv_bug;char coma_bug;char pad0;#else
arch/x86/kernel/cpu/bugs.c +4 -3
@@ -59,7 +59,7 @@ static void __init check_fpu(void)* trap_init() enabled FXSR and company _before_ testing for FP * problems here. * -* Test for the divl bug.. +* Test for the divl bug: http://en.wikipedia.org/wiki/Fdiv_bug */ __asm__("fninit\n\t" "fldl %1\n\t"
@@ -75,9 +75,10 @@ static void __init check_fpu(void)kernel_fpu_end (); - boot_cpu_data.fdiv_bug = fdiv_bug; -if (boot_cpu_data.fdiv_bug) +if (fdiv_bug) { +set_cpu_bug (&boot_cpu_data,X86_BUG_FDIV );pr_warn ("Hmm, FPU with FDIV bug\n" ); + } }/*
arch/x86/kernel/cpu/proc.c +1 -1
@@ -34,7 +34,7 @@ static void show_cpuinfo_misc(struct seq_file *m, struct cpuinfo_x86 *c)"fpu_exception\t: %s\n" "cpuid level\t: %d\n" "wp\t\t: %s\n" , - c->fdiv_bug ?"yes" :"no" , +static_cpu_has_bug (X86_BUG_FDIV ) ?"yes" :"no" ,static_cpu_has_bug (X86_BUG_F00F ) ?"yes" :"no" , c->coma_bug ?"yes" :"no" , c->hard_math ? "yes" : "no",
arch/x86/kernel/setup.c +0 -2
@@ -173,12 +173,10 @@ static struct resource bss_resource = {/* cpu data as detected by the assembly code in head.S */ struct cpuinfo_x86 new_cpu_data__cpuinitdata = { .wp_works_ok =-1 , - .fdiv_bug =-1 , };/* common cpu data for all cpus */ struct cpuinfo_x86 boot_cpu_data__read_mostly = { .wp_works_ok =-1 , - .fdiv_bug =-1 , };EXPORT_SYMBOL (boot_cpu_data);
Borislav Petkov
maintainerPATCH 4/6 x86, cpu: Convert Cyrix coma bug detection
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
... to the new facility.
--- arch/x86/include/asm/cpufeature.h | 1 + arch/x86/include/asm/processor.h | 1 - arch/x86/kernel/cpu/cyrix.c | 5 +++-- arch/x86/kernel/cpu/proc.c | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-)
arch/x86/include/asm/cpufeature.h +1 -0
@@ -224,6 +224,7 @@#define X86_BUG_F00F X86_BUG(0)/* Intel F00F */ #define X86_BUG_FDIV X86_BUG(1)/* FPU FDIV */ +#define X86_BUG_COMA X86_BUG(2)/* Cyrix 6x86 coma */ #if defined(__KERNEL__) && !defined(__ASSEMBLY__)
arch/x86/include/asm/processor.h +0 -1
@@ -91,7 +91,6 @@ struct cpuinfo_x86 {/* Problems on some 486Dx4's and old 386's: */ char hard_math;char rfu; -char coma_bug;char pad0;#else /* Number of 4K pages in DTLB/ITLB combined(in pages): */
arch/x86/kernel/cpu/cyrix.c +3 -2
@@ -249,7 +249,7 @@ static void __cpuinit init_cyrix(struct cpuinfo_x86 *c)/* Emulate MTRRs using Cyrix's ARRs. */ set_cpu_cap (c,X86_FEATURE_CYRIX_ARR );/* 6x86's contain this bug */ - c->coma_bug =1 ; +set_cpu_bug (c,X86_BUG_COMA );break ;case 4 :/* MediaGX/GXm or Geode GXM/GXLV/GX1 */
@@ -317,7 +317,8 @@ static void __cpuinit init_cyrix(struct cpuinfo_x86 *c)/* Enable MMX extensions (App note 108) */ setCx86_old (CX86_CCR7 ,getCx86_old (CX86_CCR7 )|1 ); }else { - c->coma_bug =1 ;/* 6x86MX, it has the bug. */ +/* A 6x86MX - it has the bug. */ +set_cpu_bug (c,X86_BUG_COMA ); } tmp = (!(dir0_lsn &7 ) || dir0_lsn &1 ) ?2 :0 ; Cx86_cb[tmp] = cyrix_model_mult2[dir0_lsn &7 ];
arch/x86/kernel/cpu/proc.c +1 -1
@@ -36,7 +36,7 @@ static void show_cpuinfo_misc(struct seq_file *m, struct cpuinfo_x86 *c)"wp\t\t: %s\n" ,static_cpu_has_bug (X86_BUG_FDIV ) ?"yes" :"no" ,static_cpu_has_bug (X86_BUG_F00F ) ?"yes" :"no" , - c->coma_bug ?"yes" :"no" , +static_cpu_has_bug (X86_BUG_COMA ) ?"yes" :"no" , c->hard_math ?"yes" :"no" , c->hard_math ?"yes" :"no" , c->cpuid_level,
Signature · 1 line
1.8.1.3.535.ga923c31
tip-bot for Borislav Petkov
merge bot[tip:x86/cpu] x86, cpu: Convert Cyrix coma bug detection
x86, cpu: Convert Cyrix coma bug detection
Commit-ID: c5b41a67505cc3c9744d8f105c63a3bf3c443a01 Gitweb: http://git.kernel.org/tip/c5b41a67505cc3c9744d8f105c63a3bf3c443a01 Author: Borislav Petkov <[email protected]> AuthorDate: Wed, 20 Mar 2013 15:07:26 +0100 Committer: H. Peter Anvin <[email protected]> CommitDate: Tue, 2 Apr 2013 10:12:54 -0700
x86, cpu: Convert Cyrix coma bug detection
... to the new facility.
--- arch/x86/include/asm/cpufeature.h | 1 + arch/x86/include/asm/processor.h | 1 - arch/x86/kernel/cpu/cyrix.c | 5 +++-- arch/x86/kernel/cpu/proc.c | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-)
arch/x86/include/asm/cpufeature.h +1 -0
@@ -224,6 +224,7 @@#define X86_BUG_F00F X86_BUG(0)/* Intel F00F */ #define X86_BUG_FDIV X86_BUG(1)/* FPU FDIV */ +#define X86_BUG_COMA X86_BUG(2)/* Cyrix 6x86 coma */ #if defined(__KERNEL__) && !defined(__ASSEMBLY__)
arch/x86/include/asm/processor.h +0 -1
@@ -91,7 +91,6 @@ struct cpuinfo_x86 {/* Problems on some 486Dx4's and old 386's: */ char hard_math;char rfu; -char coma_bug;char pad0;#else /* Number of 4K pages in DTLB/ITLB combined(in pages): */
arch/x86/kernel/cpu/cyrix.c +3 -2
@@ -249,7 +249,7 @@ static void __cpuinit init_cyrix(struct cpuinfo_x86 *c)/* Emulate MTRRs using Cyrix's ARRs. */ set_cpu_cap (c,X86_FEATURE_CYRIX_ARR );/* 6x86's contain this bug */ - c->coma_bug =1 ; +set_cpu_bug (c,X86_BUG_COMA );break ;case 4 :/* MediaGX/GXm or Geode GXM/GXLV/GX1 */
@@ -317,7 +317,8 @@ static void __cpuinit init_cyrix(struct cpuinfo_x86 *c)/* Enable MMX extensions (App note 108) */ setCx86_old (CX86_CCR7 ,getCx86_old (CX86_CCR7 )|1 ); }else { - c->coma_bug =1 ;/* 6x86MX, it has the bug. */ +/* A 6x86MX - it has the bug. */ +set_cpu_bug (c,X86_BUG_COMA ); } tmp = (!(dir0_lsn &7 ) || dir0_lsn &1 ) ?2 :0 ; Cx86_cb[tmp] = cyrix_model_mult2[dir0_lsn &7 ];
arch/x86/kernel/cpu/proc.c +1 -1
@@ -36,7 +36,7 @@ static void show_cpuinfo_misc(struct seq_file *m, struct cpuinfo_x86 *c)"wp\t\t: %s\n" ,static_cpu_has_bug (X86_BUG_FDIV ) ?"yes" :"no" ,static_cpu_has_bug (X86_BUG_F00F ) ?"yes" :"no" , - c->coma_bug ?"yes" :"no" , +static_cpu_has_bug (X86_BUG_COMA ) ?"yes" :"no" , c->hard_math ?"yes" :"no" , c->hard_math ?"yes" :"no" , c->cpuid_level,
Borislav Petkov
maintainerPATCH 5/6 x86, cpu: Convert AMD Erratum 383
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
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.
--- arch/x86/include/asm/cpufeature.h | 1 + arch/x86/include/asm/processor.h | 1 - arch/x86/kernel/cpu/amd.c | 8 ++++++-- arch/x86/kvm/svm.c | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-)
arch/x86/include/asm/cpufeature.h +1 -0
@@ -225,6 +225,7 @@#define X86_BUG_F00F X86_BUG(0)/* Intel F00F */ #define X86_BUG_FDIV X86_BUG(1)/* FPU FDIV */ #define X86_BUG_COMA X86_BUG(2)/* Cyrix 6x86 coma */ +#define X86_BUG_AMD_TLB_MMATCH X86_BUG(3)/* AMD Erratum 383 */ #if defined(__KERNEL__) && !defined(__ASSEMBLY__)
arch/x86/include/asm/processor.h +0 -1
@@ -974,7 +974,6 @@ unsigned long calc_aperfmperf_ratio(struct aperfmperf *old,* AMD errata checking */ #ifdef CONFIG_CPU_SUP_AMD -extern const int amd_erratum_383[];extern const int amd_erratum_400[];extern bool cpu_has_amd_erratum (const int *);
arch/x86/kernel/cpu/amd.c +6 -2
@@ -513,6 +513,8 @@ static void __cpuinit early_init_amd(struct cpuinfo_x86 *c)#endif } +static const int amd_erratum_383[]; +static void __cpuinit init_amd (struct cpuinfo_x86 *c) {u32 dummy;
@@ -727,6 +729,9 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)rdmsrl_safe (MSR_AMD64_BU_CFG2 , &value); value &= ~(1ULL <<24 );wrmsrl_safe (MSR_AMD64_BU_CFG2 , value); + +if (cpu_has_amd_erratum (amd_erratum_383)) +set_cpu_bug (c,X86_BUG_AMD_TLB_MMATCH ); }rdmsr_safe (MSR_AMD64_PATCH_LEVEL , &c->microcode, &dummy);
@@ -863,9 +868,8 @@ const int amd_erratum_400[] = AMD_MODEL_RANGE(0x10, 0x2, 0x1, 0xff, 0xf));EXPORT_SYMBOL_GPL (amd_erratum_400); -const int amd_erratum_383[] = +static const int amd_erratum_383[] =AMD_OSVW_ERRATUM (3 ,AMD_MODEL_RANGE (0x10 ,0 ,0 ,0xff ,0xf )); -EXPORT_SYMBOL_GPL (amd_erratum_383);bool cpu_has_amd_erratum (const int *erratum) {
arch/x86/kvm/svm.c +1 -1
@@ -555,7 +555,7 @@ static void svm_init_erratum_383(void)int err;u64 val; -if (!cpu_has_amd_erratum (amd_erratum_383)) +if (!static_cpu_has_bug (X86_BUG_AMD_TLB_MMATCH ))return ;/* Use _safe variants to not break nested virtualization */
Signature · 1 line
1.8.1.3.535.ga923c31
tip-bot for Borislav Petkov
merge bot[tip:x86/cpu] x86, cpu: Convert AMD Erratum 383
x86, cpu: Convert AMD Erratum 383
Commit-ID: e6ee94d58dfd06ec64c55f91581f00d4f98bf1f6 Gitweb: http://git.kernel.org/tip/e6ee94d58dfd06ec64c55f91581f00d4f98bf1f6 Author: Borislav Petkov <[email protected]> AuthorDate: Wed, 20 Mar 2013 15:07:27 +0100 Committer: H. Peter Anvin <[email protected]> CommitDate: Tue, 2 Apr 2013 10:12:54 -0700
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.
--- arch/x86/include/asm/cpufeature.h | 1 + arch/x86/include/asm/processor.h | 1 - arch/x86/kernel/cpu/amd.c | 8 ++++++-- arch/x86/kvm/svm.c | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-)
arch/x86/include/asm/cpufeature.h +1 -0
@@ -225,6 +225,7 @@#define X86_BUG_F00F X86_BUG(0)/* Intel F00F */ #define X86_BUG_FDIV X86_BUG(1)/* FPU FDIV */ #define X86_BUG_COMA X86_BUG(2)/* Cyrix 6x86 coma */ +#define X86_BUG_AMD_TLB_MMATCH X86_BUG(3)/* AMD Erratum 383 */ #if defined(__KERNEL__) && !defined(__ASSEMBLY__)
arch/x86/include/asm/processor.h +0 -1
@@ -974,7 +974,6 @@ unsigned long calc_aperfmperf_ratio(struct aperfmperf *old,* AMD errata checking */ #ifdef CONFIG_CPU_SUP_AMD -extern const int amd_erratum_383[];extern const int amd_erratum_400[];extern bool cpu_has_amd_erratum (const int *);
arch/x86/kernel/cpu/amd.c +6 -2
@@ -513,6 +513,8 @@ static void __cpuinit early_init_amd(struct cpuinfo_x86 *c)#endif } +static const int amd_erratum_383[]; +static void __cpuinit init_amd (struct cpuinfo_x86 *c) {u32 dummy;
@@ -727,6 +729,9 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)rdmsrl_safe (MSR_AMD64_BU_CFG2 , &value); value &= ~(1ULL <<24 );wrmsrl_safe (MSR_AMD64_BU_CFG2 , value); + +if (cpu_has_amd_erratum (amd_erratum_383)) +set_cpu_bug (c,X86_BUG_AMD_TLB_MMATCH ); }rdmsr_safe (MSR_AMD64_PATCH_LEVEL , &c->microcode, &dummy);
@@ -863,9 +868,8 @@ const int amd_erratum_400[] = AMD_MODEL_RANGE(0x10, 0x2, 0x1, 0xff, 0xf));EXPORT_SYMBOL_GPL (amd_erratum_400); -const int amd_erratum_383[] = +static const int amd_erratum_383[] =AMD_OSVW_ERRATUM (3 ,AMD_MODEL_RANGE (0x10 ,0 ,0 ,0xff ,0xf )); -EXPORT_SYMBOL_GPL (amd_erratum_383);bool cpu_has_amd_erratum (const int *erratum) {
arch/x86/kvm/svm.c +1 -1
@@ -555,7 +555,7 @@ static void svm_init_erratum_383(void)int err;u64 val; -if (!cpu_has_amd_erratum (amd_erratum_383)) +if (!static_cpu_has_bug (X86_BUG_AMD_TLB_MMATCH ))return ;/* Use _safe variants to not break nested virtualization */
Borislav Petkov
maintainerPATCH 6/6 x86, cpu: Convert AMD Erratum 400
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
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.
--- arch/x86/include/asm/cpufeature.h | 1 + arch/x86/include/asm/processor.h | 19 ------------------- arch/x86/kernel/cpu/amd.c | 23 ++++++++++++++++------- arch/x86/kernel/process.c | 2 +- 4 files changed, 18 insertions(+), 27 deletions(-)
arch/x86/include/asm/cpufeature.h +1 -0
@@ -226,6 +226,7 @@#define X86_BUG_FDIV X86_BUG(1)/* FPU FDIV */ #define X86_BUG_COMA X86_BUG(2)/* Cyrix 6x86 coma */ #define X86_BUG_AMD_TLB_MMATCH X86_BUG(3)/* AMD Erratum 383 */ +#define X86_BUG_AMD_APIC_C1E X86_BUG(4)/* AMD Erratum 400 */ #if defined(__KERNEL__) && !defined(__ASSEMBLY__)
arch/x86/include/asm/processor.h +0 -19
@@ -970,25 +970,6 @@ unsigned long calc_aperfmperf_ratio(struct aperfmperf *old,return ratio; } -/* -* AMD errata checking -*/ -#ifdef CONFIG_CPU_SUP_AMD -extern const int amd_erratum_400[]; -extern bool cpu_has_amd_erratum (const int *); - -#define AMD_LEGACY_ERRATUM (...) { -1, __VA_ARGS__, 0 } -#define AMD_OSVW_ERRATUM (osvw_id, ...) { osvw_id, __VA_ARGS__, 0 } -#define AMD_MODEL_RANGE (f, m_start, s_start, m_end, s_end) \ - ((f << 24) | (m_start << 16) | (s_start << 12) | (m_end << 4) | (s_end)) -#define AMD_MODEL_RANGE_FAMILY (range) (((range) >> 24) & 0xff) -#define AMD_MODEL_RANGE_START (range) (((range) >> 12) & 0xfff) -#define AMD_MODEL_RANGE_END (range) ((range) & 0xfff) - -#else -#define cpu_has_amd_erratum (x) (false) -#endif /* CONFIG_CPU_SUP_AMD */ -extern unsigned long arch_align_stack (unsigned long sp);extern void free_init_pages (char *what,unsigned long begin,unsigned long end);
arch/x86/kernel/cpu/amd.c +16 -7
@@ -514,6 +514,8 @@ static void __cpuinit early_init_amd(struct cpuinfo_x86 *c) }static const int amd_erratum_383[]; +static const int amd_erratum_400[]; +static bool cpu_has_amd_erratum (const int *erratum);static void __cpuinit init_amd (struct cpuinfo_x86 *c) {
@@ -734,6 +736,9 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)set_cpu_bug (c,X86_BUG_AMD_TLB_MMATCH ); } +if (cpu_has_amd_erratum (amd_erratum_400)) +set_cpu_bug (c,X86_BUG_AMD_APIC_C1E ); +rdmsr_safe (MSR_AMD64_PATCH_LEVEL , &c->microcode, &dummy); }
@@ -852,8 +857,7 @@ cpu_dev_register(amd_cpu_dev);* AMD_OSVW_ERRATUM() macros. The latter is intended for newer errata that * have an OSVW id assigned, which it takes as first argument. Both take a * variable number of family-specific model-stepping ranges created by -* AMD_MODEL_RANGE(). Each erratum also has to be declared as extern const -* int[] in arch/x86/include/asm/processor.h. +* AMD_MODEL_RANGE(). * * Example: *
@@ -863,15 +867,22 @@ cpu_dev_register(amd_cpu_dev);* AMD_MODEL_RANGE(0x10, 0x9, 0x0, 0x9, 0x0)); */ -const int amd_erratum_400[] = +#define AMD_LEGACY_ERRATUM (...) { -1, __VA_ARGS__, 0 } +#define AMD_OSVW_ERRATUM (osvw_id, ...) { osvw_id, __VA_ARGS__, 0 } +#define AMD_MODEL_RANGE (f, m_start, s_start, m_end, s_end) \ + ((f << 24) | (m_start << 16) | (s_start << 12) | (m_end << 4) | (s_end)) +#define AMD_MODEL_RANGE_FAMILY (range) (((range) >> 24) & 0xff) +#define AMD_MODEL_RANGE_START (range) (((range) >> 12) & 0xfff) +#define AMD_MODEL_RANGE_END (range) ((range) & 0xfff) + +static const int amd_erratum_400[] =AMD_OSVW_ERRATUM (1 ,AMD_MODEL_RANGE (0xf ,0x41 ,0x2 ,0xff ,0xf ),AMD_MODEL_RANGE (0x10 ,0x2 ,0x1 ,0xff ,0xf )); -EXPORT_SYMBOL_GPL (amd_erratum_400);static const int amd_erratum_383[] =AMD_OSVW_ERRATUM (3 ,AMD_MODEL_RANGE (0x10 ,0 ,0 ,0xff ,0xf )); -bool cpu_has_amd_erratum (const int *erratum) +static bool cpu_has_amd_erratum (const int *erratum) {struct cpuinfo_x86 *cpu =__this_cpu_ptr (&cpu_info);int osvw_id = *erratum++;
@@ -912,5 +923,3 @@ bool cpu_has_amd_erratum(const int *erratum)return false; } - -EXPORT_SYMBOL_GPL (cpu_has_amd_erratum);
arch/x86/kernel/process.c +1 -1
@@ -495,7 +495,7 @@ void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c)if (x86_idle)return ; -if (cpu_has_amd_erratum (amd_erratum_400)) { +if (cpu_has_bug (c,X86_BUG_AMD_APIC_C1E )) {/* E400: APIC timer interrupt does not wake up CPU from C1e */ pr_info ("using AMD E400 aware idle routine\n" ); x86_idle = amd_e400_idle;
Signature · 1 line
1.8.1.3.535.ga923c31
tip-bot for Borislav Petkov
merge bot[tip:x86/cpu] x86, cpu: Convert AMD Erratum 400
x86, cpu: Convert AMD Erratum 400
Commit-ID: 7d7dc116e56c8a1ba4beb36d06a77a48fe5f750b Gitweb: http://git.kernel.org/tip/7d7dc116e56c8a1ba4beb36d06a77a48fe5f750b Author: Borislav Petkov <[email protected]> AuthorDate: Wed, 20 Mar 2013 15:07:28 +0100 Committer: H. Peter Anvin <[email protected]> CommitDate: Tue, 2 Apr 2013 10:12:55 -0700
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.
--- arch/x86/include/asm/cpufeature.h | 1 + arch/x86/include/asm/processor.h | 19 ------------------- arch/x86/kernel/cpu/amd.c | 23 ++++++++++++++++------- arch/x86/kernel/process.c | 2 +- 4 files changed, 18 insertions(+), 27 deletions(-)
arch/x86/include/asm/cpufeature.h +1 -0
@@ -226,6 +226,7 @@#define X86_BUG_FDIV X86_BUG(1)/* FPU FDIV */ #define X86_BUG_COMA X86_BUG(2)/* Cyrix 6x86 coma */ #define X86_BUG_AMD_TLB_MMATCH X86_BUG(3)/* AMD Erratum 383 */ +#define X86_BUG_AMD_APIC_C1E X86_BUG(4)/* AMD Erratum 400 */ #if defined(__KERNEL__) && !defined(__ASSEMBLY__)
arch/x86/include/asm/processor.h +0 -19
@@ -970,25 +970,6 @@ unsigned long calc_aperfmperf_ratio(struct aperfmperf *old,return ratio; } -/* -* AMD errata checking -*/ -#ifdef CONFIG_CPU_SUP_AMD -extern const int amd_erratum_400[]; -extern bool cpu_has_amd_erratum (const int *); - -#define AMD_LEGACY_ERRATUM (...) { -1, __VA_ARGS__, 0 } -#define AMD_OSVW_ERRATUM (osvw_id, ...) { osvw_id, __VA_ARGS__, 0 } -#define AMD_MODEL_RANGE (f, m_start, s_start, m_end, s_end) \ - ((f << 24) | (m_start << 16) | (s_start << 12) | (m_end << 4) | (s_end)) -#define AMD_MODEL_RANGE_FAMILY (range) (((range) >> 24) & 0xff) -#define AMD_MODEL_RANGE_START (range) (((range) >> 12) & 0xfff) -#define AMD_MODEL_RANGE_END (range) ((range) & 0xfff) - -#else -#define cpu_has_amd_erratum (x) (false) -#endif /* CONFIG_CPU_SUP_AMD */ -extern unsigned long arch_align_stack (unsigned long sp);extern void free_init_pages (char *what,unsigned long begin,unsigned long end);
arch/x86/kernel/cpu/amd.c +16 -7
@@ -514,6 +514,8 @@ static void __cpuinit early_init_amd(struct cpuinfo_x86 *c) }static const int amd_erratum_383[]; +static const int amd_erratum_400[]; +static bool cpu_has_amd_erratum (const int *erratum);static void __cpuinit init_amd (struct cpuinfo_x86 *c) {
@@ -734,6 +736,9 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)set_cpu_bug (c,X86_BUG_AMD_TLB_MMATCH ); } +if (cpu_has_amd_erratum (amd_erratum_400)) +set_cpu_bug (c,X86_BUG_AMD_APIC_C1E ); +rdmsr_safe (MSR_AMD64_PATCH_LEVEL , &c->microcode, &dummy); }
@@ -852,8 +857,7 @@ cpu_dev_register(amd_cpu_dev);* AMD_OSVW_ERRATUM() macros. The latter is intended for newer errata that * have an OSVW id assigned, which it takes as first argument. Both take a * variable number of family-specific model-stepping ranges created by -* AMD_MODEL_RANGE(). Each erratum also has to be declared as extern const -* int[] in arch/x86/include/asm/processor.h. +* AMD_MODEL_RANGE(). * * Example: *
@@ -863,15 +867,22 @@ cpu_dev_register(amd_cpu_dev);* AMD_MODEL_RANGE(0x10, 0x9, 0x0, 0x9, 0x0)); */ -const int amd_erratum_400[] = +#define AMD_LEGACY_ERRATUM (...) { -1, __VA_ARGS__, 0 } +#define AMD_OSVW_ERRATUM (osvw_id, ...) { osvw_id, __VA_ARGS__, 0 } +#define AMD_MODEL_RANGE (f, m_start, s_start, m_end, s_end) \ + ((f << 24) | (m_start << 16) | (s_start << 12) | (m_end << 4) | (s_end)) +#define AMD_MODEL_RANGE_FAMILY (range) (((range) >> 24) & 0xff) +#define AMD_MODEL_RANGE_START (range) (((range) >> 12) & 0xfff) +#define AMD_MODEL_RANGE_END (range) ((range) & 0xfff) + +static const int amd_erratum_400[] =AMD_OSVW_ERRATUM (1 ,AMD_MODEL_RANGE (0xf ,0x41 ,0x2 ,0xff ,0xf ),AMD_MODEL_RANGE (0x10 ,0x2 ,0x1 ,0xff ,0xf )); -EXPORT_SYMBOL_GPL (amd_erratum_400);static const int amd_erratum_383[] =AMD_OSVW_ERRATUM (3 ,AMD_MODEL_RANGE (0x10 ,0 ,0 ,0xff ,0xf )); -bool cpu_has_amd_erratum (const int *erratum) +static bool cpu_has_amd_erratum (const int *erratum) {struct cpuinfo_x86 *cpu =__this_cpu_ptr (&cpu_info);int osvw_id = *erratum++;
@@ -912,5 +923,3 @@ bool cpu_has_amd_erratum(const int *erratum)return false; } - -EXPORT_SYMBOL_GPL (cpu_has_amd_erratum);
arch/x86/kernel/process.c +1 -1
@@ -495,7 +495,7 @@ void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c)if (x86_idle)return ; -if (cpu_has_amd_erratum (amd_erratum_400)) { +if (cpu_has_bug (c,X86_BUG_AMD_APIC_C1E )) {/* E400: APIC timer interrupt does not wake up CPU from C1e */ pr_info ("using AMD E400 aware idle routine\n" ); x86_idle = amd_e400_idle;