intel_64.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #include <linux/init.h>
  2. #include <linux/smp.h>
  3. #include <asm/processor.h>
  4. #include <asm/ptrace.h>
  5. #include <asm/topology.h>
  6. #include <asm/numa_64.h>
  7. void __cpuinit early_init_intel(struct cpuinfo_x86 *c)
  8. {
  9. if ((c->x86 == 0xf && c->x86_model >= 0x03) ||
  10. (c->x86 == 0x6 && c->x86_model >= 0x0e))
  11. set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
  12. }
  13. /*
  14. * find out the number of processor cores on the die
  15. */
  16. static int __cpuinit intel_num_cpu_cores(struct cpuinfo_x86 *c)
  17. {
  18. unsigned int eax, t;
  19. if (c->cpuid_level < 4)
  20. return 1;
  21. cpuid_count(4, 0, &eax, &t, &t, &t);
  22. if (eax & 0x1f)
  23. return ((eax >> 26) + 1);
  24. else
  25. return 1;
  26. }
  27. static void __cpuinit srat_detect_node(void)
  28. {
  29. #ifdef CONFIG_NUMA
  30. unsigned node;
  31. int cpu = smp_processor_id();
  32. int apicid = hard_smp_processor_id();
  33. /* Don't do the funky fallback heuristics the AMD version employs
  34. for now. */
  35. node = apicid_to_node[apicid];
  36. if (node == NUMA_NO_NODE || !node_online(node))
  37. node = first_node(node_online_map);
  38. numa_set_node(cpu, node);
  39. printk(KERN_INFO "CPU %d/%x -> Node %d\n", cpu, apicid, node);
  40. #endif
  41. }
  42. void __cpuinit init_intel(struct cpuinfo_x86 *c)
  43. {
  44. /* Cache sizes */
  45. unsigned n;
  46. init_intel_cacheinfo(c);
  47. if (c->cpuid_level > 9) {
  48. unsigned eax = cpuid_eax(10);
  49. /* Check for version and the number of counters */
  50. if ((eax & 0xff) && (((eax>>8) & 0xff) > 1))
  51. set_cpu_cap(c, X86_FEATURE_ARCH_PERFMON);
  52. }
  53. if (cpu_has_ds) {
  54. unsigned int l1, l2;
  55. rdmsr(MSR_IA32_MISC_ENABLE, l1, l2);
  56. if (!(l1 & (1<<11)))
  57. set_cpu_cap(c, X86_FEATURE_BTS);
  58. if (!(l1 & (1<<12)))
  59. set_cpu_cap(c, X86_FEATURE_PEBS);
  60. }
  61. if (cpu_has_bts)
  62. ds_init_intel(c);
  63. n = c->extended_cpuid_level;
  64. if (n >= 0x80000008) {
  65. unsigned eax = cpuid_eax(0x80000008);
  66. c->x86_virt_bits = (eax >> 8) & 0xff;
  67. c->x86_phys_bits = eax & 0xff;
  68. }
  69. if (c->x86 == 15)
  70. c->x86_cache_alignment = c->x86_clflush_size * 2;
  71. if (c->x86 == 6)
  72. set_cpu_cap(c, X86_FEATURE_REP_GOOD);
  73. set_cpu_cap(c, X86_FEATURE_LFENCE_RDTSC);
  74. c->x86_max_cores = intel_num_cpu_cores(c);
  75. srat_detect_node();
  76. }