x86 fixes
Subsystems (2)
Linus,
Please pull the latest x86-fixes-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git x86-fixes-for-linus
The NOP impact is a bit wider than what i'd like, but it addresses the VirtualPC regression and it's what Peter tested - and also Peter's solution of turning enhanced NOPs into a virtual CPUID flag that is tested before use is kind of elegant IMO and reduces some of the mess and risks.
The memory leak fixes are old commits freshly cherry-picked over from another branch (i already ran a few test builds and test boots of it) - they have a lot of test time already otherwise, i just missed their .27 impact.
Thanks,
Ingo
------------------>
Andreas Herrmann (2):
x86: pda_init(): fix memory leak when using CPU hotplug
x86: cpu_init(): fix memory leak when using CPU hotplug
Eduardo Habkost (1):
x86, xen: Use native_pte_flags instead of native_pte_val for .pte_flags
H. Peter Anvin (3):
x86: boot: stub out unimplemented CPU feature words
x86: add NOPL as a synthetic CPU feature bit
x86: use X86_FEATURE_NOPL in alternatives
Krzysztof Helt (1):
x86: delay early cpu initialization until cpuid is done
Yinghai Lu (1):
x86: move mtrr cpu cap setting early in early_init_xxxx
arch/x86/boot/cpucheck.c | 8 ++-- arch/x86/kernel/alternative.c | 36 ++++++----------- arch/x86/kernel/cpu/amd.c | 9 ++-- arch/x86/kernel/cpu/centaur.c | 11 +++++ arch/x86/kernel/cpu/common.c | 34 +++++++++++++++- arch/x86/kernel/cpu/common_64.c | 74 +++++++++++++++++++++++++++------- arch/x86/kernel/cpu/cyrix.c | 32 +++++++++++++-- arch/x86/kernel/cpu/feature_names.c | 3 +- arch/x86/xen/enlighten.c | 2 +- include/asm-x86/cpufeature.h | 11 +++-- include/asm-x86/required-features.h | 8 +++- 11 files changed, 167 insertions(+), 61 deletions(-)
arch/x86/boot/cpucheck.c +4 -4
@@ -38,12 +38,12 @@ static const u32 req_flags[NCAPINTS] = {REQUIRED_MASK0 ,REQUIRED_MASK1 , -REQUIRED_MASK2 , -REQUIRED_MASK3 , +0 ,/* REQUIRED_MASK2 not implemented in this file */ +0 ,/* REQUIRED_MASK3 not implemented in this file */ REQUIRED_MASK4 , -REQUIRED_MASK5 , +0 ,/* REQUIRED_MASK5 not implemented in this file */ REQUIRED_MASK6 , - REQUIRED_MASK7, + 0, /* REQUIRED_MASK7 not implemented in this file */ };#define A32 (a, b, c, d) (((d) << 24)+((c) << 16)+((b) << 8)+(a))
arch/x86/kernel/alternative.c +13 -23
@@ -145,35 +145,25 @@ static const unsigned char *const p6_nops[ASM_NOP_MAX+1] = {extern char __vsyscall_0;const unsigned char *const *find_nop_table (void ) { -return boot_cpu_data.x86_vendor !=X86_VENDOR_INTEL || - boot_cpu_data.x86 <6 ? k8_nops : p6_nops; +if (boot_cpu_data.x86_vendor ==X86_VENDOR_INTEL && +boot_cpu_has (X86_FEATURE_NOPL )) +return p6_nops; +else +return k8_nops; }#else /* CONFIG_X86_64 */ -static const struct nop { -int cpuid; -const unsigned char *const *noptable; -} noptypes[] = { - {X86_FEATURE_K8 , k8_nops }, - {X86_FEATURE_K7 , k7_nops }, - {X86_FEATURE_P4 , p6_nops }, - {X86_FEATURE_P3 , p6_nops }, - {-1 ,NULL } -}; -const unsigned char *const *find_nop_table (void ) { -const unsigned char *const *noptable = intel_nops; -int i; - -for (i =0 ; noptypes[i].cpuid >=0 ; i++) { -if (boot_cpu_has (noptypes[i].cpuid)) { - noptable = noptypes[i].noptable; -break ; - } - } -return noptable; +if (boot_cpu_has (X86_FEATURE_K8 )) +return k8_nops; +else if (boot_cpu_has (X86_FEATURE_K7 )) +return k7_nops; +else if (boot_cpu_has (X86_FEATURE_NOPL )) +return p6_nops; +else +return intel_nops; }#endif /* CONFIG_X86_64 */
arch/x86/kernel/cpu/amd.c +5 -4
@@ -31,6 +31,11 @@ static void __cpuinit early_init_amd(struct cpuinfo_x86 *c)if (c->x86_power & (1 <<8 ))set_cpu_cap (c,X86_FEATURE_CONSTANT_TSC ); } + +/* Set MTRR capability flag if appropriate */ +if (c->x86_model ==13 || c->x86_model ==9 || + (c->x86_model ==8 && c->x86_mask >=8 )) +set_cpu_cap (c,X86_FEATURE_K6_MTRR ); }static void __cpuinit init_amd (struct cpuinfo_x86 *c)
@@ -166,10 +171,6 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c) mbytes); } -/* Set MTRR capability flag if appropriate */ -if (c->x86_model ==13 || c->x86_model ==9 || - (c->x86_model ==8 && c->x86_mask >=8 )) -set_cpu_cap (c,X86_FEATURE_K6_MTRR );break ; }
arch/x86/kernel/cpu/centaur.c +11 -0
@@ -314,6 +314,16 @@ enum { EAMD3D = 1<<20, }; +static void __cpuinit early_init_centaur (struct cpuinfo_x86 *c) +{ +switch (c->x86) { +case 5 : +/* Emulate MTRRs using Centaur's MCR. */ +set_cpu_cap (c,X86_FEATURE_CENTAUR_MCR ); +break ; + } +} +static void __cpuinit init_centaur (struct cpuinfo_x86 *c) {
@@ -462,6 +472,7 @@ centaur_size_cache(struct cpuinfo_x86 *c, unsigned int size)static struct cpu_dev centaur_cpu_dev__cpuinitdata = { .c_vendor ="Centaur" , .c_ident = {"CentaurHauls" }, + .c_early_init = early_init_centaur, .c_init = init_centaur, .c_size_cache = centaur_size_cache, };
arch/x86/kernel/cpu/common.c +32 -2
@@ -13,6 +13,7 @@#include <asm/mtrr.h> #include <asm/mce.h> #include <asm/pat.h> +#include <asm/asm.h> #ifdef CONFIG_X86_LOCAL_APIC #include <asm/mpspec.h> #include <asm/apic.h>
@@ -334,11 +335,40 @@ static void __init early_cpu_detect(void)get_cpu_vendor (c,1 ); +early_get_cap (c); +if (c->x86_vendor !=X86_VENDOR_UNKNOWN && cpu_devs[c->x86_vendor]->c_early_init) cpu_devs[c->x86_vendor]->c_early_init (c); +} -early_get_cap (c); +/* +* The NOPL instruction is supposed to exist on all CPUs with +* family >= 6, unfortunately, that's not true in practice because +* of early VIA chips and (more importantly) broken virtualizers that +* are not easy to detect. Hence, probe for it based on first +* principles. +*/ +static void __cpuinit detect_nopl (struct cpuinfo_x86 *c) +{ +const u32 nopl_signature =0x888c53b1 ;/* Random number */ +u32 has_nopl = nopl_signature; + +clear_cpu_cap (c,X86_FEATURE_NOPL ); +if (c->x86 >=6 ) { + asmvolatile ("\n" +"1: .byte 0x0f,0x1f,0xc0\n" /* nopl %eax */ +"2:\n" +" .section .fixup,\"ax\"\n" +"3: xor %0,%0\n" +" jmp 2b\n" +" .previous\n" + _ASM_EXTABLE(1b,3b) + : "+a" (has_nopl)); + + if (has_nopl == nopl_signature) +set_cpu_cap (c,X86_FEATURE_NOPL ); + } }static void __cpuinit generic_identify (struct cpuinfo_x86 *c)
@@ -395,8 +425,8 @@ static void __cpuinit generic_identify(struct cpuinfo_x86 *c) }init_scattered_cpuid_features (c); +detect_nopl (c); } - }static void __cpuinit squash_the_stupid_serial_number (struct cpuinfo_x86 *c)
arch/x86/kernel/cpu/common_64.c +58 -16
112 lines not on this page · raw message
arch/x86/kernel/cpu/cyrix.c +28 -4
@@ -15,13 +15,11 @@/* * Read NSC/Cyrix DEVID registers (DIR) to get more detailed info. about the CPU */ -static void __cpuinit do_cyrix_devid (unsigned char *dir0,unsigned char *dir1) +static void __cpuinit __do_cyrix_devid (unsigned char *dir0,unsigned char *dir1) {unsigned char ccr2, ccr3; -unsigned long flags;/* we test for DEVID by checking whether CCR3 is writable */ -local_irq_save (flags); ccr3 =getCx86 (CX86_CCR3 );setCx86 (CX86_CCR3 , ccr3 ^0x80 );getCx86 (0xc0 );/* dummy to change bus */
@@ -44,9 +42,16 @@ static void __cpuinit do_cyrix_devid(unsigned char *dir0, unsigned char *dir1) *dir0 =getCx86 (CX86_DIR0 ); *dir1 =getCx86 (CX86_DIR1 ); } -local_irq_restore (flags); } +static void __cpuinit do_cyrix_devid (unsigned char *dir0,unsigned char *dir1) +{ +unsigned long flags; + +local_irq_save (flags); +__do_cyrix_devid (dir0, dir1); +local_irq_restore (flags); +}/* * Cx86_dir0_msb is a HACK needed by check_cx686_cpuid/slop in bugs.h in * order to identify the Cyrix CPU model after we're out of setup.c
@@ -161,6 +166,24 @@ static void __cpuinit geode_configure(void)local_irq_restore (flags); } +static void __cpuinit early_init_cyrix (struct cpuinfo_x86 *c) +{ +unsigned char dir0, dir0_msn, dir1 =0 ; + +__do_cyrix_devid (&dir0, &dir1); + dir0_msn = dir0 >>4 ;/* identifies CPU "family" */ + +switch (dir0_msn) { +case 3 :/* 6x86/6x86L */ +/* Emulate MTRRs using Cyrix's ARRs. */ +set_cpu_cap (c,X86_FEATURE_CYRIX_ARR ); +break ; +case 5 :/* 6x86MX/M II */ +/* Emulate MTRRs using Cyrix's ARRs. */ +set_cpu_cap (c,X86_FEATURE_CYRIX_ARR ); +break ; + } +}static void __cpuinit init_cyrix (struct cpuinfo_x86 *c) {
@@ -416,6 +439,7 @@ static void __cpuinit cyrix_identify(struct cpuinfo_x86 *c)static struct cpu_dev cyrix_cpu_dev__cpuinitdata = { .c_vendor ="Cyrix" , .c_ident = {"CyrixInstead" }, + .c_early_init = early_init_cyrix, .c_init = init_cyrix, .c_identify = cyrix_identify, };
arch/x86/kernel/cpu/feature_names.c +2 -1
@@ -39,7 +39,8 @@ const char * const x86_cap_flags[NCAPINTS*32] = {NULL ,NULL ,NULL ,NULL ,"constant_tsc" ,"up" ,NULL ,"arch_perfmon" ,"pebs" ,"bts" ,NULL ,NULL , -"rep_good" ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL , +"rep_good" ,NULL ,NULL ,NULL , +"nopl" ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL , /* Intel-defined (#2) */
arch/x86/xen/enlighten.c +1 -1
@@ -1324,7 +1324,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initdata = { .ptep_modify_prot_commit = __ptep_modify_prot_commit, .pte_val = xen_pte_val, - .pte_flags = native_pte_val, + .pte_flags = native_pte_flags, .pgd_val = xen_pgd_val, .make_pte = xen_make_pte,
include/asm-x86/cpufeature.h +6 -5
@@ -72,14 +72,15 @@#define X86_FEATURE_UP (3*32+ 9)/* smp kernel running on up */ #define X86_FEATURE_FXSAVE_LEAK (3*32+10)/* FXSAVE leaks FOP/FIP/FOP */ #define X86_FEATURE_ARCH_PERFMON (3*32+11)/* Intel Architectural PerfMon */ -#define X86_FEATURE_PEBS (3*32+12)/* Precise-Event Based Sampling */ -#define X86_FEATURE_BTS (3*32+13)/* Branch Trace Store */ -#define X86_FEATURE_SYSCALL32 (3*32+14)/* syscall in ia32 userspace */ -#define X86_FEATURE_SYSENTER32 (3*32+15)/* sysenter in ia32 userspace */ +#define X86_FEATURE_PEBS (3*32+12)/* Precise-Event Based Sampling */ +#define X86_FEATURE_BTS (3*32+13)/* Branch Trace Store */ +#define X86_FEATURE_SYSCALL32 (3*32+14)/* syscall in ia32 userspace */ +#define X86_FEATURE_SYSENTER32 (3*32+15)/* sysenter in ia32 userspace */ #define X86_FEATURE_REP_GOOD (3*32+16)/* rep microcode works well on this CPU */ #define X86_FEATURE_MFENCE_RDTSC (3*32+17)/* Mfence synchronizes RDTSC */ #define X86_FEATURE_LFENCE_RDTSC (3*32+18)/* Lfence synchronizes RDTSC */ -#define X86_FEATURE_11AP (3*32+19)/* Bad local APIC aka 11AP */ +#define X86_FEATURE_11AP (3*32+19)/* Bad local APIC aka 11AP */ +#define X86_FEATURE_NOPL (3*32+20)/* The NOPL (0F 1F) instructions */ /* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */ #define X86_FEATURE_XMM3 (4*32+ 0)/* Streaming SIMD Extensions-3 */
include/asm-x86/required-features.h +7 -1
@@ -41,6 +41,12 @@# define NEED_3DNOW 0#endif +#if defined(CONFIG_X86_P6_NOP ) || defined(CONFIG_X86_64 ) +# define NEED_NOPL (1<<(X86_FEATURE_NOPL & 31)) +#else +# define NEED_NOPL 0 +#endif +#ifdef CONFIG_X86_64 #define NEED_PSE 0#define NEED_MSR (1<<(X86_FEATURE_MSR & 31))
@@ -67,7 +73,7 @@#define REQUIRED_MASK1 (NEED_LM|NEED_3DNOW)#define REQUIRED_MASK2 0 -#define REQUIRED_MASK3 0 +#define REQUIRED_MASK3 (NEED_NOPL)#define REQUIRED_MASK4 0#define REQUIRED_MASK5 0#define REQUIRED_MASK6 0