1 #include <linux/config.h>
2 #include <linux/init.h>
3 #include <linux/kernel.h>
5 #include <linux/string.h>
6 #include <linux/bitops.h>
8 #include <linux/thread_info.h>
10 #include <asm/processor.h>
12 #include <asm/uaccess.h>
16 #ifdef CONFIG_X86_LOCAL_APIC
17 #include <asm/mpspec.h>
19 #include <mach_apic.h>
22 extern int trap_init_f00f_bug(void);
24 #ifdef CONFIG_X86_INTEL_USERCOPY
26 * Alignment at which movsl is preferred for bulk memory copies.
28 struct movsl_mask movsl_mask;
32 * Early probe support logic for ppro memory erratum #50
34 * This is called before we do cpu ident work
37 int __init ppro_with_ram_bug(void)
52 (int *)&vendor_id[4]);
54 if(memcmp(vendor_id, "IntelInside", 12))
61 if(((ident>>8)&15)!=6)
66 if(((ident>>4)&15)!=1)
71 printk(KERN_INFO "Pentium Pro with Errata#50 detected. Taking evasive action.\n");
74 printk(KERN_INFO "Your Pentium Pro seems ok.\n");
86 unsigned char descriptor;
91 /* all the cache descriptor types we care about (no TLB or trace cache entries) */
92 static struct _cache_table cache_table[] __initdata =
94 { 0x06, LVL_1_INST, 8 },
95 { 0x08, LVL_1_INST, 16 },
96 { 0x0a, LVL_1_DATA, 8 },
97 { 0x0c, LVL_1_DATA, 16 },
99 { 0x23, LVL_3, 1024 },
100 { 0x25, LVL_3, 2048 },
101 { 0x29, LVL_3, 4096 },
102 { 0x2c, LVL_1_DATA, 32 },
103 { 0x30, LVL_1_INST, 32 },
104 { 0x39, LVL_2, 128 },
105 { 0x3b, LVL_2, 128 },
106 { 0x3c, LVL_2, 256 },
107 { 0x41, LVL_2, 128 },
108 { 0x42, LVL_2, 256 },
109 { 0x43, LVL_2, 512 },
110 { 0x44, LVL_2, 1024 },
111 { 0x45, LVL_2, 2048 },
112 { 0x66, LVL_1_DATA, 8 },
113 { 0x67, LVL_1_DATA, 16 },
114 { 0x68, LVL_1_DATA, 32 },
115 { 0x70, LVL_TRACE, 12 },
116 { 0x71, LVL_TRACE, 16 },
117 { 0x72, LVL_TRACE, 32 },
118 { 0x79, LVL_2, 128 },
119 { 0x7a, LVL_2, 256 },
120 { 0x7b, LVL_2, 512 },
121 { 0x7c, LVL_2, 1024 },
122 { 0x82, LVL_2, 256 },
123 { 0x83, LVL_2, 512 },
124 { 0x84, LVL_2, 1024 },
125 { 0x85, LVL_2, 2048 },
126 { 0x86, LVL_2, 512 },
127 { 0x87, LVL_2, 1024 },
132 * P4 Xeon errata 037 workaround.
133 * Hardware prefetcher may cause stale data to be loaded into the cache.
135 static void __init Intel_errata_workarounds(struct cpuinfo_x86 *c)
137 unsigned long lo, hi;
139 if ((c->x86 == 15) && (c->x86_model == 1) && (c->x86_mask == 1)) {
140 rdmsr (MSR_IA32_MISC_ENABLE, lo, hi);
141 if ((lo & (1<<9)) == 0) {
142 printk (KERN_INFO "CPU: C0 stepping P4 Xeon detected.\n");
143 printk (KERN_INFO "CPU: Disabling hardware prefetching (Errata 037)\n");
144 lo |= (1<<9); /* Disable hw prefetching */
145 wrmsr (MSR_IA32_MISC_ENABLE, lo, hi);
151 static void __init init_intel(struct cpuinfo_x86 *c)
154 unsigned int trace = 0, l1i = 0, l1d = 0, l2 = 0, l3 = 0; /* Cache sizes */
156 #ifdef CONFIG_X86_F00F_BUG
158 * All current models of Pentium and Pentium with MMX technology CPUs
159 * have the F0 0F bug, which lets nonprivileged users lock up the system.
160 * Note that the workaround only should be initialized once...
164 static int f00f_workaround_enabled = 0;
167 if ( !f00f_workaround_enabled ) {
168 trap_init_f00f_bug();
169 printk(KERN_NOTICE "Intel Pentium with F0 0F bug - workaround enabled.\n");
170 f00f_workaround_enabled = 1;
175 select_idle_routine(c);
176 if (c->cpuid_level > 1) {
177 /* supports eax=2 call */
180 unsigned char *dp = (unsigned char *)regs;
182 /* Number of times to iterate */
183 n = cpuid_eax(2) & 0xFF;
185 for ( i = 0 ; i < n ; i++ ) {
186 cpuid(2, ®s[0], ®s[1], ®s[2], ®s[3]);
188 /* If bit 31 is set, this is an unknown format */
189 for ( j = 0 ; j < 3 ; j++ ) {
190 if ( regs[j] < 0 ) regs[j] = 0;
193 /* Byte 0 is level count, not a descriptor */
194 for ( j = 1 ; j < 16 ; j++ ) {
195 unsigned char des = dp[j];
198 /* look up this descriptor in the table */
199 while (cache_table[k].descriptor != 0)
201 if (cache_table[k].descriptor == des) {
202 switch (cache_table[k].cache_type) {
204 l1i += cache_table[k].size;
207 l1d += cache_table[k].size;
210 l2 += cache_table[k].size;
213 l3 += cache_table[k].size;
216 trace += cache_table[k].size;
229 printk (KERN_INFO "CPU: Trace cache: %dK uops", trace);
231 printk (KERN_INFO "CPU: L1 I cache: %dK", l1i);
233 printk(", L1 D cache: %dK\n", l1d);
237 printk(KERN_INFO "CPU: L2 cache: %dK\n", l2);
239 printk(KERN_INFO "CPU: L3 cache: %dK\n", l3);
242 * This assumes the L3 cache is shared; it typically lives in
243 * the northbridge. The L1 caches are included by the L2
244 * cache, and so should not be included for the purpose of
245 * SMP switching weights.
247 c->x86_cache_size = l2 ? l2 : (l1i+l1d);
250 /* SEP CPUID bug: Pentium Pro reports SEP but doesn't have it until model 3 mask 3 */
251 if ((c->x86<<8 | c->x86_model<<4 | c->x86_mask) < 0x633)
252 clear_bit(X86_FEATURE_SEP, c->x86_capability);
254 /* Names for the Pentium II/Celeron processors
255 detectable only by also checking the cache size.
256 Dixon is NOT a Celeron. */
258 switch (c->x86_model) {
260 if (c->x86_mask == 0) {
262 p = "Celeron (Covington)";
264 p = "Mobile Pentium II (Dixon)";
270 p = "Celeron (Mendocino)";
271 else if (c->x86_mask == 0 || c->x86_mask == 5)
277 p = "Celeron (Coppermine)";
283 strcpy(c->x86_model_id, p);
286 if (cpu_has(c, X86_FEATURE_HT)) {
287 extern int phys_proc_id[NR_CPUS];
289 u32 eax, ebx, ecx, edx;
290 int index_lsb, index_msb, tmp;
291 int cpu = smp_processor_id();
293 cpuid(1, &eax, &ebx, &ecx, &edx);
294 smp_num_siblings = (ebx & 0xff0000) >> 16;
296 if (smp_num_siblings == 1) {
297 printk(KERN_INFO "CPU: Hyper-Threading is disabled\n");
298 } else if (smp_num_siblings > 1 ) {
302 if (smp_num_siblings > NR_CPUS) {
303 printk(KERN_WARNING "CPU: Unsupported number of the siblings %d", smp_num_siblings);
304 smp_num_siblings = 1;
305 goto too_many_siblings;
307 tmp = smp_num_siblings;
308 while ((tmp & 1) == 0) {
312 tmp = smp_num_siblings;
313 while ((tmp & 0x80000000 ) == 0) {
317 if (index_lsb != index_msb )
319 phys_proc_id[cpu] = phys_pkg_id((ebx >> 24) & 0xFF, index_msb);
321 printk(KERN_INFO "CPU: Physical Processor ID: %d\n",
330 /* Work around errata */
331 Intel_errata_workarounds(c);
333 #ifdef CONFIG_X86_INTEL_USERCOPY
335 * Set up the preferred alignment for movsl bulk memory moves
338 case 4: /* 486: untested */
340 case 5: /* Old Pentia: untested */
342 case 6: /* PII/PIII only like movsl with 8-byte alignment */
345 case 15: /* P4 is OK down to 8-byte alignment */
352 set_bit(X86_FEATURE_P4, c->x86_capability);
354 set_bit(X86_FEATURE_P3, c->x86_capability);
358 static unsigned int intel_size_cache(struct cpuinfo_x86 * c, unsigned int size)
360 /* Intel PIII Tualatin. This comes in two flavours.
361 * One has 256kb of cache, the other 512. We have no way
362 * to determine which, so we use a boottime override
363 * for the 512kb model, and assume 256 otherwise.
365 if ((c->x86 == 6) && (c->x86_model == 11) && (size == 0))
370 static struct cpu_dev intel_cpu_dev __initdata = {
372 .c_ident = { "GenuineIntel" },
374 { .vendor = X86_VENDOR_INTEL, .family = 4, .model_names =
376 [0] = "486 DX-25/33",
387 { .vendor = X86_VENDOR_INTEL, .family = 5, .model_names =
389 [0] = "Pentium 60/66 A-step",
390 [1] = "Pentium 60/66",
391 [2] = "Pentium 75 - 200",
392 [3] = "OverDrive PODP5V83",
394 [7] = "Mobile Pentium 75 - 200",
395 [8] = "Mobile Pentium MMX"
398 { .vendor = X86_VENDOR_INTEL, .family = 6, .model_names =
400 [0] = "Pentium Pro A-step",
402 [3] = "Pentium II (Klamath)",
403 [4] = "Pentium II (Deschutes)",
404 [5] = "Pentium II (Deschutes)",
405 [6] = "Mobile Pentium II",
406 [7] = "Pentium III (Katmai)",
407 [8] = "Pentium III (Coppermine)",
408 [10] = "Pentium III (Cascades)",
409 [11] = "Pentium III (Tualatin)",
412 { .vendor = X86_VENDOR_INTEL, .family = 15, .model_names =
414 [0] = "Pentium 4 (Unknown)",
415 [1] = "Pentium 4 (Willamette)",
416 [2] = "Pentium 4 (Northwood)",
417 [4] = "Pentium 4 (Foster)",
418 [5] = "Pentium 4 (Foster)",
422 .c_init = init_intel,
423 .c_identify = generic_identify,
424 .c_size_cache = intel_size_cache,
427 __init int intel_cpu_init(void)
429 cpu_devs[X86_VENDOR_INTEL] = &intel_cpu_dev;
433 // arch_initcall(intel_cpu_init);