intel.c 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. #include <linux/config.h>
  2. #include <linux/init.h>
  3. #include <linux/kernel.h>
  4. #include <linux/string.h>
  5. #include <linux/bitops.h>
  6. #include <linux/smp.h>
  7. #include <linux/thread_info.h>
  8. #include <asm/processor.h>
  9. #include <asm/msr.h>
  10. #include <asm/uaccess.h>
  11. #include "cpu.h"
  12. #ifdef CONFIG_X86_LOCAL_APIC
  13. #include <asm/mpspec.h>
  14. #include <asm/apic.h>
  15. #include <mach_apic.h>
  16. #endif
  17. extern int trap_init_f00f_bug(void);
  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. void __devinit early_intel_workaround(struct cpuinfo_x86 *c)
  25. {
  26. if (c->x86_vendor != X86_VENDOR_INTEL)
  27. return;
  28. /* Netburst reports 64 bytes clflush size, but does IO in 128 bytes */
  29. if (c->x86 == 15 && c->x86_cache_alignment == 64)
  30. c->x86_cache_alignment = 128;
  31. }
  32. /*
  33. * Early probe support logic for ppro memory erratum #50
  34. *
  35. * This is called before we do cpu ident work
  36. */
  37. int __devinit ppro_with_ram_bug(void)
  38. {
  39. /* Uses data from early_cpu_detect now */
  40. if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL &&
  41. boot_cpu_data.x86 == 6 &&
  42. boot_cpu_data.x86_model == 1 &&
  43. boot_cpu_data.x86_mask < 8) {
  44. printk(KERN_INFO "Pentium Pro with Errata#50 detected. Taking evasive action.\n");
  45. return 1;
  46. }
  47. return 0;
  48. }
  49. /*
  50. * P4 Xeon errata 037 workaround.
  51. * Hardware prefetcher may cause stale data to be loaded into the cache.
  52. */
  53. static void __devinit Intel_errata_workarounds(struct cpuinfo_x86 *c)
  54. {
  55. unsigned long lo, hi;
  56. if ((c->x86 == 15) && (c->x86_model == 1) && (c->x86_mask == 1)) {
  57. rdmsr (MSR_IA32_MISC_ENABLE, lo, hi);
  58. if ((lo & (1<<9)) == 0) {
  59. printk (KERN_INFO "CPU: C0 stepping P4 Xeon detected.\n");
  60. printk (KERN_INFO "CPU: Disabling hardware prefetching (Errata 037)\n");
  61. lo |= (1<<9); /* Disable hw prefetching */
  62. wrmsr (MSR_IA32_MISC_ENABLE, lo, hi);
  63. }
  64. }
  65. }
  66. /*
  67. * find out the number of processor cores on the die
  68. */
  69. static int __devinit num_cpu_cores(struct cpuinfo_x86 *c)
  70. {
  71. unsigned int eax;
  72. if (c->cpuid_level < 4)
  73. return 1;
  74. __asm__("cpuid"
  75. : "=a" (eax)
  76. : "0" (4), "c" (0)
  77. : "bx", "dx");
  78. if (eax & 0x1f)
  79. return ((eax >> 26) + 1);
  80. else
  81. return 1;
  82. }
  83. static void __devinit init_intel(struct cpuinfo_x86 *c)
  84. {
  85. unsigned int l2 = 0;
  86. char *p = NULL;
  87. #ifdef CONFIG_X86_F00F_BUG
  88. /*
  89. * All current models of Pentium and Pentium with MMX technology CPUs
  90. * have the F0 0F bug, which lets nonprivileged users lock up the system.
  91. * Note that the workaround only should be initialized once...
  92. */
  93. c->f00f_bug = 0;
  94. if ( c->x86 == 5 ) {
  95. static int f00f_workaround_enabled = 0;
  96. c->f00f_bug = 1;
  97. if ( !f00f_workaround_enabled ) {
  98. trap_init_f00f_bug();
  99. printk(KERN_NOTICE "Intel Pentium with F0 0F bug - workaround enabled.\n");
  100. f00f_workaround_enabled = 1;
  101. }
  102. }
  103. #endif
  104. select_idle_routine(c);
  105. l2 = init_intel_cacheinfo(c);
  106. /* SEP CPUID bug: Pentium Pro reports SEP but doesn't have it until model 3 mask 3 */
  107. if ((c->x86<<8 | c->x86_model<<4 | c->x86_mask) < 0x633)
  108. clear_bit(X86_FEATURE_SEP, c->x86_capability);
  109. /* Names for the Pentium II/Celeron processors
  110. detectable only by also checking the cache size.
  111. Dixon is NOT a Celeron. */
  112. if (c->x86 == 6) {
  113. switch (c->x86_model) {
  114. case 5:
  115. if (c->x86_mask == 0) {
  116. if (l2 == 0)
  117. p = "Celeron (Covington)";
  118. else if (l2 == 256)
  119. p = "Mobile Pentium II (Dixon)";
  120. }
  121. break;
  122. case 6:
  123. if (l2 == 128)
  124. p = "Celeron (Mendocino)";
  125. else if (c->x86_mask == 0 || c->x86_mask == 5)
  126. p = "Celeron-A";
  127. break;
  128. case 8:
  129. if (l2 == 128)
  130. p = "Celeron (Coppermine)";
  131. break;
  132. }
  133. }
  134. if ( p )
  135. strcpy(c->x86_model_id, p);
  136. c->x86_num_cores = num_cpu_cores(c);
  137. detect_ht(c);
  138. /* Work around errata */
  139. Intel_errata_workarounds(c);
  140. #ifdef CONFIG_X86_INTEL_USERCOPY
  141. /*
  142. * Set up the preferred alignment for movsl bulk memory moves
  143. */
  144. switch (c->x86) {
  145. case 4: /* 486: untested */
  146. break;
  147. case 5: /* Old Pentia: untested */
  148. break;
  149. case 6: /* PII/PIII only like movsl with 8-byte alignment */
  150. movsl_mask.mask = 7;
  151. break;
  152. case 15: /* P4 is OK down to 8-byte alignment */
  153. movsl_mask.mask = 7;
  154. break;
  155. }
  156. #endif
  157. if (c->x86 == 15)
  158. set_bit(X86_FEATURE_P4, c->x86_capability);
  159. if (c->x86 == 6)
  160. set_bit(X86_FEATURE_P3, c->x86_capability);
  161. }
  162. static unsigned int intel_size_cache(struct cpuinfo_x86 * c, unsigned int size)
  163. {
  164. /* Intel PIII Tualatin. This comes in two flavours.
  165. * One has 256kb of cache, the other 512. We have no way
  166. * to determine which, so we use a boottime override
  167. * for the 512kb model, and assume 256 otherwise.
  168. */
  169. if ((c->x86 == 6) && (c->x86_model == 11) && (size == 0))
  170. size = 256;
  171. return size;
  172. }
  173. static struct cpu_dev intel_cpu_dev __devinitdata = {
  174. .c_vendor = "Intel",
  175. .c_ident = { "GenuineIntel" },
  176. .c_models = {
  177. { .vendor = X86_VENDOR_INTEL, .family = 4, .model_names =
  178. {
  179. [0] = "486 DX-25/33",
  180. [1] = "486 DX-50",
  181. [2] = "486 SX",
  182. [3] = "486 DX/2",
  183. [4] = "486 SL",
  184. [5] = "486 SX/2",
  185. [7] = "486 DX/2-WB",
  186. [8] = "486 DX/4",
  187. [9] = "486 DX/4-WB"
  188. }
  189. },
  190. { .vendor = X86_VENDOR_INTEL, .family = 5, .model_names =
  191. {
  192. [0] = "Pentium 60/66 A-step",
  193. [1] = "Pentium 60/66",
  194. [2] = "Pentium 75 - 200",
  195. [3] = "OverDrive PODP5V83",
  196. [4] = "Pentium MMX",
  197. [7] = "Mobile Pentium 75 - 200",
  198. [8] = "Mobile Pentium MMX"
  199. }
  200. },
  201. { .vendor = X86_VENDOR_INTEL, .family = 6, .model_names =
  202. {
  203. [0] = "Pentium Pro A-step",
  204. [1] = "Pentium Pro",
  205. [3] = "Pentium II (Klamath)",
  206. [4] = "Pentium II (Deschutes)",
  207. [5] = "Pentium II (Deschutes)",
  208. [6] = "Mobile Pentium II",
  209. [7] = "Pentium III (Katmai)",
  210. [8] = "Pentium III (Coppermine)",
  211. [10] = "Pentium III (Cascades)",
  212. [11] = "Pentium III (Tualatin)",
  213. }
  214. },
  215. { .vendor = X86_VENDOR_INTEL, .family = 15, .model_names =
  216. {
  217. [0] = "Pentium 4 (Unknown)",
  218. [1] = "Pentium 4 (Willamette)",
  219. [2] = "Pentium 4 (Northwood)",
  220. [4] = "Pentium 4 (Foster)",
  221. [5] = "Pentium 4 (Foster)",
  222. }
  223. },
  224. },
  225. .c_init = init_intel,
  226. .c_identify = generic_identify,
  227. .c_size_cache = intel_size_cache,
  228. };
  229. __init int intel_cpu_init(void)
  230. {
  231. cpu_devs[X86_VENDOR_INTEL] = &intel_cpu_dev;
  232. return 0;
  233. }
  234. // arch_initcall(intel_cpu_init);