Rev 582 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
582 | mauro | 1 | #include <linuxcomp.h> |
2 | |||
3 | #include <linux/init.h> |
||
4 | #include <linux/kernel.h> |
||
5 | #include <linux/string.h> |
||
6 | #include <linux/bitops.h> |
||
7 | #include <linux/smp.h> |
||
8 | #include <linux/thread_info.h> |
||
9 | |||
10 | #include <asm/processor.h> |
||
11 | #include <asm/msr.h> |
||
12 | #include <asm/uaccess.h> |
||
13 | |||
14 | #include "cpu.h" |
||
15 | |||
16 | extern int trap_init_f00f_bug(void); |
||
17 | |||
18 | #ifdef CONFIG_X86_INTEL_USERCOPY |
||
19 | /* |
||
20 | * Alignment at which movsl is preferred for bulk memory copies. |
||
21 | */ |
||
22 | struct movsl_mask movsl_mask; |
||
23 | #endif |
||
24 | |||
25 | /* |
||
26 | * Early probe support logic for ppro memory erratum #50 |
||
27 | * |
||
28 | * This is called before we do cpu ident work |
||
29 | */ |
||
30 | |||
31 | int __init ppro_with_ram_bug(void) |
||
32 | { |
||
33 | char vendor_id[16]; |
||
34 | int ident; |
||
35 | |||
36 | /* Must have CPUID */ |
||
37 | if(!have_cpuid_p()) |
||
38 | return 0; |
||
39 | if(cpuid_eax(0)<1) |
||
40 | return 0; |
||
41 | |||
42 | /* Must be Intel */ |
||
43 | cpuid(0, &ident, |
||
44 | (int *)&vendor_id[0], |
||
45 | (int *)&vendor_id[8], |
||
46 | (int *)&vendor_id[4]); |
||
47 | |||
48 | if(memcmp(vendor_id, "IntelInside", 12)) |
||
49 | return 0; |
||
50 | |||
51 | ident = cpuid_eax(1); |
||
52 | |||
53 | /* Model 6 */ |
||
54 | |||
55 | if(((ident>>8)&15)!=6) |
||
56 | return 0; |
||
57 | |||
58 | /* Pentium Pro */ |
||
59 | |||
60 | if(((ident>>4)&15)!=1) |
||
61 | return 0; |
||
62 | |||
63 | if((ident&15) < 8) |
||
64 | { |
||
65 | printk(KERN_INFO "Pentium Pro with Errata#50 detected. Taking evasive action.\n"); |
||
66 | return 1; |
||
67 | } |
||
68 | printk(KERN_INFO "Your Pentium Pro seems ok.\n"); |
||
69 | return 0; |
||
70 | } |
||
71 | |||
72 | #define LVL_1_INST 1 |
||
73 | #define LVL_1_DATA 2 |
||
74 | #define LVL_2 3 |
||
75 | #define LVL_3 4 |
||
76 | #define LVL_TRACE 5 |
||
77 | |||
78 | struct _cache_table |
||
79 | { |
||
80 | unsigned char descriptor; |
||
81 | char cache_type; |
||
82 | short size; |
||
83 | }; |
||
84 | |||
85 | /* all the cache descriptor types we care about (no TLB or trace cache entries) */ |
||
86 | static struct _cache_table cache_table[] __initdata = |
||
87 | { |
||
88 | { 0x06, LVL_1_INST, 8 }, |
||
89 | { 0x08, LVL_1_INST, 16 }, |
||
90 | { 0x0a, LVL_1_DATA, 8 }, |
||
91 | { 0x0c, LVL_1_DATA, 16 }, |
||
92 | { 0x22, LVL_3, 512 }, |
||
93 | { 0x23, LVL_3, 1024 }, |
||
94 | { 0x25, LVL_3, 2048 }, |
||
95 | { 0x29, LVL_3, 4096 }, |
||
96 | { 0x2c, LVL_1_DATA, 32 }, |
||
97 | { 0x30, LVL_1_INST, 32 }, |
||
98 | { 0x39, LVL_2, 128 }, |
||
99 | { 0x3b, LVL_2, 128 }, |
||
100 | { 0x3c, LVL_2, 256 }, |
||
101 | { 0x41, LVL_2, 128 }, |
||
102 | { 0x42, LVL_2, 256 }, |
||
103 | { 0x43, LVL_2, 512 }, |
||
104 | { 0x44, LVL_2, 1024 }, |
||
105 | { 0x45, LVL_2, 2048 }, |
||
106 | { 0x66, LVL_1_DATA, 8 }, |
||
107 | { 0x67, LVL_1_DATA, 16 }, |
||
108 | { 0x68, LVL_1_DATA, 32 }, |
||
109 | { 0x70, LVL_TRACE, 12 }, |
||
110 | { 0x71, LVL_TRACE, 16 }, |
||
111 | { 0x72, LVL_TRACE, 32 }, |
||
112 | { 0x79, LVL_2, 128 }, |
||
113 | { 0x7a, LVL_2, 256 }, |
||
114 | { 0x7b, LVL_2, 512 }, |
||
115 | { 0x7c, LVL_2, 1024 }, |
||
116 | { 0x82, LVL_2, 256 }, |
||
117 | { 0x83, LVL_2, 512 }, |
||
118 | { 0x84, LVL_2, 1024 }, |
||
119 | { 0x85, LVL_2, 2048 }, |
||
120 | { 0x86, LVL_2, 512 }, |
||
121 | { 0x87, LVL_2, 1024 }, |
||
122 | { 0x00, 0, 0} |
||
123 | }; |
||
124 | |||
125 | /* |
||
126 | * P4 Xeon errata 037 workaround. |
||
127 | * Hardware prefetcher may cause stale data to be loaded into the cache. |
||
128 | */ |
||
129 | static void __init Intel_errata_workarounds(struct cpuinfo_x86 *c) |
||
130 | { |
||
131 | unsigned long lo, hi; |
||
132 | |||
133 | if ((c->x86 == 15) && (c->x86_model == 1) && (c->x86_mask == 1)) { |
||
134 | rdmsr (MSR_IA32_MISC_ENABLE, lo, hi); |
||
135 | if ((lo & (1<<9)) == 0) { |
||
136 | printk (KERN_INFO "CPU: C0 stepping P4 Xeon detected.\n"); |
||
137 | printk (KERN_INFO "CPU: Disabling hardware prefetching (Errata 037)\n"); |
||
138 | lo |= (1<<9); /* Disable hw prefetching */ |
||
139 | wrmsr (MSR_IA32_MISC_ENABLE, lo, hi); |
||
140 | } |
||
141 | } |
||
142 | } |
||
143 | |||
144 | |||
145 | static void __init init_intel(struct cpuinfo_x86 *c) |
||
146 | { |
||
147 | char *p = NULL; |
||
148 | unsigned int trace = 0, l1i = 0, l1d = 0, l2 = 0, l3 = 0; /* Cache sizes */ |
||
149 | |||
150 | #ifdef CONFIG_X86_F00F_BUG |
||
151 | /* |
||
152 | * All current models of Pentium and Pentium with MMX technology CPUs |
||
153 | * have the F0 0F bug, which lets nonprivileged users lock up the system. |
||
154 | * Note that the workaround only should be initialized once... |
||
155 | */ |
||
156 | c->f00f_bug = 0; |
||
157 | if ( c->x86 == 5 ) { |
||
158 | static int f00f_workaround_enabled = 0; |
||
159 | |||
160 | c->f00f_bug = 1; |
||
161 | if ( !f00f_workaround_enabled ) { |
||
162 | trap_init_f00f_bug(); |
||
163 | printk(KERN_NOTICE "Intel Pentium with F0 0F bug - workaround enabled.\n"); |
||
164 | f00f_workaround_enabled = 1; |
||
165 | } |
||
166 | } |
||
167 | #endif |
||
168 | |||
169 | //!!!select_idle_routine(c); |
||
170 | if (c->cpuid_level > 1) { |
||
171 | /* supports eax=2 call */ |
||
172 | int i, j, n; |
||
173 | int regs[4]; |
||
174 | unsigned char *dp = (unsigned char *)regs; |
||
175 | |||
176 | /* Number of times to iterate */ |
||
177 | n = cpuid_eax(2) & 0xFF; |
||
178 | |||
179 | for ( i = 0 ; i < n ; i++ ) { |
||
180 | cpuid(2, ®s[0], ®s[1], ®s[2], ®s[3]); |
||
181 | |||
182 | /* If bit 31 is set, this is an unknown format */ |
||
183 | for ( j = 0 ; j < 3 ; j++ ) { |
||
184 | if ( regs[j] < 0 ) regs[j] = 0; |
||
185 | } |
||
186 | |||
187 | /* Byte 0 is level count, not a descriptor */ |
||
188 | for ( j = 1 ; j < 16 ; j++ ) { |
||
189 | unsigned char des = dp[j]; |
||
190 | unsigned char k = 0; |
||
191 | |||
192 | /* look up this descriptor in the table */ |
||
193 | while (cache_table[k].descriptor != 0) |
||
194 | { |
||
195 | if (cache_table[k].descriptor == des) { |
||
196 | switch (cache_table[k].cache_type) { |
||
197 | case LVL_1_INST: |
||
198 | l1i += cache_table[k].size; |
||
199 | break; |
||
200 | case LVL_1_DATA: |
||
201 | l1d += cache_table[k].size; |
||
202 | break; |
||
203 | case LVL_2: |
||
204 | l2 += cache_table[k].size; |
||
205 | break; |
||
206 | case LVL_3: |
||
207 | l3 += cache_table[k].size; |
||
208 | break; |
||
209 | case LVL_TRACE: |
||
210 | trace += cache_table[k].size; |
||
211 | break; |
||
212 | } |
||
213 | |||
214 | break; |
||
215 | } |
||
216 | |||
217 | k++; |
||
218 | } |
||
219 | } |
||
220 | } |
||
221 | |||
222 | if ( trace ) |
||
223 | printk (KERN_INFO "CPU: Trace cache: %dK uops", trace); |
||
224 | else if ( l1i ) |
||
225 | printk (KERN_INFO "CPU: L1 I cache: %dK", l1i); |
||
226 | if ( l1d ) |
||
227 | printk(", L1 D cache: %dK\n", l1d); |
||
228 | if ( l2 ) |
||
229 | printk(KERN_INFO "CPU: L2 cache: %dK\n", l2); |
||
230 | if ( l3 ) |
||
231 | printk(KERN_INFO "CPU: L3 cache: %dK\n", l3); |
||
232 | |||
233 | /* |
||
234 | * This assumes the L3 cache is shared; it typically lives in |
||
235 | * the northbridge. The L1 caches are included by the L2 |
||
236 | * cache, and so should not be included for the purpose of |
||
237 | * SMP switching weights. |
||
238 | */ |
||
239 | c->x86_cache_size = l2 ? l2 : (l1i+l1d); |
||
240 | } |
||
241 | |||
242 | /* SEP CPUID bug: Pentium Pro reports SEP but doesn't have it until model 3 mask 3 */ |
||
243 | if ((c->x86<<8 | c->x86_model<<4 | c->x86_mask) < 0x633) |
||
244 | clear_bit(X86_FEATURE_SEP, c->x86_capability); |
||
245 | |||
246 | /* Names for the Pentium II/Celeron processors |
||
247 | detectable only by also checking the cache size. |
||
248 | Dixon is NOT a Celeron. */ |
||
249 | if (c->x86 == 6) { |
||
250 | switch (c->x86_model) { |
||
251 | case 5: |
||
252 | if (c->x86_mask == 0) { |
||
253 | if (l2 == 0) |
||
254 | p = "Celeron (Covington)"; |
||
255 | else if (l2 == 256) |
||
256 | p = "Mobile Pentium II (Dixon)"; |
||
257 | } |
||
258 | break; |
||
259 | |||
260 | case 6: |
||
261 | if (l2 == 128) |
||
262 | p = "Celeron (Mendocino)"; |
||
263 | else if (c->x86_mask == 0 || c->x86_mask == 5) |
||
264 | p = "Celeron-A"; |
||
265 | break; |
||
266 | |||
267 | case 8: |
||
268 | if (l2 == 128) |
||
269 | p = "Celeron (Coppermine)"; |
||
270 | break; |
||
271 | } |
||
272 | } |
||
273 | |||
274 | if ( p ) |
||
275 | strcpy(c->x86_model_id, p); |
||
276 | |||
277 | #ifdef CONFIG_X86_HT |
||
278 | if (cpu_has(c, X86_FEATURE_HT)) { |
||
279 | extern int phys_proc_id[NR_CPUS]; |
||
280 | |||
281 | u32 eax, ebx, ecx, edx; |
||
282 | int cpu = smp_processor_id(); |
||
283 | |||
284 | cpuid(1, &eax, &ebx, &ecx, &edx); |
||
285 | smp_num_siblings = (ebx & 0xff0000) >> 16; |
||
286 | |||
287 | if (smp_num_siblings == 1) { |
||
288 | printk(KERN_INFO "CPU: Hyper-Threading is disabled\n"); |
||
289 | } else if (smp_num_siblings > 1 ) { |
||
290 | /* |
||
291 | * At this point we only support two siblings per |
||
292 | * processor package. |
||
293 | */ |
||
294 | #define NR_SIBLINGS 2 |
||
295 | if (smp_num_siblings != NR_SIBLINGS) { |
||
296 | printk(KERN_WARNING "CPU: Unsupported number of the siblings %d", smp_num_siblings); |
||
297 | smp_num_siblings = 1; |
||
298 | goto too_many_siblings; |
||
299 | } |
||
300 | /* cpuid returns the value latched in the HW at reset, |
||
301 | * not the APIC ID register's value. For any box |
||
302 | * whose BIOS changes APIC IDs, like clustered APIC |
||
303 | * systems, we must use hard_smp_processor_id. |
||
304 | * See Intel's IA-32 SW Dev's Manual Vol2 under CPUID. |
||
305 | */ |
||
306 | phys_proc_id[cpu] = hard_smp_processor_id() & ~(smp_num_siblings - 1); |
||
307 | |||
308 | printk(KERN_INFO "CPU: Physical Processor ID: %d\n", |
||
309 | phys_proc_id[cpu]); |
||
310 | } |
||
311 | |||
312 | } |
||
313 | too_many_siblings: |
||
314 | |||
315 | #endif |
||
316 | |||
317 | /* Work around errata */ |
||
318 | Intel_errata_workarounds(c); |
||
319 | |||
320 | #ifdef CONFIG_X86_INTEL_USERCOPY |
||
321 | /* |
||
322 | * Set up the preferred alignment for movsl bulk memory moves |
||
323 | */ |
||
324 | switch (c->x86) { |
||
325 | case 4: /* 486: untested */ |
||
326 | break; |
||
327 | case 5: /* Old Pentia: untested */ |
||
328 | break; |
||
329 | case 6: /* PII/PIII only like movsl with 8-byte alignment */ |
||
330 | movsl_mask.mask = 7; |
||
331 | break; |
||
332 | case 15: /* P4 is OK down to 8-byte alignment */ |
||
333 | movsl_mask.mask = 7; |
||
334 | break; |
||
335 | } |
||
336 | #endif |
||
337 | |||
338 | if (c->x86 == 15) |
||
339 | set_bit(X86_FEATURE_P4, c->x86_capability); |
||
340 | if (c->x86 == 6) |
||
341 | set_bit(X86_FEATURE_P3, c->x86_capability); |
||
342 | } |
||
343 | |||
344 | |||
345 | static unsigned int intel_size_cache(struct cpuinfo_x86 * c, unsigned int size) |
||
346 | { |
||
347 | /* Intel PIII Tualatin. This comes in two flavours. |
||
348 | * One has 256kb of cache, the other 512. We have no way |
||
349 | * to determine which, so we use a boottime override |
||
350 | * for the 512kb model, and assume 256 otherwise. |
||
351 | */ |
||
352 | if ((c->x86 == 6) && (c->x86_model == 11) && (size == 0)) |
||
353 | size = 256; |
||
354 | return size; |
||
355 | } |
||
356 | |||
357 | static struct cpu_dev intel_cpu_dev __initdata = { |
||
358 | .c_vendor = "Intel", |
||
359 | .c_ident = { "GenuineIntel" }, |
||
360 | .c_models = { |
||
361 | { .vendor = X86_VENDOR_INTEL, .family = 4, .model_names = |
||
362 | { |
||
363 | [0] = "486 DX-25/33", |
||
364 | [1] = "486 DX-50", |
||
365 | [2] = "486 SX", |
||
366 | [3] = "486 DX/2", |
||
367 | [4] = "486 SL", |
||
368 | [5] = "486 SX/2", |
||
369 | [7] = "486 DX/2-WB", |
||
370 | [8] = "486 DX/4", |
||
371 | [9] = "486 DX/4-WB" |
||
372 | } |
||
373 | }, |
||
374 | { .vendor = X86_VENDOR_INTEL, .family = 5, .model_names = |
||
375 | { |
||
376 | [0] = "Pentium 60/66 A-step", |
||
377 | [1] = "Pentium 60/66", |
||
378 | [2] = "Pentium 75 - 200", |
||
379 | [3] = "OverDrive PODP5V83", |
||
380 | [4] = "Pentium MMX", |
||
381 | [7] = "Mobile Pentium 75 - 200", |
||
382 | [8] = "Mobile Pentium MMX" |
||
383 | } |
||
384 | }, |
||
385 | { .vendor = X86_VENDOR_INTEL, .family = 6, .model_names = |
||
386 | { |
||
387 | [0] = "Pentium Pro A-step", |
||
388 | [1] = "Pentium Pro", |
||
389 | [3] = "Pentium II (Klamath)", |
||
390 | [4] = "Pentium II (Deschutes)", |
||
391 | [5] = "Pentium II (Deschutes)", |
||
392 | [6] = "Mobile Pentium II", |
||
393 | [7] = "Pentium III (Katmai)", |
||
394 | [8] = "Pentium III (Coppermine)", |
||
395 | [10] = "Pentium III (Cascades)", |
||
396 | [11] = "Pentium III (Tualatin)", |
||
397 | } |
||
398 | }, |
||
399 | { .vendor = X86_VENDOR_INTEL, .family = 15, .model_names = |
||
400 | { |
||
401 | [0] = "Pentium 4 (Unknown)", |
||
402 | [1] = "Pentium 4 (Willamette)", |
||
403 | [2] = "Pentium 4 (Northwood)", |
||
404 | [4] = "Pentium 4 (Foster)", |
||
405 | [5] = "Pentium 4 (Foster)", |
||
406 | } |
||
407 | }, |
||
408 | }, |
||
409 | .c_init = init_intel, |
||
410 | .c_identify = generic_identify, |
||
411 | .c_size_cache = intel_size_cache, |
||
412 | }; |
||
413 | |||
414 | __init int intel_cpu_init(void) |
||
415 | { |
||
416 | cpu_devs[X86_VENDOR_INTEL] = &intel_cpu_dev; |
||
417 | return 0; |
||
418 | } |
||
419 | |||
420 | // arch_initcall(intel_cpu_init); |
||
421 |