diff options
author | Yinghai Lu <yinghai@kernel.org> | 2009-05-10 02:47:42 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-05-11 04:57:24 -0400 |
commit | 3e0c373749d7eb5b354ac0b043f2b2cdf84eefef (patch) | |
tree | 473870b2f527ce227cb729db35dbe226ce95a7d1 | |
parent | 3969c52d4d2fef5a4b9e3ab0e51b3901e1cc8b83 (diff) |
x86: clean up and fix setup_clear/force_cpu_cap handling
setup_force_cpu_cap() only have one user (Xen guest code),
but it should not reuse cleared_cpu_cpus, otherwise it
will have problems on SMP.
Need to have a separate cpu_cpus_set array too, for forced-on
flags, beyond the forced-off flags.
Also need to setup handling before all cpus caps are combined.
[ Impact: fix the forced-set CPU feature flag logic ]
Cc: H. Peter Anvin <hpa@linux.intel.com>
Cc: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Yinghai Lu <yinghai.lu@kernel.org>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | arch/x86/include/asm/cpufeature.h | 4 | ||||
-rw-r--r-- | arch/x86/include/asm/processor.h | 3 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/common.c | 17 |
3 files changed, 16 insertions, 8 deletions
diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h index ccc1061b8b25..13cc6a503a02 100644 --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h | |||
@@ -192,11 +192,11 @@ extern const char * const x86_power_flags[32]; | |||
192 | #define clear_cpu_cap(c, bit) clear_bit(bit, (unsigned long *)((c)->x86_capability)) | 192 | #define clear_cpu_cap(c, bit) clear_bit(bit, (unsigned long *)((c)->x86_capability)) |
193 | #define setup_clear_cpu_cap(bit) do { \ | 193 | #define setup_clear_cpu_cap(bit) do { \ |
194 | clear_cpu_cap(&boot_cpu_data, bit); \ | 194 | clear_cpu_cap(&boot_cpu_data, bit); \ |
195 | set_bit(bit, (unsigned long *)cleared_cpu_caps); \ | 195 | set_bit(bit, (unsigned long *)cpu_caps_cleared); \ |
196 | } while (0) | 196 | } while (0) |
197 | #define setup_force_cpu_cap(bit) do { \ | 197 | #define setup_force_cpu_cap(bit) do { \ |
198 | set_cpu_cap(&boot_cpu_data, bit); \ | 198 | set_cpu_cap(&boot_cpu_data, bit); \ |
199 | clear_bit(bit, (unsigned long *)cleared_cpu_caps); \ | 199 | set_bit(bit, (unsigned long *)cpu_caps_set); \ |
200 | } while (0) | 200 | } while (0) |
201 | 201 | ||
202 | #define cpu_has_fpu boot_cpu_has(X86_FEATURE_FPU) | 202 | #define cpu_has_fpu boot_cpu_has(X86_FEATURE_FPU) |
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index c2cceae709c8..fed93fec9764 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h | |||
@@ -135,7 +135,8 @@ extern struct cpuinfo_x86 boot_cpu_data; | |||
135 | extern struct cpuinfo_x86 new_cpu_data; | 135 | extern struct cpuinfo_x86 new_cpu_data; |
136 | 136 | ||
137 | extern struct tss_struct doublefault_tss; | 137 | extern struct tss_struct doublefault_tss; |
138 | extern __u32 cleared_cpu_caps[NCAPINTS]; | 138 | extern __u32 cpu_caps_cleared[NCAPINTS]; |
139 | extern __u32 cpu_caps_set[NCAPINTS]; | ||
139 | 140 | ||
140 | #ifdef CONFIG_SMP | 141 | #ifdef CONFIG_SMP |
141 | DECLARE_PER_CPU_SHARED_ALIGNED(struct cpuinfo_x86, cpu_info); | 142 | DECLARE_PER_CPU_SHARED_ALIGNED(struct cpuinfo_x86, cpu_info); |
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index c4f667896c28..e7fd5c4935a3 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c | |||
@@ -292,7 +292,8 @@ static const char *__cpuinit table_lookup_model(struct cpuinfo_x86 *c) | |||
292 | return NULL; /* Not found */ | 292 | return NULL; /* Not found */ |
293 | } | 293 | } |
294 | 294 | ||
295 | __u32 cleared_cpu_caps[NCAPINTS] __cpuinitdata; | 295 | __u32 cpu_caps_cleared[NCAPINTS] __cpuinitdata; |
296 | __u32 cpu_caps_set[NCAPINTS] __cpuinitdata; | ||
296 | 297 | ||
297 | void load_percpu_segment(int cpu) | 298 | void load_percpu_segment(int cpu) |
298 | { | 299 | { |
@@ -806,6 +807,16 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c) | |||
806 | #endif | 807 | #endif |
807 | 808 | ||
808 | init_hypervisor(c); | 809 | init_hypervisor(c); |
810 | |||
811 | /* | ||
812 | * Clear/Set all flags overriden by options, need do it | ||
813 | * before following smp all cpus cap AND. | ||
814 | */ | ||
815 | for (i = 0; i < NCAPINTS; i++) { | ||
816 | c->x86_capability[i] &= ~cpu_caps_cleared[i]; | ||
817 | c->x86_capability[i] |= cpu_caps_set[i]; | ||
818 | } | ||
819 | |||
809 | /* | 820 | /* |
810 | * On SMP, boot_cpu_data holds the common feature set between | 821 | * On SMP, boot_cpu_data holds the common feature set between |
811 | * all CPUs; so make sure that we indicate which features are | 822 | * all CPUs; so make sure that we indicate which features are |
@@ -818,10 +829,6 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c) | |||
818 | boot_cpu_data.x86_capability[i] &= c->x86_capability[i]; | 829 | boot_cpu_data.x86_capability[i] &= c->x86_capability[i]; |
819 | } | 830 | } |
820 | 831 | ||
821 | /* Clear all flags overriden by options */ | ||
822 | for (i = 0; i < NCAPINTS; i++) | ||
823 | c->x86_capability[i] &= ~cleared_cpu_caps[i]; | ||
824 | |||
825 | #ifdef CONFIG_X86_MCE | 832 | #ifdef CONFIG_X86_MCE |
826 | /* Init Machine Check Exception if available. */ | 833 | /* Init Machine Check Exception if available. */ |
827 | mcheck_init(c); | 834 | mcheck_init(c); |