diff options
Diffstat (limited to 'arch/x86/kernel/cpu/common.c')
-rw-r--r-- | arch/x86/kernel/cpu/common.c | 396 |
1 files changed, 224 insertions, 172 deletions
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 826d5c876278..e2962cc1e27b 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c | |||
@@ -1,52 +1,52 @@ | |||
1 | #include <linux/init.h> | ||
2 | #include <linux/kernel.h> | ||
3 | #include <linux/sched.h> | ||
4 | #include <linux/string.h> | ||
5 | #include <linux/bootmem.h> | 1 | #include <linux/bootmem.h> |
2 | #include <linux/linkage.h> | ||
6 | #include <linux/bitops.h> | 3 | #include <linux/bitops.h> |
4 | #include <linux/kernel.h> | ||
7 | #include <linux/module.h> | 5 | #include <linux/module.h> |
8 | #include <linux/kgdb.h> | 6 | #include <linux/percpu.h> |
9 | #include <linux/topology.h> | 7 | #include <linux/string.h> |
10 | #include <linux/delay.h> | 8 | #include <linux/delay.h> |
9 | #include <linux/sched.h> | ||
10 | #include <linux/init.h> | ||
11 | #include <linux/kgdb.h> | ||
11 | #include <linux/smp.h> | 12 | #include <linux/smp.h> |
12 | #include <linux/percpu.h> | 13 | #include <linux/io.h> |
13 | #include <asm/i387.h> | 14 | |
14 | #include <asm/msr.h> | 15 | #include <asm/stackprotector.h> |
15 | #include <asm/io.h> | ||
16 | #include <asm/linkage.h> | ||
17 | #include <asm/mmu_context.h> | 16 | #include <asm/mmu_context.h> |
17 | #include <asm/hypervisor.h> | ||
18 | #include <asm/processor.h> | ||
19 | #include <asm/sections.h> | ||
20 | #include <asm/topology.h> | ||
21 | #include <asm/cpumask.h> | ||
22 | #include <asm/pgtable.h> | ||
23 | #include <asm/atomic.h> | ||
24 | #include <asm/proto.h> | ||
25 | #include <asm/setup.h> | ||
26 | #include <asm/apic.h> | ||
27 | #include <asm/desc.h> | ||
28 | #include <asm/i387.h> | ||
18 | #include <asm/mtrr.h> | 29 | #include <asm/mtrr.h> |
30 | #include <asm/numa.h> | ||
31 | #include <asm/asm.h> | ||
32 | #include <asm/cpu.h> | ||
19 | #include <asm/mce.h> | 33 | #include <asm/mce.h> |
34 | #include <asm/msr.h> | ||
20 | #include <asm/pat.h> | 35 | #include <asm/pat.h> |
21 | #include <asm/asm.h> | ||
22 | #include <asm/numa.h> | ||
23 | #include <asm/smp.h> | 36 | #include <asm/smp.h> |
24 | #include <asm/cpu.h> | ||
25 | #include <asm/cpumask.h> | ||
26 | #include <asm/apic.h> | ||
27 | 37 | ||
28 | #ifdef CONFIG_X86_LOCAL_APIC | 38 | #ifdef CONFIG_X86_LOCAL_APIC |
29 | #include <asm/uv/uv.h> | 39 | #include <asm/uv/uv.h> |
30 | #endif | 40 | #endif |
31 | 41 | ||
32 | #include <asm/pgtable.h> | ||
33 | #include <asm/processor.h> | ||
34 | #include <asm/desc.h> | ||
35 | #include <asm/atomic.h> | ||
36 | #include <asm/proto.h> | ||
37 | #include <asm/sections.h> | ||
38 | #include <asm/setup.h> | ||
39 | #include <asm/hypervisor.h> | ||
40 | #include <asm/stackprotector.h> | ||
41 | |||
42 | #include "cpu.h" | 42 | #include "cpu.h" |
43 | 43 | ||
44 | #ifdef CONFIG_X86_64 | 44 | #ifdef CONFIG_X86_64 |
45 | 45 | ||
46 | /* all of these masks are initialized in setup_cpu_local_masks() */ | 46 | /* all of these masks are initialized in setup_cpu_local_masks() */ |
47 | cpumask_var_t cpu_callin_mask; | ||
48 | cpumask_var_t cpu_callout_mask; | ||
49 | cpumask_var_t cpu_initialized_mask; | 47 | cpumask_var_t cpu_initialized_mask; |
48 | cpumask_var_t cpu_callout_mask; | ||
49 | cpumask_var_t cpu_callin_mask; | ||
50 | 50 | ||
51 | /* representing cpus for which sibling maps can be computed */ | 51 | /* representing cpus for which sibling maps can be computed */ |
52 | cpumask_var_t cpu_sibling_setup_mask; | 52 | cpumask_var_t cpu_sibling_setup_mask; |
@@ -62,15 +62,15 @@ void __init setup_cpu_local_masks(void) | |||
62 | 62 | ||
63 | #else /* CONFIG_X86_32 */ | 63 | #else /* CONFIG_X86_32 */ |
64 | 64 | ||
65 | cpumask_t cpu_callin_map; | 65 | cpumask_t cpu_sibling_setup_map; |
66 | cpumask_t cpu_callout_map; | 66 | cpumask_t cpu_callout_map; |
67 | cpumask_t cpu_initialized; | 67 | cpumask_t cpu_initialized; |
68 | cpumask_t cpu_sibling_setup_map; | 68 | cpumask_t cpu_callin_map; |
69 | 69 | ||
70 | #endif /* CONFIG_X86_32 */ | 70 | #endif /* CONFIG_X86_32 */ |
71 | 71 | ||
72 | 72 | ||
73 | static struct cpu_dev *this_cpu __cpuinitdata; | 73 | static const struct cpu_dev *this_cpu __cpuinitdata; |
74 | 74 | ||
75 | DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = { | 75 | DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = { |
76 | #ifdef CONFIG_X86_64 | 76 | #ifdef CONFIG_X86_64 |
@@ -79,48 +79,48 @@ DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = { | |||
79 | * IRET will check the segment types kkeil 2000/10/28 | 79 | * IRET will check the segment types kkeil 2000/10/28 |
80 | * Also sysret mandates a special GDT layout | 80 | * Also sysret mandates a special GDT layout |
81 | * | 81 | * |
82 | * The TLS descriptors are currently at a different place compared to i386. | 82 | * TLS descriptors are currently at a different place compared to i386. |
83 | * Hopefully nobody expects them at a fixed place (Wine?) | 83 | * Hopefully nobody expects them at a fixed place (Wine?) |
84 | */ | 84 | */ |
85 | [GDT_ENTRY_KERNEL32_CS] = { { { 0x0000ffff, 0x00cf9b00 } } }, | 85 | [GDT_ENTRY_KERNEL32_CS] = { { { 0x0000ffff, 0x00cf9b00 } } }, |
86 | [GDT_ENTRY_KERNEL_CS] = { { { 0x0000ffff, 0x00af9b00 } } }, | 86 | [GDT_ENTRY_KERNEL_CS] = { { { 0x0000ffff, 0x00af9b00 } } }, |
87 | [GDT_ENTRY_KERNEL_DS] = { { { 0x0000ffff, 0x00cf9300 } } }, | 87 | [GDT_ENTRY_KERNEL_DS] = { { { 0x0000ffff, 0x00cf9300 } } }, |
88 | [GDT_ENTRY_DEFAULT_USER32_CS] = { { { 0x0000ffff, 0x00cffb00 } } }, | 88 | [GDT_ENTRY_DEFAULT_USER32_CS] = { { { 0x0000ffff, 0x00cffb00 } } }, |
89 | [GDT_ENTRY_DEFAULT_USER_DS] = { { { 0x0000ffff, 0x00cff300 } } }, | 89 | [GDT_ENTRY_DEFAULT_USER_DS] = { { { 0x0000ffff, 0x00cff300 } } }, |
90 | [GDT_ENTRY_DEFAULT_USER_CS] = { { { 0x0000ffff, 0x00affb00 } } }, | 90 | [GDT_ENTRY_DEFAULT_USER_CS] = { { { 0x0000ffff, 0x00affb00 } } }, |
91 | #else | 91 | #else |
92 | [GDT_ENTRY_KERNEL_CS] = { { { 0x0000ffff, 0x00cf9a00 } } }, | 92 | [GDT_ENTRY_KERNEL_CS] = { { { 0x0000ffff, 0x00cf9a00 } } }, |
93 | [GDT_ENTRY_KERNEL_DS] = { { { 0x0000ffff, 0x00cf9200 } } }, | 93 | [GDT_ENTRY_KERNEL_DS] = { { { 0x0000ffff, 0x00cf9200 } } }, |
94 | [GDT_ENTRY_DEFAULT_USER_CS] = { { { 0x0000ffff, 0x00cffa00 } } }, | 94 | [GDT_ENTRY_DEFAULT_USER_CS] = { { { 0x0000ffff, 0x00cffa00 } } }, |
95 | [GDT_ENTRY_DEFAULT_USER_DS] = { { { 0x0000ffff, 0x00cff200 } } }, | 95 | [GDT_ENTRY_DEFAULT_USER_DS] = { { { 0x0000ffff, 0x00cff200 } } }, |
96 | /* | 96 | /* |
97 | * Segments used for calling PnP BIOS have byte granularity. | 97 | * Segments used for calling PnP BIOS have byte granularity. |
98 | * They code segments and data segments have fixed 64k limits, | 98 | * They code segments and data segments have fixed 64k limits, |
99 | * the transfer segment sizes are set at run time. | 99 | * the transfer segment sizes are set at run time. |
100 | */ | 100 | */ |
101 | /* 32-bit code */ | 101 | /* 32-bit code */ |
102 | [GDT_ENTRY_PNPBIOS_CS32] = { { { 0x0000ffff, 0x00409a00 } } }, | 102 | [GDT_ENTRY_PNPBIOS_CS32] = { { { 0x0000ffff, 0x00409a00 } } }, |
103 | /* 16-bit code */ | 103 | /* 16-bit code */ |
104 | [GDT_ENTRY_PNPBIOS_CS16] = { { { 0x0000ffff, 0x00009a00 } } }, | 104 | [GDT_ENTRY_PNPBIOS_CS16] = { { { 0x0000ffff, 0x00009a00 } } }, |
105 | /* 16-bit data */ | 105 | /* 16-bit data */ |
106 | [GDT_ENTRY_PNPBIOS_DS] = { { { 0x0000ffff, 0x00009200 } } }, | 106 | [GDT_ENTRY_PNPBIOS_DS] = { { { 0x0000ffff, 0x00009200 } } }, |
107 | /* 16-bit data */ | 107 | /* 16-bit data */ |
108 | [GDT_ENTRY_PNPBIOS_TS1] = { { { 0x00000000, 0x00009200 } } }, | 108 | [GDT_ENTRY_PNPBIOS_TS1] = { { { 0x00000000, 0x00009200 } } }, |
109 | /* 16-bit data */ | 109 | /* 16-bit data */ |
110 | [GDT_ENTRY_PNPBIOS_TS2] = { { { 0x00000000, 0x00009200 } } }, | 110 | [GDT_ENTRY_PNPBIOS_TS2] = { { { 0x00000000, 0x00009200 } } }, |
111 | /* | 111 | /* |
112 | * The APM segments have byte granularity and their bases | 112 | * The APM segments have byte granularity and their bases |
113 | * are set at run time. All have 64k limits. | 113 | * are set at run time. All have 64k limits. |
114 | */ | 114 | */ |
115 | /* 32-bit code */ | 115 | /* 32-bit code */ |
116 | [GDT_ENTRY_APMBIOS_BASE] = { { { 0x0000ffff, 0x00409a00 } } }, | 116 | [GDT_ENTRY_APMBIOS_BASE] = { { { 0x0000ffff, 0x00409a00 } } }, |
117 | /* 16-bit code */ | 117 | /* 16-bit code */ |
118 | [GDT_ENTRY_APMBIOS_BASE+1] = { { { 0x0000ffff, 0x00009a00 } } }, | 118 | [GDT_ENTRY_APMBIOS_BASE+1] = { { { 0x0000ffff, 0x00009a00 } } }, |
119 | /* data */ | 119 | /* data */ |
120 | [GDT_ENTRY_APMBIOS_BASE+2] = { { { 0x0000ffff, 0x00409200 } } }, | 120 | [GDT_ENTRY_APMBIOS_BASE+2] = { { { 0x0000ffff, 0x00409200 } } }, |
121 | 121 | ||
122 | [GDT_ENTRY_ESPFIX_SS] = { { { 0x00000000, 0x00c09200 } } }, | 122 | [GDT_ENTRY_ESPFIX_SS] = { { { 0x00000000, 0x00c09200 } } }, |
123 | [GDT_ENTRY_PERCPU] = { { { 0x0000ffff, 0x00cf9200 } } }, | 123 | [GDT_ENTRY_PERCPU] = { { { 0x0000ffff, 0x00cf9200 } } }, |
124 | GDT_STACK_CANARY_INIT | 124 | GDT_STACK_CANARY_INIT |
125 | #endif | 125 | #endif |
126 | } }; | 126 | } }; |
@@ -164,16 +164,17 @@ static inline int flag_is_changeable_p(u32 flag) | |||
164 | * the CPUID. Add "volatile" to not allow gcc to | 164 | * the CPUID. Add "volatile" to not allow gcc to |
165 | * optimize the subsequent calls to this function. | 165 | * optimize the subsequent calls to this function. |
166 | */ | 166 | */ |
167 | asm volatile ("pushfl\n\t" | 167 | asm volatile ("pushfl \n\t" |
168 | "pushfl\n\t" | 168 | "pushfl \n\t" |
169 | "popl %0\n\t" | 169 | "popl %0 \n\t" |
170 | "movl %0,%1\n\t" | 170 | "movl %0, %1 \n\t" |
171 | "xorl %2,%0\n\t" | 171 | "xorl %2, %0 \n\t" |
172 | "pushl %0\n\t" | 172 | "pushl %0 \n\t" |
173 | "popfl\n\t" | 173 | "popfl \n\t" |
174 | "pushfl\n\t" | 174 | "pushfl \n\t" |
175 | "popl %0\n\t" | 175 | "popl %0 \n\t" |
176 | "popfl\n\t" | 176 | "popfl \n\t" |
177 | |||
177 | : "=&r" (f1), "=&r" (f2) | 178 | : "=&r" (f1), "=&r" (f2) |
178 | : "ir" (flag)); | 179 | : "ir" (flag)); |
179 | 180 | ||
@@ -188,18 +189,22 @@ static int __cpuinit have_cpuid_p(void) | |||
188 | 189 | ||
189 | static void __cpuinit squash_the_stupid_serial_number(struct cpuinfo_x86 *c) | 190 | static void __cpuinit squash_the_stupid_serial_number(struct cpuinfo_x86 *c) |
190 | { | 191 | { |
191 | if (cpu_has(c, X86_FEATURE_PN) && disable_x86_serial_nr) { | 192 | unsigned long lo, hi; |
192 | /* Disable processor serial number */ | 193 | |
193 | unsigned long lo, hi; | 194 | if (!cpu_has(c, X86_FEATURE_PN) || !disable_x86_serial_nr) |
194 | rdmsr(MSR_IA32_BBL_CR_CTL, lo, hi); | 195 | return; |
195 | lo |= 0x200000; | 196 | |
196 | wrmsr(MSR_IA32_BBL_CR_CTL, lo, hi); | 197 | /* Disable processor serial number: */ |
197 | printk(KERN_NOTICE "CPU serial number disabled.\n"); | 198 | |
198 | clear_cpu_cap(c, X86_FEATURE_PN); | 199 | rdmsr(MSR_IA32_BBL_CR_CTL, lo, hi); |
199 | 200 | lo |= 0x200000; | |
200 | /* Disabling the serial number may affect the cpuid level */ | 201 | wrmsr(MSR_IA32_BBL_CR_CTL, lo, hi); |
201 | c->cpuid_level = cpuid_eax(0); | 202 | |
202 | } | 203 | printk(KERN_NOTICE "CPU serial number disabled.\n"); |
204 | clear_cpu_cap(c, X86_FEATURE_PN); | ||
205 | |||
206 | /* Disabling the serial number may affect the cpuid level */ | ||
207 | c->cpuid_level = cpuid_eax(0); | ||
203 | } | 208 | } |
204 | 209 | ||
205 | static int __init x86_serial_nr_setup(char *s) | 210 | static int __init x86_serial_nr_setup(char *s) |
@@ -232,6 +237,7 @@ struct cpuid_dependent_feature { | |||
232 | u32 feature; | 237 | u32 feature; |
233 | u32 level; | 238 | u32 level; |
234 | }; | 239 | }; |
240 | |||
235 | static const struct cpuid_dependent_feature __cpuinitconst | 241 | static const struct cpuid_dependent_feature __cpuinitconst |
236 | cpuid_dependent_features[] = { | 242 | cpuid_dependent_features[] = { |
237 | { X86_FEATURE_MWAIT, 0x00000005 }, | 243 | { X86_FEATURE_MWAIT, 0x00000005 }, |
@@ -243,7 +249,11 @@ cpuid_dependent_features[] = { | |||
243 | static void __cpuinit filter_cpuid_features(struct cpuinfo_x86 *c, bool warn) | 249 | static void __cpuinit filter_cpuid_features(struct cpuinfo_x86 *c, bool warn) |
244 | { | 250 | { |
245 | const struct cpuid_dependent_feature *df; | 251 | const struct cpuid_dependent_feature *df; |
252 | |||
246 | for (df = cpuid_dependent_features; df->feature; df++) { | 253 | for (df = cpuid_dependent_features; df->feature; df++) { |
254 | |||
255 | if (!cpu_has(c, df->feature)) | ||
256 | continue; | ||
247 | /* | 257 | /* |
248 | * Note: cpuid_level is set to -1 if unavailable, but | 258 | * Note: cpuid_level is set to -1 if unavailable, but |
249 | * extended_extended_level is set to 0 if unavailable | 259 | * extended_extended_level is set to 0 if unavailable |
@@ -251,32 +261,32 @@ static void __cpuinit filter_cpuid_features(struct cpuinfo_x86 *c, bool warn) | |||
251 | * when signed; hence the weird messing around with | 261 | * when signed; hence the weird messing around with |
252 | * signs here... | 262 | * signs here... |
253 | */ | 263 | */ |
254 | if (cpu_has(c, df->feature) && | 264 | if (!((s32)df->level < 0 ? |
255 | ((s32)df->level < 0 ? | ||
256 | (u32)df->level > (u32)c->extended_cpuid_level : | 265 | (u32)df->level > (u32)c->extended_cpuid_level : |
257 | (s32)df->level > (s32)c->cpuid_level)) { | 266 | (s32)df->level > (s32)c->cpuid_level)) |
258 | clear_cpu_cap(c, df->feature); | 267 | continue; |
259 | if (warn) | 268 | |
260 | printk(KERN_WARNING | 269 | clear_cpu_cap(c, df->feature); |
261 | "CPU: CPU feature %s disabled " | 270 | if (!warn) |
262 | "due to lack of CPUID level 0x%x\n", | 271 | continue; |
263 | x86_cap_flags[df->feature], | 272 | |
264 | df->level); | 273 | printk(KERN_WARNING |
265 | } | 274 | "CPU: CPU feature %s disabled, no CPUID level 0x%x\n", |
275 | x86_cap_flags[df->feature], df->level); | ||
266 | } | 276 | } |
267 | } | 277 | } |
268 | 278 | ||
269 | /* | 279 | /* |
270 | * Naming convention should be: <Name> [(<Codename>)] | 280 | * Naming convention should be: <Name> [(<Codename>)] |
271 | * This table only is used unless init_<vendor>() below doesn't set it; | 281 | * This table only is used unless init_<vendor>() below doesn't set it; |
272 | * in particular, if CPUID levels 0x80000002..4 are supported, this isn't used | 282 | * in particular, if CPUID levels 0x80000002..4 are supported, this |
273 | * | 283 | * isn't used |
274 | */ | 284 | */ |
275 | 285 | ||
276 | /* Look up CPU names by table lookup. */ | 286 | /* Look up CPU names by table lookup. */ |
277 | static char __cpuinit *table_lookup_model(struct cpuinfo_x86 *c) | 287 | static const char *__cpuinit table_lookup_model(struct cpuinfo_x86 *c) |
278 | { | 288 | { |
279 | struct cpu_model_info *info; | 289 | const struct cpu_model_info *info; |
280 | 290 | ||
281 | if (c->x86_model >= 16) | 291 | if (c->x86_model >= 16) |
282 | return NULL; /* Range check */ | 292 | return NULL; /* Range check */ |
@@ -307,8 +317,10 @@ void load_percpu_segment(int cpu) | |||
307 | load_stack_canary_segment(); | 317 | load_stack_canary_segment(); |
308 | } | 318 | } |
309 | 319 | ||
310 | /* Current gdt points %fs at the "master" per-cpu area: after this, | 320 | /* |
311 | * it's on the real one. */ | 321 | * Current gdt points %fs at the "master" per-cpu area: after this, |
322 | * it's on the real one. | ||
323 | */ | ||
312 | void switch_to_new_gdt(int cpu) | 324 | void switch_to_new_gdt(int cpu) |
313 | { | 325 | { |
314 | struct desc_ptr gdt_descr; | 326 | struct desc_ptr gdt_descr; |
@@ -321,7 +333,7 @@ void switch_to_new_gdt(int cpu) | |||
321 | load_percpu_segment(cpu); | 333 | load_percpu_segment(cpu); |
322 | } | 334 | } |
323 | 335 | ||
324 | static struct cpu_dev *cpu_devs[X86_VENDOR_NUM] = {}; | 336 | static const struct cpu_dev *__cpuinitdata cpu_devs[X86_VENDOR_NUM] = {}; |
325 | 337 | ||
326 | static void __cpuinit default_init(struct cpuinfo_x86 *c) | 338 | static void __cpuinit default_init(struct cpuinfo_x86 *c) |
327 | { | 339 | { |
@@ -340,7 +352,7 @@ static void __cpuinit default_init(struct cpuinfo_x86 *c) | |||
340 | #endif | 352 | #endif |
341 | } | 353 | } |
342 | 354 | ||
343 | static struct cpu_dev __cpuinitdata default_cpu = { | 355 | static const struct cpu_dev __cpuinitconst default_cpu = { |
344 | .c_init = default_init, | 356 | .c_init = default_init, |
345 | .c_vendor = "Unknown", | 357 | .c_vendor = "Unknown", |
346 | .c_x86_vendor = X86_VENDOR_UNKNOWN, | 358 | .c_x86_vendor = X86_VENDOR_UNKNOWN, |
@@ -354,22 +366,24 @@ static void __cpuinit get_model_name(struct cpuinfo_x86 *c) | |||
354 | if (c->extended_cpuid_level < 0x80000004) | 366 | if (c->extended_cpuid_level < 0x80000004) |
355 | return; | 367 | return; |
356 | 368 | ||
357 | v = (unsigned int *) c->x86_model_id; | 369 | v = (unsigned int *)c->x86_model_id; |
358 | cpuid(0x80000002, &v[0], &v[1], &v[2], &v[3]); | 370 | cpuid(0x80000002, &v[0], &v[1], &v[2], &v[3]); |
359 | cpuid(0x80000003, &v[4], &v[5], &v[6], &v[7]); | 371 | cpuid(0x80000003, &v[4], &v[5], &v[6], &v[7]); |
360 | cpuid(0x80000004, &v[8], &v[9], &v[10], &v[11]); | 372 | cpuid(0x80000004, &v[8], &v[9], &v[10], &v[11]); |
361 | c->x86_model_id[48] = 0; | 373 | c->x86_model_id[48] = 0; |
362 | 374 | ||
363 | /* Intel chips right-justify this string for some dumb reason; | 375 | /* |
364 | undo that brain damage */ | 376 | * Intel chips right-justify this string for some dumb reason; |
377 | * undo that brain damage: | ||
378 | */ | ||
365 | p = q = &c->x86_model_id[0]; | 379 | p = q = &c->x86_model_id[0]; |
366 | while (*p == ' ') | 380 | while (*p == ' ') |
367 | p++; | 381 | p++; |
368 | if (p != q) { | 382 | if (p != q) { |
369 | while (*p) | 383 | while (*p) |
370 | *q++ = *p++; | 384 | *q++ = *p++; |
371 | while (q <= &c->x86_model_id[48]) | 385 | while (q <= &c->x86_model_id[48]) |
372 | *q++ = '\0'; /* Zero-pad the rest */ | 386 | *q++ = '\0'; /* Zero-pad the rest */ |
373 | } | 387 | } |
374 | } | 388 | } |
375 | 389 | ||
@@ -438,27 +452,30 @@ void __cpuinit detect_ht(struct cpuinfo_x86 *c) | |||
438 | 452 | ||
439 | if (smp_num_siblings == 1) { | 453 | if (smp_num_siblings == 1) { |
440 | printk(KERN_INFO "CPU: Hyper-Threading is disabled\n"); | 454 | printk(KERN_INFO "CPU: Hyper-Threading is disabled\n"); |
441 | } else if (smp_num_siblings > 1) { | 455 | goto out; |
456 | } | ||
442 | 457 | ||
443 | if (smp_num_siblings > nr_cpu_ids) { | 458 | if (smp_num_siblings <= 1) |
444 | printk(KERN_WARNING "CPU: Unsupported number of siblings %d", | 459 | goto out; |
445 | smp_num_siblings); | 460 | |
446 | smp_num_siblings = 1; | 461 | if (smp_num_siblings > nr_cpu_ids) { |
447 | return; | 462 | pr_warning("CPU: Unsupported number of siblings %d", |
448 | } | 463 | smp_num_siblings); |
464 | smp_num_siblings = 1; | ||
465 | return; | ||
466 | } | ||
449 | 467 | ||
450 | index_msb = get_count_order(smp_num_siblings); | 468 | index_msb = get_count_order(smp_num_siblings); |
451 | c->phys_proc_id = apic->phys_pkg_id(c->initial_apicid, index_msb); | 469 | c->phys_proc_id = apic->phys_pkg_id(c->initial_apicid, index_msb); |
452 | 470 | ||
453 | smp_num_siblings = smp_num_siblings / c->x86_max_cores; | 471 | smp_num_siblings = smp_num_siblings / c->x86_max_cores; |
454 | 472 | ||
455 | index_msb = get_count_order(smp_num_siblings); | 473 | index_msb = get_count_order(smp_num_siblings); |
456 | 474 | ||
457 | core_bits = get_count_order(c->x86_max_cores); | 475 | core_bits = get_count_order(c->x86_max_cores); |
458 | 476 | ||
459 | c->cpu_core_id = apic->phys_pkg_id(c->initial_apicid, index_msb) & | 477 | c->cpu_core_id = apic->phys_pkg_id(c->initial_apicid, index_msb) & |
460 | ((1 << core_bits) - 1); | 478 | ((1 << core_bits) - 1); |
461 | } | ||
462 | 479 | ||
463 | out: | 480 | out: |
464 | if ((c->x86_max_cores * smp_num_siblings) > 1) { | 481 | if ((c->x86_max_cores * smp_num_siblings) > 1) { |
@@ -473,8 +490,8 @@ out: | |||
473 | static void __cpuinit get_cpu_vendor(struct cpuinfo_x86 *c) | 490 | static void __cpuinit get_cpu_vendor(struct cpuinfo_x86 *c) |
474 | { | 491 | { |
475 | char *v = c->x86_vendor_id; | 492 | char *v = c->x86_vendor_id; |
476 | int i; | ||
477 | static int printed; | 493 | static int printed; |
494 | int i; | ||
478 | 495 | ||
479 | for (i = 0; i < X86_VENDOR_NUM; i++) { | 496 | for (i = 0; i < X86_VENDOR_NUM; i++) { |
480 | if (!cpu_devs[i]) | 497 | if (!cpu_devs[i]) |
@@ -483,6 +500,7 @@ static void __cpuinit get_cpu_vendor(struct cpuinfo_x86 *c) | |||
483 | if (!strcmp(v, cpu_devs[i]->c_ident[0]) || | 500 | if (!strcmp(v, cpu_devs[i]->c_ident[0]) || |
484 | (cpu_devs[i]->c_ident[1] && | 501 | (cpu_devs[i]->c_ident[1] && |
485 | !strcmp(v, cpu_devs[i]->c_ident[1]))) { | 502 | !strcmp(v, cpu_devs[i]->c_ident[1]))) { |
503 | |||
486 | this_cpu = cpu_devs[i]; | 504 | this_cpu = cpu_devs[i]; |
487 | c->x86_vendor = this_cpu->c_x86_vendor; | 505 | c->x86_vendor = this_cpu->c_x86_vendor; |
488 | return; | 506 | return; |
@@ -491,7 +509,9 @@ static void __cpuinit get_cpu_vendor(struct cpuinfo_x86 *c) | |||
491 | 509 | ||
492 | if (!printed) { | 510 | if (!printed) { |
493 | printed++; | 511 | printed++; |
494 | printk(KERN_ERR "CPU: vendor_id '%s' unknown, using generic init.\n", v); | 512 | printk(KERN_ERR |
513 | "CPU: vendor_id '%s' unknown, using generic init.\n", v); | ||
514 | |||
495 | printk(KERN_ERR "CPU: Your system may be unstable.\n"); | 515 | printk(KERN_ERR "CPU: Your system may be unstable.\n"); |
496 | } | 516 | } |
497 | 517 | ||
@@ -511,14 +531,17 @@ void __cpuinit cpu_detect(struct cpuinfo_x86 *c) | |||
511 | /* Intel-defined flags: level 0x00000001 */ | 531 | /* Intel-defined flags: level 0x00000001 */ |
512 | if (c->cpuid_level >= 0x00000001) { | 532 | if (c->cpuid_level >= 0x00000001) { |
513 | u32 junk, tfms, cap0, misc; | 533 | u32 junk, tfms, cap0, misc; |
534 | |||
514 | cpuid(0x00000001, &tfms, &misc, &junk, &cap0); | 535 | cpuid(0x00000001, &tfms, &misc, &junk, &cap0); |
515 | c->x86 = (tfms >> 8) & 0xf; | 536 | c->x86 = (tfms >> 8) & 0xf; |
516 | c->x86_model = (tfms >> 4) & 0xf; | 537 | c->x86_model = (tfms >> 4) & 0xf; |
517 | c->x86_mask = tfms & 0xf; | 538 | c->x86_mask = tfms & 0xf; |
539 | |||
518 | if (c->x86 == 0xf) | 540 | if (c->x86 == 0xf) |
519 | c->x86 += (tfms >> 20) & 0xff; | 541 | c->x86 += (tfms >> 20) & 0xff; |
520 | if (c->x86 >= 0x6) | 542 | if (c->x86 >= 0x6) |
521 | c->x86_model += ((tfms >> 16) & 0xf) << 4; | 543 | c->x86_model += ((tfms >> 16) & 0xf) << 4; |
544 | |||
522 | if (cap0 & (1<<19)) { | 545 | if (cap0 & (1<<19)) { |
523 | c->x86_clflush_size = ((misc >> 8) & 0xff) * 8; | 546 | c->x86_clflush_size = ((misc >> 8) & 0xff) * 8; |
524 | c->x86_cache_alignment = c->x86_clflush_size; | 547 | c->x86_cache_alignment = c->x86_clflush_size; |
@@ -534,6 +557,7 @@ static void __cpuinit get_cpu_cap(struct cpuinfo_x86 *c) | |||
534 | /* Intel-defined flags: level 0x00000001 */ | 557 | /* Intel-defined flags: level 0x00000001 */ |
535 | if (c->cpuid_level >= 0x00000001) { | 558 | if (c->cpuid_level >= 0x00000001) { |
536 | u32 capability, excap; | 559 | u32 capability, excap; |
560 | |||
537 | cpuid(0x00000001, &tfms, &ebx, &excap, &capability); | 561 | cpuid(0x00000001, &tfms, &ebx, &excap, &capability); |
538 | c->x86_capability[0] = capability; | 562 | c->x86_capability[0] = capability; |
539 | c->x86_capability[4] = excap; | 563 | c->x86_capability[4] = excap; |
@@ -542,6 +566,7 @@ static void __cpuinit get_cpu_cap(struct cpuinfo_x86 *c) | |||
542 | /* AMD-defined flags: level 0x80000001 */ | 566 | /* AMD-defined flags: level 0x80000001 */ |
543 | xlvl = cpuid_eax(0x80000000); | 567 | xlvl = cpuid_eax(0x80000000); |
544 | c->extended_cpuid_level = xlvl; | 568 | c->extended_cpuid_level = xlvl; |
569 | |||
545 | if ((xlvl & 0xffff0000) == 0x80000000) { | 570 | if ((xlvl & 0xffff0000) == 0x80000000) { |
546 | if (xlvl >= 0x80000001) { | 571 | if (xlvl >= 0x80000001) { |
547 | c->x86_capability[1] = cpuid_edx(0x80000001); | 572 | c->x86_capability[1] = cpuid_edx(0x80000001); |
@@ -549,13 +574,15 @@ static void __cpuinit get_cpu_cap(struct cpuinfo_x86 *c) | |||
549 | } | 574 | } |
550 | } | 575 | } |
551 | 576 | ||
552 | #ifdef CONFIG_X86_64 | ||
553 | if (c->extended_cpuid_level >= 0x80000008) { | 577 | if (c->extended_cpuid_level >= 0x80000008) { |
554 | u32 eax = cpuid_eax(0x80000008); | 578 | u32 eax = cpuid_eax(0x80000008); |
555 | 579 | ||
556 | c->x86_virt_bits = (eax >> 8) & 0xff; | 580 | c->x86_virt_bits = (eax >> 8) & 0xff; |
557 | c->x86_phys_bits = eax & 0xff; | 581 | c->x86_phys_bits = eax & 0xff; |
558 | } | 582 | } |
583 | #ifdef CONFIG_X86_32 | ||
584 | else if (cpu_has(c, X86_FEATURE_PAE) || cpu_has(c, X86_FEATURE_PSE36)) | ||
585 | c->x86_phys_bits = 36; | ||
559 | #endif | 586 | #endif |
560 | 587 | ||
561 | if (c->extended_cpuid_level >= 0x80000007) | 588 | if (c->extended_cpuid_level >= 0x80000007) |
@@ -602,8 +629,12 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c) | |||
602 | { | 629 | { |
603 | #ifdef CONFIG_X86_64 | 630 | #ifdef CONFIG_X86_64 |
604 | c->x86_clflush_size = 64; | 631 | c->x86_clflush_size = 64; |
632 | c->x86_phys_bits = 36; | ||
633 | c->x86_virt_bits = 48; | ||
605 | #else | 634 | #else |
606 | c->x86_clflush_size = 32; | 635 | c->x86_clflush_size = 32; |
636 | c->x86_phys_bits = 32; | ||
637 | c->x86_virt_bits = 32; | ||
607 | #endif | 638 | #endif |
608 | c->x86_cache_alignment = c->x86_clflush_size; | 639 | c->x86_cache_alignment = c->x86_clflush_size; |
609 | 640 | ||
@@ -634,12 +665,12 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c) | |||
634 | 665 | ||
635 | void __init early_cpu_init(void) | 666 | void __init early_cpu_init(void) |
636 | { | 667 | { |
637 | struct cpu_dev **cdev; | 668 | const struct cpu_dev *const *cdev; |
638 | int count = 0; | 669 | int count = 0; |
639 | 670 | ||
640 | printk("KERNEL supported cpus:\n"); | 671 | printk(KERN_INFO "KERNEL supported cpus:\n"); |
641 | for (cdev = __x86_cpu_dev_start; cdev < __x86_cpu_dev_end; cdev++) { | 672 | for (cdev = __x86_cpu_dev_start; cdev < __x86_cpu_dev_end; cdev++) { |
642 | struct cpu_dev *cpudev = *cdev; | 673 | const struct cpu_dev *cpudev = *cdev; |
643 | unsigned int j; | 674 | unsigned int j; |
644 | 675 | ||
645 | if (count >= X86_VENDOR_NUM) | 676 | if (count >= X86_VENDOR_NUM) |
@@ -650,7 +681,7 @@ void __init early_cpu_init(void) | |||
650 | for (j = 0; j < 2; j++) { | 681 | for (j = 0; j < 2; j++) { |
651 | if (!cpudev->c_ident[j]) | 682 | if (!cpudev->c_ident[j]) |
652 | continue; | 683 | continue; |
653 | printk(" %s %s\n", cpudev->c_vendor, | 684 | printk(KERN_INFO " %s %s\n", cpudev->c_vendor, |
654 | cpudev->c_ident[j]); | 685 | cpudev->c_ident[j]); |
655 | } | 686 | } |
656 | } | 687 | } |
@@ -726,9 +757,13 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c) | |||
726 | c->x86_coreid_bits = 0; | 757 | c->x86_coreid_bits = 0; |
727 | #ifdef CONFIG_X86_64 | 758 | #ifdef CONFIG_X86_64 |
728 | c->x86_clflush_size = 64; | 759 | c->x86_clflush_size = 64; |
760 | c->x86_phys_bits = 36; | ||
761 | c->x86_virt_bits = 48; | ||
729 | #else | 762 | #else |
730 | c->cpuid_level = -1; /* CPUID not detected */ | 763 | c->cpuid_level = -1; /* CPUID not detected */ |
731 | c->x86_clflush_size = 32; | 764 | c->x86_clflush_size = 32; |
765 | c->x86_phys_bits = 32; | ||
766 | c->x86_virt_bits = 32; | ||
732 | #endif | 767 | #endif |
733 | c->x86_cache_alignment = c->x86_clflush_size; | 768 | c->x86_cache_alignment = c->x86_clflush_size; |
734 | memset(&c->x86_capability, 0, sizeof c->x86_capability); | 769 | memset(&c->x86_capability, 0, sizeof c->x86_capability); |
@@ -759,8 +794,8 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c) | |||
759 | squash_the_stupid_serial_number(c); | 794 | squash_the_stupid_serial_number(c); |
760 | 795 | ||
761 | /* | 796 | /* |
762 | * The vendor-specific functions might have changed features. Now | 797 | * The vendor-specific functions might have changed features. |
763 | * we do "generic changes." | 798 | * Now we do "generic changes." |
764 | */ | 799 | */ |
765 | 800 | ||
766 | /* Filter out anything that depends on CPUID levels we don't have */ | 801 | /* Filter out anything that depends on CPUID levels we don't have */ |
@@ -768,7 +803,7 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c) | |||
768 | 803 | ||
769 | /* If the model name is still unset, do table lookup. */ | 804 | /* If the model name is still unset, do table lookup. */ |
770 | if (!c->x86_model_id[0]) { | 805 | if (!c->x86_model_id[0]) { |
771 | char *p; | 806 | const char *p; |
772 | p = table_lookup_model(c); | 807 | p = table_lookup_model(c); |
773 | if (p) | 808 | if (p) |
774 | strcpy(c->x86_model_id, p); | 809 | strcpy(c->x86_model_id, p); |
@@ -843,11 +878,11 @@ void __cpuinit identify_secondary_cpu(struct cpuinfo_x86 *c) | |||
843 | } | 878 | } |
844 | 879 | ||
845 | struct msr_range { | 880 | struct msr_range { |
846 | unsigned min; | 881 | unsigned min; |
847 | unsigned max; | 882 | unsigned max; |
848 | }; | 883 | }; |
849 | 884 | ||
850 | static struct msr_range msr_range_array[] __cpuinitdata = { | 885 | static const struct msr_range msr_range_array[] __cpuinitconst = { |
851 | { 0x00000000, 0x00000418}, | 886 | { 0x00000000, 0x00000418}, |
852 | { 0xc0000000, 0xc000040b}, | 887 | { 0xc0000000, 0xc000040b}, |
853 | { 0xc0010000, 0xc0010142}, | 888 | { 0xc0010000, 0xc0010142}, |
@@ -856,14 +891,15 @@ static struct msr_range msr_range_array[] __cpuinitdata = { | |||
856 | 891 | ||
857 | static void __cpuinit print_cpu_msr(void) | 892 | static void __cpuinit print_cpu_msr(void) |
858 | { | 893 | { |
894 | unsigned index_min, index_max; | ||
859 | unsigned index; | 895 | unsigned index; |
860 | u64 val; | 896 | u64 val; |
861 | int i; | 897 | int i; |
862 | unsigned index_min, index_max; | ||
863 | 898 | ||
864 | for (i = 0; i < ARRAY_SIZE(msr_range_array); i++) { | 899 | for (i = 0; i < ARRAY_SIZE(msr_range_array); i++) { |
865 | index_min = msr_range_array[i].min; | 900 | index_min = msr_range_array[i].min; |
866 | index_max = msr_range_array[i].max; | 901 | index_max = msr_range_array[i].max; |
902 | |||
867 | for (index = index_min; index < index_max; index++) { | 903 | for (index = index_min; index < index_max; index++) { |
868 | if (rdmsrl_amd_safe(index, &val)) | 904 | if (rdmsrl_amd_safe(index, &val)) |
869 | continue; | 905 | continue; |
@@ -873,6 +909,7 @@ static void __cpuinit print_cpu_msr(void) | |||
873 | } | 909 | } |
874 | 910 | ||
875 | static int show_msr __cpuinitdata; | 911 | static int show_msr __cpuinitdata; |
912 | |||
876 | static __init int setup_show_msr(char *arg) | 913 | static __init int setup_show_msr(char *arg) |
877 | { | 914 | { |
878 | int num; | 915 | int num; |
@@ -894,12 +931,14 @@ __setup("noclflush", setup_noclflush); | |||
894 | 931 | ||
895 | void __cpuinit print_cpu_info(struct cpuinfo_x86 *c) | 932 | void __cpuinit print_cpu_info(struct cpuinfo_x86 *c) |
896 | { | 933 | { |
897 | char *vendor = NULL; | 934 | const char *vendor = NULL; |
898 | 935 | ||
899 | if (c->x86_vendor < X86_VENDOR_NUM) | 936 | if (c->x86_vendor < X86_VENDOR_NUM) { |
900 | vendor = this_cpu->c_vendor; | 937 | vendor = this_cpu->c_vendor; |
901 | else if (c->cpuid_level >= 0) | 938 | } else { |
902 | vendor = c->x86_vendor_id; | 939 | if (c->cpuid_level >= 0) |
940 | vendor = c->x86_vendor_id; | ||
941 | } | ||
903 | 942 | ||
904 | if (vendor && !strstr(c->x86_model_id, vendor)) | 943 | if (vendor && !strstr(c->x86_model_id, vendor)) |
905 | printk(KERN_CONT "%s ", vendor); | 944 | printk(KERN_CONT "%s ", vendor); |
@@ -926,10 +965,12 @@ void __cpuinit print_cpu_info(struct cpuinfo_x86 *c) | |||
926 | static __init int setup_disablecpuid(char *arg) | 965 | static __init int setup_disablecpuid(char *arg) |
927 | { | 966 | { |
928 | int bit; | 967 | int bit; |
968 | |||
929 | if (get_option(&arg, &bit) && bit < NCAPINTS*32) | 969 | if (get_option(&arg, &bit) && bit < NCAPINTS*32) |
930 | setup_clear_cpu_cap(bit); | 970 | setup_clear_cpu_cap(bit); |
931 | else | 971 | else |
932 | return 0; | 972 | return 0; |
973 | |||
933 | return 1; | 974 | return 1; |
934 | } | 975 | } |
935 | __setup("clearcpuid=", setup_disablecpuid); | 976 | __setup("clearcpuid=", setup_disablecpuid); |
@@ -939,6 +980,7 @@ struct desc_ptr idt_descr = { 256 * 16 - 1, (unsigned long) idt_table }; | |||
939 | 980 | ||
940 | DEFINE_PER_CPU_FIRST(union irq_stack_union, | 981 | DEFINE_PER_CPU_FIRST(union irq_stack_union, |
941 | irq_stack_union) __aligned(PAGE_SIZE); | 982 | irq_stack_union) __aligned(PAGE_SIZE); |
983 | |||
942 | DEFINE_PER_CPU(char *, irq_stack_ptr) = | 984 | DEFINE_PER_CPU(char *, irq_stack_ptr) = |
943 | init_per_cpu_var(irq_stack_union.irq_stack) + IRQ_STACK_SIZE - 64; | 985 | init_per_cpu_var(irq_stack_union.irq_stack) + IRQ_STACK_SIZE - 64; |
944 | 986 | ||
@@ -948,12 +990,21 @@ EXPORT_PER_CPU_SYMBOL(kernel_stack); | |||
948 | 990 | ||
949 | DEFINE_PER_CPU(unsigned int, irq_count) = -1; | 991 | DEFINE_PER_CPU(unsigned int, irq_count) = -1; |
950 | 992 | ||
993 | /* | ||
994 | * Special IST stacks which the CPU switches to when it calls | ||
995 | * an IST-marked descriptor entry. Up to 7 stacks (hardware | ||
996 | * limit), all of them are 4K, except the debug stack which | ||
997 | * is 8K. | ||
998 | */ | ||
999 | static const unsigned int exception_stack_sizes[N_EXCEPTION_STACKS] = { | ||
1000 | [0 ... N_EXCEPTION_STACKS - 1] = EXCEPTION_STKSZ, | ||
1001 | [DEBUG_STACK - 1] = DEBUG_STKSZ | ||
1002 | }; | ||
1003 | |||
951 | static DEFINE_PER_CPU_PAGE_ALIGNED(char, exception_stacks | 1004 | static DEFINE_PER_CPU_PAGE_ALIGNED(char, exception_stacks |
952 | [(N_EXCEPTION_STACKS - 1) * EXCEPTION_STKSZ + DEBUG_STKSZ]) | 1005 | [(N_EXCEPTION_STACKS - 1) * EXCEPTION_STKSZ + DEBUG_STKSZ]) |
953 | __aligned(PAGE_SIZE); | 1006 | __aligned(PAGE_SIZE); |
954 | 1007 | ||
955 | extern asmlinkage void ignore_sysret(void); | ||
956 | |||
957 | /* May not be marked __init: used by software suspend */ | 1008 | /* May not be marked __init: used by software suspend */ |
958 | void syscall_init(void) | 1009 | void syscall_init(void) |
959 | { | 1010 | { |
@@ -983,7 +1034,7 @@ unsigned long kernel_eflags; | |||
983 | */ | 1034 | */ |
984 | DEFINE_PER_CPU(struct orig_ist, orig_ist); | 1035 | DEFINE_PER_CPU(struct orig_ist, orig_ist); |
985 | 1036 | ||
986 | #else /* x86_64 */ | 1037 | #else /* CONFIG_X86_64 */ |
987 | 1038 | ||
988 | #ifdef CONFIG_CC_STACKPROTECTOR | 1039 | #ifdef CONFIG_CC_STACKPROTECTOR |
989 | DEFINE_PER_CPU(unsigned long, stack_canary); | 1040 | DEFINE_PER_CPU(unsigned long, stack_canary); |
@@ -995,9 +1046,26 @@ struct pt_regs * __cpuinit idle_regs(struct pt_regs *regs) | |||
995 | memset(regs, 0, sizeof(struct pt_regs)); | 1046 | memset(regs, 0, sizeof(struct pt_regs)); |
996 | regs->fs = __KERNEL_PERCPU; | 1047 | regs->fs = __KERNEL_PERCPU; |
997 | regs->gs = __KERNEL_STACK_CANARY; | 1048 | regs->gs = __KERNEL_STACK_CANARY; |
1049 | |||
998 | return regs; | 1050 | return regs; |
999 | } | 1051 | } |
1000 | #endif /* x86_64 */ | 1052 | #endif /* CONFIG_X86_64 */ |
1053 | |||
1054 | /* | ||
1055 | * Clear all 6 debug registers: | ||
1056 | */ | ||
1057 | static void clear_all_debug_regs(void) | ||
1058 | { | ||
1059 | int i; | ||
1060 | |||
1061 | for (i = 0; i < 8; i++) { | ||
1062 | /* Ignore db4, db5 */ | ||
1063 | if ((i == 4) || (i == 5)) | ||
1064 | continue; | ||
1065 | |||
1066 | set_debugreg(0, i); | ||
1067 | } | ||
1068 | } | ||
1001 | 1069 | ||
1002 | /* | 1070 | /* |
1003 | * cpu_init() initializes state that is per-CPU. Some data is already | 1071 | * cpu_init() initializes state that is per-CPU. Some data is already |
@@ -1007,15 +1075,20 @@ struct pt_regs * __cpuinit idle_regs(struct pt_regs *regs) | |||
1007 | * A lot of state is already set up in PDA init for 64 bit | 1075 | * A lot of state is already set up in PDA init for 64 bit |
1008 | */ | 1076 | */ |
1009 | #ifdef CONFIG_X86_64 | 1077 | #ifdef CONFIG_X86_64 |
1078 | |||
1010 | void __cpuinit cpu_init(void) | 1079 | void __cpuinit cpu_init(void) |
1011 | { | 1080 | { |
1012 | int cpu = stack_smp_processor_id(); | 1081 | struct orig_ist *orig_ist; |
1013 | struct tss_struct *t = &per_cpu(init_tss, cpu); | ||
1014 | struct orig_ist *orig_ist = &per_cpu(orig_ist, cpu); | ||
1015 | unsigned long v; | ||
1016 | struct task_struct *me; | 1082 | struct task_struct *me; |
1083 | struct tss_struct *t; | ||
1084 | unsigned long v; | ||
1085 | int cpu; | ||
1017 | int i; | 1086 | int i; |
1018 | 1087 | ||
1088 | cpu = stack_smp_processor_id(); | ||
1089 | t = &per_cpu(init_tss, cpu); | ||
1090 | orig_ist = &per_cpu(orig_ist, cpu); | ||
1091 | |||
1019 | #ifdef CONFIG_NUMA | 1092 | #ifdef CONFIG_NUMA |
1020 | if (cpu != 0 && percpu_read(node_number) == 0 && | 1093 | if (cpu != 0 && percpu_read(node_number) == 0 && |
1021 | cpu_to_node(cpu) != NUMA_NO_NODE) | 1094 | cpu_to_node(cpu) != NUMA_NO_NODE) |
@@ -1056,19 +1129,17 @@ void __cpuinit cpu_init(void) | |||
1056 | * set up and load the per-CPU TSS | 1129 | * set up and load the per-CPU TSS |
1057 | */ | 1130 | */ |
1058 | if (!orig_ist->ist[0]) { | 1131 | if (!orig_ist->ist[0]) { |
1059 | static const unsigned int sizes[N_EXCEPTION_STACKS] = { | ||
1060 | [0 ... N_EXCEPTION_STACKS - 1] = EXCEPTION_STKSZ, | ||
1061 | [DEBUG_STACK - 1] = DEBUG_STKSZ | ||
1062 | }; | ||
1063 | char *estacks = per_cpu(exception_stacks, cpu); | 1132 | char *estacks = per_cpu(exception_stacks, cpu); |
1133 | |||
1064 | for (v = 0; v < N_EXCEPTION_STACKS; v++) { | 1134 | for (v = 0; v < N_EXCEPTION_STACKS; v++) { |
1065 | estacks += sizes[v]; | 1135 | estacks += exception_stack_sizes[v]; |
1066 | orig_ist->ist[v] = t->x86_tss.ist[v] = | 1136 | orig_ist->ist[v] = t->x86_tss.ist[v] = |
1067 | (unsigned long)estacks; | 1137 | (unsigned long)estacks; |
1068 | } | 1138 | } |
1069 | } | 1139 | } |
1070 | 1140 | ||
1071 | t->x86_tss.io_bitmap_base = offsetof(struct tss_struct, io_bitmap); | 1141 | t->x86_tss.io_bitmap_base = offsetof(struct tss_struct, io_bitmap); |
1142 | |||
1072 | /* | 1143 | /* |
1073 | * <= is required because the CPU will access up to | 1144 | * <= is required because the CPU will access up to |
1074 | * 8 bits beyond the end of the IO permission bitmap. | 1145 | * 8 bits beyond the end of the IO permission bitmap. |
@@ -1078,8 +1149,7 @@ void __cpuinit cpu_init(void) | |||
1078 | 1149 | ||
1079 | atomic_inc(&init_mm.mm_count); | 1150 | atomic_inc(&init_mm.mm_count); |
1080 | me->active_mm = &init_mm; | 1151 | me->active_mm = &init_mm; |
1081 | if (me->mm) | 1152 | BUG_ON(me->mm); |
1082 | BUG(); | ||
1083 | enter_lazy_tlb(&init_mm, me); | 1153 | enter_lazy_tlb(&init_mm, me); |
1084 | 1154 | ||
1085 | load_sp0(t, ¤t->thread); | 1155 | load_sp0(t, ¤t->thread); |
@@ -1098,17 +1168,7 @@ void __cpuinit cpu_init(void) | |||
1098 | arch_kgdb_ops.correct_hw_break(); | 1168 | arch_kgdb_ops.correct_hw_break(); |
1099 | else | 1169 | else |
1100 | #endif | 1170 | #endif |
1101 | { | 1171 | clear_all_debug_regs(); |
1102 | /* | ||
1103 | * Clear all 6 debug registers: | ||
1104 | */ | ||
1105 | set_debugreg(0UL, 0); | ||
1106 | set_debugreg(0UL, 1); | ||
1107 | set_debugreg(0UL, 2); | ||
1108 | set_debugreg(0UL, 3); | ||
1109 | set_debugreg(0UL, 6); | ||
1110 | set_debugreg(0UL, 7); | ||
1111 | } | ||
1112 | 1172 | ||
1113 | fpu_init(); | 1173 | fpu_init(); |
1114 | 1174 | ||
@@ -1129,7 +1189,8 @@ void __cpuinit cpu_init(void) | |||
1129 | 1189 | ||
1130 | if (cpumask_test_and_set_cpu(cpu, cpu_initialized_mask)) { | 1190 | if (cpumask_test_and_set_cpu(cpu, cpu_initialized_mask)) { |
1131 | printk(KERN_WARNING "CPU#%d already initialized!\n", cpu); | 1191 | printk(KERN_WARNING "CPU#%d already initialized!\n", cpu); |
1132 | for (;;) local_irq_enable(); | 1192 | for (;;) |
1193 | local_irq_enable(); | ||
1133 | } | 1194 | } |
1134 | 1195 | ||
1135 | printk(KERN_INFO "Initializing CPU#%d\n", cpu); | 1196 | printk(KERN_INFO "Initializing CPU#%d\n", cpu); |
@@ -1145,8 +1206,7 @@ void __cpuinit cpu_init(void) | |||
1145 | */ | 1206 | */ |
1146 | atomic_inc(&init_mm.mm_count); | 1207 | atomic_inc(&init_mm.mm_count); |
1147 | curr->active_mm = &init_mm; | 1208 | curr->active_mm = &init_mm; |
1148 | if (curr->mm) | 1209 | BUG_ON(curr->mm); |
1149 | BUG(); | ||
1150 | enter_lazy_tlb(&init_mm, curr); | 1210 | enter_lazy_tlb(&init_mm, curr); |
1151 | 1211 | ||
1152 | load_sp0(t, thread); | 1212 | load_sp0(t, thread); |
@@ -1159,13 +1219,7 @@ void __cpuinit cpu_init(void) | |||
1159 | __set_tss_desc(cpu, GDT_ENTRY_DOUBLEFAULT_TSS, &doublefault_tss); | 1219 | __set_tss_desc(cpu, GDT_ENTRY_DOUBLEFAULT_TSS, &doublefault_tss); |
1160 | #endif | 1220 | #endif |
1161 | 1221 | ||
1162 | /* Clear all 6 debug registers: */ | 1222 | clear_all_debug_regs(); |
1163 | set_debugreg(0, 0); | ||
1164 | set_debugreg(0, 1); | ||
1165 | set_debugreg(0, 2); | ||
1166 | set_debugreg(0, 3); | ||
1167 | set_debugreg(0, 6); | ||
1168 | set_debugreg(0, 7); | ||
1169 | 1223 | ||
1170 | /* | 1224 | /* |
1171 | * Force FPU initialization: | 1225 | * Force FPU initialization: |
@@ -1185,6 +1239,4 @@ void __cpuinit cpu_init(void) | |||
1185 | 1239 | ||
1186 | xsave_init(); | 1240 | xsave_init(); |
1187 | } | 1241 | } |
1188 | |||
1189 | |||
1190 | #endif | 1242 | #endif |