diff options
Diffstat (limited to 'arch/x86/kernel/cpu/intel_64.c')
-rw-r--r-- | arch/x86/kernel/cpu/intel_64.c | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/arch/x86/kernel/cpu/intel_64.c b/arch/x86/kernel/cpu/intel_64.c new file mode 100644 index 000000000000..fcb1cc9d75ca --- /dev/null +++ b/arch/x86/kernel/cpu/intel_64.c | |||
@@ -0,0 +1,103 @@ | |||
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 | |||
8 | #include "cpu.h" | ||
9 | |||
10 | static void __cpuinit early_init_intel(struct cpuinfo_x86 *c) | ||
11 | { | ||
12 | if ((c->x86 == 0xf && c->x86_model >= 0x03) || | ||
13 | (c->x86 == 0x6 && c->x86_model >= 0x0e)) | ||
14 | set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC); | ||
15 | } | ||
16 | |||
17 | /* | ||
18 | * find out the number of processor cores on the die | ||
19 | */ | ||
20 | static int __cpuinit intel_num_cpu_cores(struct cpuinfo_x86 *c) | ||
21 | { | ||
22 | unsigned int eax, t; | ||
23 | |||
24 | if (c->cpuid_level < 4) | ||
25 | return 1; | ||
26 | |||
27 | cpuid_count(4, 0, &eax, &t, &t, &t); | ||
28 | |||
29 | if (eax & 0x1f) | ||
30 | return ((eax >> 26) + 1); | ||
31 | else | ||
32 | return 1; | ||
33 | } | ||
34 | |||
35 | static void __cpuinit srat_detect_node(void) | ||
36 | { | ||
37 | #ifdef CONFIG_NUMA | ||
38 | unsigned node; | ||
39 | int cpu = smp_processor_id(); | ||
40 | int apicid = hard_smp_processor_id(); | ||
41 | |||
42 | /* Don't do the funky fallback heuristics the AMD version employs | ||
43 | for now. */ | ||
44 | node = apicid_to_node[apicid]; | ||
45 | if (node == NUMA_NO_NODE || !node_online(node)) | ||
46 | node = first_node(node_online_map); | ||
47 | numa_set_node(cpu, node); | ||
48 | |||
49 | printk(KERN_INFO "CPU %d/%x -> Node %d\n", cpu, apicid, node); | ||
50 | #endif | ||
51 | } | ||
52 | |||
53 | static void __cpuinit init_intel(struct cpuinfo_x86 *c) | ||
54 | { | ||
55 | /* Cache sizes */ | ||
56 | unsigned n; | ||
57 | |||
58 | init_intel_cacheinfo(c); | ||
59 | if (c->cpuid_level > 9) { | ||
60 | unsigned eax = cpuid_eax(10); | ||
61 | /* Check for version and the number of counters */ | ||
62 | if ((eax & 0xff) && (((eax>>8) & 0xff) > 1)) | ||
63 | set_cpu_cap(c, X86_FEATURE_ARCH_PERFMON); | ||
64 | } | ||
65 | |||
66 | if (cpu_has_ds) { | ||
67 | unsigned int l1, l2; | ||
68 | rdmsr(MSR_IA32_MISC_ENABLE, l1, l2); | ||
69 | if (!(l1 & (1<<11))) | ||
70 | set_cpu_cap(c, X86_FEATURE_BTS); | ||
71 | if (!(l1 & (1<<12))) | ||
72 | set_cpu_cap(c, X86_FEATURE_PEBS); | ||
73 | } | ||
74 | |||
75 | |||
76 | if (cpu_has_bts) | ||
77 | ds_init_intel(c); | ||
78 | |||
79 | n = c->extended_cpuid_level; | ||
80 | if (n >= 0x80000008) { | ||
81 | unsigned eax = cpuid_eax(0x80000008); | ||
82 | c->x86_virt_bits = (eax >> 8) & 0xff; | ||
83 | c->x86_phys_bits = eax & 0xff; | ||
84 | } | ||
85 | |||
86 | if (c->x86 == 15) | ||
87 | c->x86_cache_alignment = c->x86_clflush_size * 2; | ||
88 | if (c->x86 == 6) | ||
89 | set_cpu_cap(c, X86_FEATURE_REP_GOOD); | ||
90 | set_cpu_cap(c, X86_FEATURE_LFENCE_RDTSC); | ||
91 | c->x86_max_cores = intel_num_cpu_cores(c); | ||
92 | |||
93 | srat_detect_node(); | ||
94 | } | ||
95 | |||
96 | static struct cpu_dev intel_cpu_dev __cpuinitdata = { | ||
97 | .c_vendor = "Intel", | ||
98 | .c_ident = { "GenuineIntel" }, | ||
99 | .c_early_init = early_init_intel, | ||
100 | .c_init = init_intel, | ||
101 | }; | ||
102 | cpu_vendor_dev_register(X86_VENDOR_INTEL, &intel_cpu_dev); | ||
103 | |||