]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | // SPDX-License-Identifier: GPL-2.0 |
1da177e4 LT |
2 | #include <linux/kernel.h> |
3 | ||
4 | #include <linux/string.h> | |
5 | #include <linux/bitops.h> | |
6 | #include <linux/smp.h> | |
83ce4009 | 7 | #include <linux/sched.h> |
e6017571 | 8 | #include <linux/sched/clock.h> |
1da177e4 | 9 | #include <linux/thread_info.h> |
186f4360 | 10 | #include <linux/init.h> |
8bdbd962 | 11 | #include <linux/uaccess.h> |
1da177e4 | 12 | |
cd4d09ec | 13 | #include <asm/cpufeature.h> |
d72b1b4f | 14 | #include <asm/pgtable.h> |
1da177e4 | 15 | #include <asm/msr.h> |
73bdb73f | 16 | #include <asm/bugs.h> |
1f442d70 | 17 | #include <asm/cpu.h> |
08e237fa | 18 | #include <asm/intel-family.h> |
4167709b | 19 | #include <asm/microcode_intel.h> |
e16fd002 GA |
20 | #include <asm/hwcap2.h> |
21 | #include <asm/elf.h> | |
1da177e4 | 22 | |
185f3b9d | 23 | #ifdef CONFIG_X86_64 |
8bdbd962 | 24 | #include <linux/topology.h> |
185f3b9d YL |
25 | #endif |
26 | ||
1da177e4 LT |
27 | #include "cpu.h" |
28 | ||
29 | #ifdef CONFIG_X86_LOCAL_APIC | |
30 | #include <asm/mpspec.h> | |
31 | #include <asm/apic.h> | |
1da177e4 LT |
32 | #endif |
33 | ||
0f6ff2bc DH |
34 | /* |
35 | * Just in case our CPU detection goes bad, or you have a weird system, | |
36 | * allow a way to override the automatic disabling of MPX. | |
37 | */ | |
38 | static int forcempx; | |
39 | ||
40 | static int __init forcempx_setup(char *__unused) | |
41 | { | |
42 | forcempx = 1; | |
43 | ||
44 | return 1; | |
45 | } | |
46 | __setup("intel-skd-046-workaround=disable", forcempx_setup); | |
47 | ||
48 | void check_mpx_erratum(struct cpuinfo_x86 *c) | |
49 | { | |
50 | if (forcempx) | |
51 | return; | |
52 | /* | |
53 | * Turn off the MPX feature on CPUs where SMEP is not | |
54 | * available or disabled. | |
55 | * | |
56 | * Works around Intel Erratum SKD046: "Branch Instructions | |
57 | * May Initialize MPX Bound Registers Incorrectly". | |
58 | * | |
59 | * This might falsely disable MPX on systems without | |
60 | * SMEP, like Atom processors without SMEP. But there | |
61 | * is no such hardware known at the moment. | |
62 | */ | |
63 | if (cpu_has(c, X86_FEATURE_MPX) && !cpu_has(c, X86_FEATURE_SMEP)) { | |
64 | setup_clear_cpu_cap(X86_FEATURE_MPX); | |
65 | pr_warn("x86/mpx: Disabling MPX since SMEP not present\n"); | |
66 | } | |
67 | } | |
68 | ||
e16fd002 GA |
69 | static bool ring3mwait_disabled __read_mostly; |
70 | ||
71 | static int __init ring3mwait_disable(char *__unused) | |
72 | { | |
73 | ring3mwait_disabled = true; | |
74 | return 0; | |
75 | } | |
76 | __setup("ring3mwait=disable", ring3mwait_disable); | |
77 | ||
78 | static void probe_xeon_phi_r3mwait(struct cpuinfo_x86 *c) | |
79 | { | |
80 | /* | |
81 | * Ring 3 MONITOR/MWAIT feature cannot be detected without | |
82 | * cpu model and family comparison. | |
83 | */ | |
4d8bb006 | 84 | if (c->x86 != 6) |
e16fd002 | 85 | return; |
4d8bb006 PL |
86 | switch (c->x86_model) { |
87 | case INTEL_FAM6_XEON_PHI_KNL: | |
88 | case INTEL_FAM6_XEON_PHI_KNM: | |
89 | break; | |
90 | default: | |
91 | return; | |
92 | } | |
e16fd002 | 93 | |
e9ea1e7f | 94 | if (ring3mwait_disabled) |
e16fd002 | 95 | return; |
e16fd002 GA |
96 | |
97 | set_cpu_cap(c, X86_FEATURE_RING3MWAIT); | |
e9ea1e7f KH |
98 | this_cpu_or(msr_misc_features_shadow, |
99 | 1UL << MSR_MISC_FEATURES_ENABLES_RING3MWAIT_BIT); | |
e16fd002 GA |
100 | |
101 | if (c == &boot_cpu_data) | |
102 | ELF_HWCAP2 |= HWCAP2_RING3MWAIT; | |
103 | } | |
104 | ||
a5b29663 DW |
105 | /* |
106 | * Early microcode releases for the Spectre v2 mitigation were broken. | |
107 | * Information taken from; | |
108 | * - https://newsroom.intel.com/wp-content/uploads/sites/11/2018/01/microcode-update-guidance.pdf | |
109 | * - https://kb.vmware.com/s/article/52345 | |
110 | * - Microcode revisions observed in the wild | |
111 | * - Release note from 20180108 microcode release | |
112 | */ | |
113 | struct sku_microcode { | |
114 | u8 model; | |
115 | u8 stepping; | |
116 | u32 microcode; | |
117 | }; | |
118 | static const struct sku_microcode spectre_bad_microcodes[] = { | |
d37fc6d3 DW |
119 | { INTEL_FAM6_KABYLAKE_DESKTOP, 0x0B, 0x80 }, |
120 | { INTEL_FAM6_KABYLAKE_DESKTOP, 0x0A, 0x80 }, | |
121 | { INTEL_FAM6_KABYLAKE_DESKTOP, 0x09, 0x80 }, | |
122 | { INTEL_FAM6_KABYLAKE_MOBILE, 0x0A, 0x80 }, | |
123 | { INTEL_FAM6_KABYLAKE_MOBILE, 0x09, 0x80 }, | |
a5b29663 DW |
124 | { INTEL_FAM6_SKYLAKE_X, 0x03, 0x0100013e }, |
125 | { INTEL_FAM6_SKYLAKE_X, 0x04, 0x0200003c }, | |
d37fc6d3 | 126 | { INTEL_FAM6_SKYLAKE_DESKTOP, 0x03, 0xc2 }, |
a5b29663 DW |
127 | { INTEL_FAM6_BROADWELL_CORE, 0x04, 0x28 }, |
128 | { INTEL_FAM6_BROADWELL_GT3E, 0x01, 0x1b }, | |
129 | { INTEL_FAM6_BROADWELL_XEON_D, 0x02, 0x14 }, | |
130 | { INTEL_FAM6_BROADWELL_XEON_D, 0x03, 0x07000011 }, | |
131 | { INTEL_FAM6_BROADWELL_X, 0x01, 0x0b000025 }, | |
132 | { INTEL_FAM6_HASWELL_ULT, 0x01, 0x21 }, | |
133 | { INTEL_FAM6_HASWELL_GT3E, 0x01, 0x18 }, | |
134 | { INTEL_FAM6_HASWELL_CORE, 0x03, 0x23 }, | |
135 | { INTEL_FAM6_HASWELL_X, 0x02, 0x3b }, | |
136 | { INTEL_FAM6_HASWELL_X, 0x04, 0x10 }, | |
137 | { INTEL_FAM6_IVYBRIDGE_X, 0x04, 0x42a }, | |
a5b29663 DW |
138 | /* Observed in the wild */ |
139 | { INTEL_FAM6_SANDYBRIDGE_X, 0x06, 0x61b }, | |
140 | { INTEL_FAM6_SANDYBRIDGE_X, 0x07, 0x712 }, | |
141 | }; | |
142 | ||
143 | static bool bad_spectre_microcode(struct cpuinfo_x86 *c) | |
144 | { | |
145 | int i; | |
146 | ||
36268223 KRW |
147 | /* |
148 | * We know that the hypervisor lie to us on the microcode version so | |
149 | * we may as well hope that it is running the correct version. | |
150 | */ | |
151 | if (cpu_has(c, X86_FEATURE_HYPERVISOR)) | |
152 | return false; | |
153 | ||
a5b29663 DW |
154 | for (i = 0; i < ARRAY_SIZE(spectre_bad_microcodes); i++) { |
155 | if (c->x86_model == spectre_bad_microcodes[i].model && | |
b399151c | 156 | c->x86_stepping == spectre_bad_microcodes[i].stepping) |
a5b29663 DW |
157 | return (c->microcode <= spectre_bad_microcodes[i].microcode); |
158 | } | |
159 | return false; | |
160 | } | |
161 | ||
148f9bb8 | 162 | static void early_init_intel(struct cpuinfo_x86 *c) |
1da177e4 | 163 | { |
161ec53c FY |
164 | u64 misc_enable; |
165 | ||
99fb4d34 | 166 | /* Unmask CPUID levels if masked: */ |
30a0fb94 | 167 | if (c->x86 > 6 || (c->x86 == 6 && c->x86_model >= 0xd)) { |
0b131be8 PA |
168 | if (msr_clear_bit(MSR_IA32_MISC_ENABLE, |
169 | MSR_IA32_MISC_ENABLE_LIMIT_CPUID_BIT) > 0) { | |
99fb4d34 | 170 | c->cpuid_level = cpuid_eax(0); |
d900329e | 171 | get_cpu_cap(c); |
99fb4d34 | 172 | } |
066941bd PA |
173 | } |
174 | ||
2b16a235 AK |
175 | if ((c->x86 == 0xf && c->x86_model >= 0x03) || |
176 | (c->x86 == 0x6 && c->x86_model >= 0x0e)) | |
177 | set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC); | |
185f3b9d | 178 | |
4167709b BP |
179 | if (c->x86 >= 6 && !cpu_has(c, X86_FEATURE_IA64)) |
180 | c->microcode = intel_get_microcode_revision(); | |
506ed6b5 | 181 | |
2961298e | 182 | /* Now if any of them are set, check the blacklist and clear the lot */ |
7fcae111 DW |
183 | if ((cpu_has(c, X86_FEATURE_SPEC_CTRL) || |
184 | cpu_has(c, X86_FEATURE_INTEL_STIBP) || | |
185 | cpu_has(c, X86_FEATURE_IBRS) || cpu_has(c, X86_FEATURE_IBPB) || | |
2961298e DW |
186 | cpu_has(c, X86_FEATURE_STIBP)) && bad_spectre_microcode(c)) { |
187 | pr_warn("Intel Spectre v2 broken microcode detected; disabling Speculation Control\n"); | |
7fcae111 DW |
188 | setup_clear_cpu_cap(X86_FEATURE_IBRS); |
189 | setup_clear_cpu_cap(X86_FEATURE_IBPB); | |
190 | setup_clear_cpu_cap(X86_FEATURE_STIBP); | |
191 | setup_clear_cpu_cap(X86_FEATURE_SPEC_CTRL); | |
192 | setup_clear_cpu_cap(X86_FEATURE_INTEL_STIBP); | |
a5b29663 DW |
193 | } |
194 | ||
7a0fc404 PA |
195 | /* |
196 | * Atom erratum AAE44/AAF40/AAG38/AAH41: | |
197 | * | |
198 | * A race condition between speculative fetches and invalidating | |
199 | * a large page. This is worked around in microcode, but we | |
200 | * need the microcode to have already been loaded... so if it is | |
201 | * not, recommend a BIOS update and disable large pages. | |
202 | */ | |
b399151c | 203 | if (c->x86 == 6 && c->x86_model == 0x1c && c->x86_stepping <= 2 && |
30963c0a | 204 | c->microcode < 0x20e) { |
1b74dde7 | 205 | pr_warn("Atom PSE erratum detected, BIOS microcode update recommended\n"); |
30963c0a | 206 | clear_cpu_cap(c, X86_FEATURE_PSE); |
7a0fc404 PA |
207 | } |
208 | ||
185f3b9d YL |
209 | #ifdef CONFIG_X86_64 |
210 | set_cpu_cap(c, X86_FEATURE_SYSENTER32); | |
211 | #else | |
212 | /* Netburst reports 64 bytes clflush size, but does IO in 128 bytes */ | |
213 | if (c->x86 == 15 && c->x86_cache_alignment == 64) | |
214 | c->x86_cache_alignment = 128; | |
215 | #endif | |
40fb1715 | 216 | |
13c6c532 JB |
217 | /* CPUID workaround for 0F33/0F34 CPU */ |
218 | if (c->x86 == 0xF && c->x86_model == 0x3 | |
b399151c | 219 | && (c->x86_stepping == 0x3 || c->x86_stepping == 0x4)) |
13c6c532 JB |
220 | c->x86_phys_bits = 36; |
221 | ||
40fb1715 VP |
222 | /* |
223 | * c->x86_power is 8000_0007 edx. Bit 8 is TSC runs at constant rate | |
83ce4009 IM |
224 | * with P/T states and does not stop in deep C-states. |
225 | * | |
226 | * It is also reliable across cores and sockets. (but not across | |
227 | * cabinets - we turn it off in that case explicitly.) | |
40fb1715 VP |
228 | */ |
229 | if (c->x86_power & (1 << 8)) { | |
230 | set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC); | |
231 | set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC); | |
232 | } | |
233 | ||
c54fdbb2 FT |
234 | /* Penwell and Cloverview have the TSC which doesn't sleep on S3 */ |
235 | if (c->x86 == 6) { | |
236 | switch (c->x86_model) { | |
237 | case 0x27: /* Penwell */ | |
238 | case 0x35: /* Cloverview */ | |
354dbaa7 | 239 | case 0x4a: /* Merrifield */ |
c54fdbb2 FT |
240 | set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC_S3); |
241 | break; | |
242 | default: | |
243 | break; | |
244 | } | |
245 | } | |
246 | ||
75a04811 PA |
247 | /* |
248 | * There is a known erratum on Pentium III and Core Solo | |
249 | * and Core Duo CPUs. | |
250 | * " Page with PAT set to WC while associated MTRR is UC | |
251 | * may consolidate to UC " | |
252 | * Because of this erratum, it is better to stick with | |
253 | * setting WC in MTRR rather than using PAT on these CPUs. | |
254 | * | |
255 | * Enable PAT WC only on P4, Core 2 or later CPUs. | |
256 | */ | |
257 | if (c->x86 == 6 && c->x86_model < 15) | |
258 | clear_cpu_cap(c, X86_FEATURE_PAT); | |
f8561296 | 259 | |
161ec53c FY |
260 | /* |
261 | * If fast string is not enabled in IA32_MISC_ENABLE for any reason, | |
262 | * clear the fast string and enhanced fast string CPU capabilities. | |
263 | */ | |
264 | if (c->x86 > 6 || (c->x86 == 6 && c->x86_model >= 0xd)) { | |
265 | rdmsrl(MSR_IA32_MISC_ENABLE, misc_enable); | |
266 | if (!(misc_enable & MSR_IA32_MISC_ENABLE_FAST_STRING)) { | |
1b74dde7 | 267 | pr_info("Disabled fast string operations\n"); |
161ec53c FY |
268 | setup_clear_cpu_cap(X86_FEATURE_REP_GOOD); |
269 | setup_clear_cpu_cap(X86_FEATURE_ERMS); | |
270 | } | |
271 | } | |
ee1b5b16 BD |
272 | |
273 | /* | |
274 | * Intel Quark Core DevMan_001.pdf section 6.4.11 | |
275 | * "The operating system also is required to invalidate (i.e., flush) | |
276 | * the TLB when any changes are made to any of the page table entries. | |
277 | * The operating system must reload CR3 to cause the TLB to be flushed" | |
278 | * | |
c109bf95 BP |
279 | * As a result, boot_cpu_has(X86_FEATURE_PGE) in arch/x86/include/asm/tlbflush.h |
280 | * should be false so that __flush_tlb_all() causes CR3 insted of CR4.PGE | |
281 | * to be modified. | |
ee1b5b16 BD |
282 | */ |
283 | if (c->x86 == 5 && c->x86_model == 9) { | |
284 | pr_info("Disabling PGE capability bit\n"); | |
285 | setup_clear_cpu_cap(X86_FEATURE_PGE); | |
286 | } | |
1f12e32f TG |
287 | |
288 | if (c->cpuid_level >= 0x00000001) { | |
289 | u32 eax, ebx, ecx, edx; | |
290 | ||
291 | cpuid(0x00000001, &eax, &ebx, &ecx, &edx); | |
292 | /* | |
293 | * If HTT (EDX[28]) is set EBX[16:23] contain the number of | |
294 | * apicids which are reserved per package. Store the resulting | |
295 | * shift value for the package management code. | |
296 | */ | |
297 | if (edx & (1U << 28)) | |
298 | c->x86_coreid_bits = get_count_order((ebx >> 16) & 0xff); | |
299 | } | |
0f6ff2bc DH |
300 | |
301 | check_mpx_erratum(c); | |
1da177e4 LT |
302 | } |
303 | ||
185f3b9d | 304 | #ifdef CONFIG_X86_32 |
1da177e4 LT |
305 | /* |
306 | * Early probe support logic for ppro memory erratum #50 | |
307 | * | |
308 | * This is called before we do cpu ident work | |
309 | */ | |
65eb6b43 | 310 | |
148f9bb8 | 311 | int ppro_with_ram_bug(void) |
1da177e4 LT |
312 | { |
313 | /* Uses data from early_cpu_detect now */ | |
314 | if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL && | |
315 | boot_cpu_data.x86 == 6 && | |
316 | boot_cpu_data.x86_model == 1 && | |
b399151c | 317 | boot_cpu_data.x86_stepping < 8) { |
1b74dde7 | 318 | pr_info("Pentium Pro with Errata#50 detected. Taking evasive action.\n"); |
1da177e4 LT |
319 | return 1; |
320 | } | |
321 | return 0; | |
322 | } | |
65eb6b43 | 323 | |
148f9bb8 | 324 | static void intel_smp_check(struct cpuinfo_x86 *c) |
1f442d70 | 325 | { |
1f442d70 | 326 | /* calling is from identify_secondary_cpu() ? */ |
f6e9456c | 327 | if (!c->cpu_index) |
1f442d70 YL |
328 | return; |
329 | ||
330 | /* | |
331 | * Mask B, Pentium, but not Pentium MMX | |
332 | */ | |
333 | if (c->x86 == 5 && | |
b399151c | 334 | c->x86_stepping >= 1 && c->x86_stepping <= 4 && |
1f442d70 YL |
335 | c->x86_model <= 3) { |
336 | /* | |
337 | * Remember we have B step Pentia with bugs | |
338 | */ | |
339 | WARN_ONCE(1, "WARNING: SMP operation may be unreliable" | |
340 | "with B stepping processors.\n"); | |
341 | } | |
1f442d70 YL |
342 | } |
343 | ||
69f2366c CB |
344 | static int forcepae; |
345 | static int __init forcepae_setup(char *__unused) | |
346 | { | |
347 | forcepae = 1; | |
348 | return 1; | |
349 | } | |
350 | __setup("forcepae", forcepae_setup); | |
351 | ||
148f9bb8 | 352 | static void intel_workarounds(struct cpuinfo_x86 *c) |
1da177e4 | 353 | { |
4052704d YL |
354 | #ifdef CONFIG_X86_F00F_BUG |
355 | /* | |
d4e1a0af | 356 | * All models of Pentium and Pentium with MMX technology CPUs |
8bdbd962 | 357 | * have the F0 0F bug, which lets nonprivileged users lock up the |
4eefbe79 | 358 | * system. Announce that the fault handler will be checking for it. |
d4e1a0af | 359 | * The Quark is also family 5, but does not have the same bug. |
4052704d | 360 | */ |
e2604b49 | 361 | clear_cpu_bug(c, X86_BUG_F00F); |
fa392794 | 362 | if (c->x86 == 5 && c->x86_model < 9) { |
4052704d YL |
363 | static int f00f_workaround_enabled; |
364 | ||
e2604b49 | 365 | set_cpu_bug(c, X86_BUG_F00F); |
4052704d | 366 | if (!f00f_workaround_enabled) { |
1b74dde7 | 367 | pr_notice("Intel Pentium with F0 0F bug - workaround enabled.\n"); |
4052704d YL |
368 | f00f_workaround_enabled = 1; |
369 | } | |
370 | } | |
371 | #endif | |
372 | ||
373 | /* | |
374 | * SEP CPUID bug: Pentium Pro reports SEP but doesn't have it until | |
375 | * model 3 mask 3 | |
376 | */ | |
b399151c | 377 | if ((c->x86<<8 | c->x86_model<<4 | c->x86_stepping) < 0x633) |
4052704d YL |
378 | clear_cpu_cap(c, X86_FEATURE_SEP); |
379 | ||
69f2366c CB |
380 | /* |
381 | * PAE CPUID issue: many Pentium M report no PAE but may have a | |
382 | * functionally usable PAE implementation. | |
383 | * Forcefully enable PAE if kernel parameter "forcepae" is present. | |
384 | */ | |
385 | if (forcepae) { | |
1b74dde7 | 386 | pr_warn("PAE forced!\n"); |
69f2366c CB |
387 | set_cpu_cap(c, X86_FEATURE_PAE); |
388 | add_taint(TAINT_CPU_OUT_OF_SPEC, LOCKDEP_NOW_UNRELIABLE); | |
389 | } | |
390 | ||
4052704d | 391 | /* |
f0133acc | 392 | * P4 Xeon erratum 037 workaround. |
4052704d YL |
393 | * Hardware prefetcher may cause stale data to be loaded into the cache. |
394 | */ | |
b399151c | 395 | if ((c->x86 == 15) && (c->x86_model == 1) && (c->x86_stepping == 1)) { |
0b131be8 | 396 | if (msr_set_bit(MSR_IA32_MISC_ENABLE, |
f0133acc | 397 | MSR_IA32_MISC_ENABLE_PREFETCH_DISABLE_BIT) > 0) { |
c0a639ad | 398 | pr_info("CPU: C0 stepping P4 Xeon detected.\n"); |
f0133acc | 399 | pr_info("CPU: Disabling hardware prefetching (Erratum 037)\n"); |
1da177e4 LT |
400 | } |
401 | } | |
1da177e4 | 402 | |
4052704d YL |
403 | /* |
404 | * See if we have a good local APIC by checking for buggy Pentia, | |
405 | * i.e. all B steppings and the C2 stepping of P54C when using their | |
406 | * integrated APIC (see 11AP erratum in "Pentium Processor | |
407 | * Specification Update"). | |
408 | */ | |
93984fbd | 409 | if (boot_cpu_has(X86_FEATURE_APIC) && (c->x86<<8 | c->x86_model<<4) == 0x520 && |
b399151c | 410 | (c->x86_stepping < 0x6 || c->x86_stepping == 0xb)) |
9b13a93d | 411 | set_cpu_bug(c, X86_BUG_11AP); |
185f3b9d | 412 | |
185f3b9d | 413 | |
4052704d | 414 | #ifdef CONFIG_X86_INTEL_USERCOPY |
185f3b9d | 415 | /* |
4052704d | 416 | * Set up the preferred alignment for movsl bulk memory moves |
185f3b9d | 417 | */ |
4052704d YL |
418 | switch (c->x86) { |
419 | case 4: /* 486: untested */ | |
420 | break; | |
421 | case 5: /* Old Pentia: untested */ | |
422 | break; | |
423 | case 6: /* PII/PIII only like movsl with 8-byte alignment */ | |
424 | movsl_mask.mask = 7; | |
425 | break; | |
426 | case 15: /* P4 is OK down to 8-byte alignment */ | |
427 | movsl_mask.mask = 7; | |
428 | break; | |
429 | } | |
185f3b9d | 430 | #endif |
4052704d | 431 | |
1f442d70 | 432 | intel_smp_check(c); |
4052704d YL |
433 | } |
434 | #else | |
148f9bb8 | 435 | static void intel_workarounds(struct cpuinfo_x86 *c) |
4052704d YL |
436 | { |
437 | } | |
185f3b9d YL |
438 | #endif |
439 | ||
148f9bb8 | 440 | static void srat_detect_node(struct cpuinfo_x86 *c) |
185f3b9d | 441 | { |
645a7919 | 442 | #ifdef CONFIG_NUMA |
185f3b9d YL |
443 | unsigned node; |
444 | int cpu = smp_processor_id(); | |
185f3b9d YL |
445 | |
446 | /* Don't do the funky fallback heuristics the AMD version employs | |
447 | for now. */ | |
bbc9e2f4 | 448 | node = numa_cpu_node(cpu); |
50f2d7f6 | 449 | if (node == NUMA_NO_NODE || !node_online(node)) { |
d9c2d5ac YL |
450 | /* reuse the value from init_cpu_to_node() */ |
451 | node = cpu_to_node(cpu); | |
452 | } | |
185f3b9d | 453 | numa_set_node(cpu, node); |
185f3b9d YL |
454 | #endif |
455 | } | |
456 | ||
3dd9d514 AK |
457 | /* |
458 | * find out the number of processor cores on the die | |
459 | */ | |
148f9bb8 | 460 | static int intel_num_cpu_cores(struct cpuinfo_x86 *c) |
3dd9d514 | 461 | { |
f2ab4461 | 462 | unsigned int eax, ebx, ecx, edx; |
3dd9d514 | 463 | |
8d415ee2 | 464 | if (!IS_ENABLED(CONFIG_SMP) || c->cpuid_level < 4) |
3dd9d514 AK |
465 | return 1; |
466 | ||
f2ab4461 ZA |
467 | /* Intel has a non-standard dependency on %ecx for this CPUID level. */ |
468 | cpuid_count(4, 0, &eax, &ebx, &ecx, &edx); | |
3dd9d514 | 469 | if (eax & 0x1f) |
8bdbd962 | 470 | return (eax >> 26) + 1; |
3dd9d514 AK |
471 | else |
472 | return 1; | |
473 | } | |
474 | ||
148f9bb8 | 475 | static void detect_vmx_virtcap(struct cpuinfo_x86 *c) |
e38e05a8 SY |
476 | { |
477 | /* Intel VMX MSR indicated features */ | |
478 | #define X86_VMX_FEATURE_PROC_CTLS_TPR_SHADOW 0x00200000 | |
479 | #define X86_VMX_FEATURE_PROC_CTLS_VNMI 0x00400000 | |
480 | #define X86_VMX_FEATURE_PROC_CTLS_2ND_CTLS 0x80000000 | |
481 | #define X86_VMX_FEATURE_PROC_CTLS2_VIRT_APIC 0x00000001 | |
482 | #define X86_VMX_FEATURE_PROC_CTLS2_EPT 0x00000002 | |
483 | #define X86_VMX_FEATURE_PROC_CTLS2_VPID 0x00000020 | |
484 | ||
485 | u32 vmx_msr_low, vmx_msr_high, msr_ctl, msr_ctl2; | |
486 | ||
487 | clear_cpu_cap(c, X86_FEATURE_TPR_SHADOW); | |
488 | clear_cpu_cap(c, X86_FEATURE_VNMI); | |
489 | clear_cpu_cap(c, X86_FEATURE_FLEXPRIORITY); | |
490 | clear_cpu_cap(c, X86_FEATURE_EPT); | |
491 | clear_cpu_cap(c, X86_FEATURE_VPID); | |
492 | ||
493 | rdmsr(MSR_IA32_VMX_PROCBASED_CTLS, vmx_msr_low, vmx_msr_high); | |
494 | msr_ctl = vmx_msr_high | vmx_msr_low; | |
495 | if (msr_ctl & X86_VMX_FEATURE_PROC_CTLS_TPR_SHADOW) | |
496 | set_cpu_cap(c, X86_FEATURE_TPR_SHADOW); | |
497 | if (msr_ctl & X86_VMX_FEATURE_PROC_CTLS_VNMI) | |
498 | set_cpu_cap(c, X86_FEATURE_VNMI); | |
499 | if (msr_ctl & X86_VMX_FEATURE_PROC_CTLS_2ND_CTLS) { | |
500 | rdmsr(MSR_IA32_VMX_PROCBASED_CTLS2, | |
501 | vmx_msr_low, vmx_msr_high); | |
502 | msr_ctl2 = vmx_msr_high | vmx_msr_low; | |
503 | if ((msr_ctl2 & X86_VMX_FEATURE_PROC_CTLS2_VIRT_APIC) && | |
504 | (msr_ctl & X86_VMX_FEATURE_PROC_CTLS_TPR_SHADOW)) | |
505 | set_cpu_cap(c, X86_FEATURE_FLEXPRIORITY); | |
506 | if (msr_ctl2 & X86_VMX_FEATURE_PROC_CTLS2_EPT) | |
507 | set_cpu_cap(c, X86_FEATURE_EPT); | |
508 | if (msr_ctl2 & X86_VMX_FEATURE_PROC_CTLS2_VPID) | |
509 | set_cpu_cap(c, X86_FEATURE_VPID); | |
510 | } | |
511 | } | |
512 | ||
b51ef52d LA |
513 | static void init_intel_energy_perf(struct cpuinfo_x86 *c) |
514 | { | |
515 | u64 epb; | |
516 | ||
517 | /* | |
518 | * Initialize MSR_IA32_ENERGY_PERF_BIAS if not already initialized. | |
519 | * (x86_energy_perf_policy(8) is available to change it at run-time.) | |
520 | */ | |
521 | if (!cpu_has(c, X86_FEATURE_EPB)) | |
522 | return; | |
523 | ||
524 | rdmsrl(MSR_IA32_ENERGY_PERF_BIAS, epb); | |
525 | if ((epb & 0xF) != ENERGY_PERF_BIAS_PERFORMANCE) | |
526 | return; | |
527 | ||
528 | pr_warn_once("ENERGY_PERF_BIAS: Set to 'normal', was 'performance'\n"); | |
529 | pr_warn_once("ENERGY_PERF_BIAS: View and update with x86_energy_perf_policy(8)\n"); | |
530 | epb = (epb & ~0xF) | ENERGY_PERF_BIAS_NORMAL; | |
531 | wrmsrl(MSR_IA32_ENERGY_PERF_BIAS, epb); | |
532 | } | |
533 | ||
534 | static void intel_bsp_resume(struct cpuinfo_x86 *c) | |
535 | { | |
536 | /* | |
537 | * MSR_IA32_ENERGY_PERF_BIAS is lost across suspend/resume, | |
538 | * so reinitialize it properly like during bootup: | |
539 | */ | |
540 | init_intel_energy_perf(c); | |
541 | } | |
542 | ||
90218ac7 KH |
543 | static void init_cpuid_fault(struct cpuinfo_x86 *c) |
544 | { | |
545 | u64 msr; | |
546 | ||
547 | if (!rdmsrl_safe(MSR_PLATFORM_INFO, &msr)) { | |
548 | if (msr & MSR_PLATFORM_INFO_CPUID_FAULT) | |
549 | set_cpu_cap(c, X86_FEATURE_CPUID_FAULT); | |
550 | } | |
551 | } | |
552 | ||
553 | static void init_intel_misc_features(struct cpuinfo_x86 *c) | |
554 | { | |
555 | u64 msr; | |
556 | ||
557 | if (rdmsrl_safe(MSR_MISC_FEATURES_ENABLES, &msr)) | |
558 | return; | |
559 | ||
e9ea1e7f KH |
560 | /* Clear all MISC features */ |
561 | this_cpu_write(msr_misc_features_shadow, 0); | |
562 | ||
563 | /* Check features and update capabilities and shadow control bits */ | |
90218ac7 KH |
564 | init_cpuid_fault(c); |
565 | probe_xeon_phi_r3mwait(c); | |
e9ea1e7f KH |
566 | |
567 | msr = this_cpu_read(msr_misc_features_shadow); | |
568 | wrmsrl(MSR_MISC_FEATURES_ENABLES, msr); | |
90218ac7 KH |
569 | } |
570 | ||
148f9bb8 | 571 | static void init_intel(struct cpuinfo_x86 *c) |
1da177e4 LT |
572 | { |
573 | unsigned int l2 = 0; | |
1da177e4 | 574 | |
2b16a235 AK |
575 | early_init_intel(c); |
576 | ||
4052704d | 577 | intel_workarounds(c); |
1da177e4 | 578 | |
345077cd SS |
579 | /* |
580 | * Detect the extended topology information if available. This | |
581 | * will reinitialise the initial_apicid which will be used | |
582 | * in init_intel_cacheinfo() | |
583 | */ | |
584 | detect_extended_topology(c); | |
585 | ||
2a226155 PZ |
586 | if (!cpu_has(c, X86_FEATURE_XTOPOLOGY)) { |
587 | /* | |
588 | * let's use the legacy cpuid vector 0x1 and 0x4 for topology | |
589 | * detection. | |
590 | */ | |
591 | c->x86_max_cores = intel_num_cpu_cores(c); | |
592 | #ifdef CONFIG_X86_32 | |
593 | detect_ht(c); | |
594 | #endif | |
595 | } | |
596 | ||
1da177e4 | 597 | l2 = init_intel_cacheinfo(c); |
aece118e BD |
598 | |
599 | /* Detect legacy cache sizes if init_intel_cacheinfo did not */ | |
600 | if (l2 == 0) { | |
601 | cpu_detect_cache_sizes(c); | |
602 | l2 = c->x86_cache_size; | |
603 | } | |
604 | ||
65eb6b43 | 605 | if (c->cpuid_level > 9) { |
0080e667 VP |
606 | unsigned eax = cpuid_eax(10); |
607 | /* Check for version and the number of counters */ | |
608 | if ((eax & 0xff) && (((eax>>8) & 0xff) > 1)) | |
d0e95ebd | 609 | set_cpu_cap(c, X86_FEATURE_ARCH_PERFMON); |
0080e667 | 610 | } |
1da177e4 | 611 | |
054efb64 | 612 | if (cpu_has(c, X86_FEATURE_XMM2)) |
4052704d | 613 | set_cpu_cap(c, X86_FEATURE_LFENCE_RDTSC); |
362f924b BP |
614 | |
615 | if (boot_cpu_has(X86_FEATURE_DS)) { | |
4052704d YL |
616 | unsigned int l1; |
617 | rdmsr(MSR_IA32_MISC_ENABLE, l1, l2); | |
618 | if (!(l1 & (1<<11))) | |
619 | set_cpu_cap(c, X86_FEATURE_BTS); | |
620 | if (!(l1 & (1<<12))) | |
621 | set_cpu_cap(c, X86_FEATURE_PEBS); | |
4052704d | 622 | } |
1da177e4 | 623 | |
906bf7fd | 624 | if (c->x86 == 6 && boot_cpu_has(X86_FEATURE_CLFLUSH) && |
40e2d7f9 | 625 | (c->x86_model == 29 || c->x86_model == 46 || c->x86_model == 47)) |
9b13a93d | 626 | set_cpu_bug(c, X86_BUG_CLFLUSH_MONITOR); |
e736ad54 | 627 | |
08e237fa PZ |
628 | if (c->x86 == 6 && boot_cpu_has(X86_FEATURE_MWAIT) && |
629 | ((c->x86_model == INTEL_FAM6_ATOM_GOLDMONT))) | |
630 | set_cpu_bug(c, X86_BUG_MONITOR); | |
631 | ||
4052704d YL |
632 | #ifdef CONFIG_X86_64 |
633 | if (c->x86 == 15) | |
634 | c->x86_cache_alignment = c->x86_clflush_size * 2; | |
635 | if (c->x86 == 6) | |
636 | set_cpu_cap(c, X86_FEATURE_REP_GOOD); | |
637 | #else | |
65eb6b43 PC |
638 | /* |
639 | * Names for the Pentium II/Celeron processors | |
640 | * detectable only by also checking the cache size. | |
641 | * Dixon is NOT a Celeron. | |
642 | */ | |
1da177e4 | 643 | if (c->x86 == 6) { |
4052704d YL |
644 | char *p = NULL; |
645 | ||
1da177e4 LT |
646 | switch (c->x86_model) { |
647 | case 5: | |
865be7a8 OZ |
648 | if (l2 == 0) |
649 | p = "Celeron (Covington)"; | |
650 | else if (l2 == 256) | |
651 | p = "Mobile Pentium II (Dixon)"; | |
1da177e4 | 652 | break; |
65eb6b43 | 653 | |
1da177e4 LT |
654 | case 6: |
655 | if (l2 == 128) | |
656 | p = "Celeron (Mendocino)"; | |
b399151c | 657 | else if (c->x86_stepping == 0 || c->x86_stepping == 5) |
1da177e4 LT |
658 | p = "Celeron-A"; |
659 | break; | |
65eb6b43 | 660 | |
1da177e4 LT |
661 | case 8: |
662 | if (l2 == 128) | |
663 | p = "Celeron (Coppermine)"; | |
664 | break; | |
665 | } | |
1da177e4 | 666 | |
4052704d YL |
667 | if (p) |
668 | strcpy(c->x86_model_id, p); | |
1da177e4 | 669 | } |
1da177e4 | 670 | |
185f3b9d YL |
671 | if (c->x86 == 15) |
672 | set_cpu_cap(c, X86_FEATURE_P4); | |
673 | if (c->x86 == 6) | |
674 | set_cpu_cap(c, X86_FEATURE_P3); | |
f4166c54 | 675 | #endif |
185f3b9d | 676 | |
185f3b9d | 677 | /* Work around errata */ |
2759c328 | 678 | srat_detect_node(c); |
e38e05a8 SY |
679 | |
680 | if (cpu_has(c, X86_FEATURE_VMX)) | |
681 | detect_vmx_virtcap(c); | |
abe48b10 | 682 | |
b51ef52d | 683 | init_intel_energy_perf(c); |
e16fd002 | 684 | |
90218ac7 | 685 | init_intel_misc_features(c); |
42ed458a | 686 | } |
1da177e4 | 687 | |
185f3b9d | 688 | #ifdef CONFIG_X86_32 |
148f9bb8 | 689 | static unsigned int intel_size_cache(struct cpuinfo_x86 *c, unsigned int size) |
1da177e4 | 690 | { |
65eb6b43 PC |
691 | /* |
692 | * Intel PIII Tualatin. This comes in two flavours. | |
1da177e4 LT |
693 | * One has 256kb of cache, the other 512. We have no way |
694 | * to determine which, so we use a boottime override | |
695 | * for the 512kb model, and assume 256 otherwise. | |
696 | */ | |
697 | if ((c->x86 == 6) && (c->x86_model == 11) && (size == 0)) | |
698 | size = 256; | |
aece118e BD |
699 | |
700 | /* | |
701 | * Intel Quark SoC X1000 contains a 4-way set associative | |
702 | * 16K cache with a 16 byte cache line and 256 lines per tag | |
703 | */ | |
704 | if ((c->x86 == 5) && (c->x86_model == 9)) | |
705 | size = 16; | |
1da177e4 LT |
706 | return size; |
707 | } | |
185f3b9d | 708 | #endif |
1da177e4 | 709 | |
e0ba94f1 AS |
710 | #define TLB_INST_4K 0x01 |
711 | #define TLB_INST_4M 0x02 | |
712 | #define TLB_INST_2M_4M 0x03 | |
713 | ||
714 | #define TLB_INST_ALL 0x05 | |
715 | #define TLB_INST_1G 0x06 | |
716 | ||
717 | #define TLB_DATA_4K 0x11 | |
718 | #define TLB_DATA_4M 0x12 | |
719 | #define TLB_DATA_2M_4M 0x13 | |
720 | #define TLB_DATA_4K_4M 0x14 | |
721 | ||
722 | #define TLB_DATA_1G 0x16 | |
723 | ||
724 | #define TLB_DATA0_4K 0x21 | |
725 | #define TLB_DATA0_4M 0x22 | |
726 | #define TLB_DATA0_2M_4M 0x23 | |
727 | ||
728 | #define STLB_4K 0x41 | |
dd360393 | 729 | #define STLB_4K_2M 0x42 |
e0ba94f1 | 730 | |
148f9bb8 | 731 | static const struct _tlb_table intel_tlb_table[] = { |
e0ba94f1 AS |
732 | { 0x01, TLB_INST_4K, 32, " TLB_INST 4 KByte pages, 4-way set associative" }, |
733 | { 0x02, TLB_INST_4M, 2, " TLB_INST 4 MByte pages, full associative" }, | |
734 | { 0x03, TLB_DATA_4K, 64, " TLB_DATA 4 KByte pages, 4-way set associative" }, | |
735 | { 0x04, TLB_DATA_4M, 8, " TLB_DATA 4 MByte pages, 4-way set associative" }, | |
736 | { 0x05, TLB_DATA_4M, 32, " TLB_DATA 4 MByte pages, 4-way set associative" }, | |
737 | { 0x0b, TLB_INST_4M, 4, " TLB_INST 4 MByte pages, 4-way set associative" }, | |
738 | { 0x4f, TLB_INST_4K, 32, " TLB_INST 4 KByte pages */" }, | |
739 | { 0x50, TLB_INST_ALL, 64, " TLB_INST 4 KByte and 2-MByte or 4-MByte pages" }, | |
740 | { 0x51, TLB_INST_ALL, 128, " TLB_INST 4 KByte and 2-MByte or 4-MByte pages" }, | |
741 | { 0x52, TLB_INST_ALL, 256, " TLB_INST 4 KByte and 2-MByte or 4-MByte pages" }, | |
742 | { 0x55, TLB_INST_2M_4M, 7, " TLB_INST 2-MByte or 4-MByte pages, fully associative" }, | |
743 | { 0x56, TLB_DATA0_4M, 16, " TLB_DATA0 4 MByte pages, 4-way set associative" }, | |
744 | { 0x57, TLB_DATA0_4K, 16, " TLB_DATA0 4 KByte pages, 4-way associative" }, | |
745 | { 0x59, TLB_DATA0_4K, 16, " TLB_DATA0 4 KByte pages, fully associative" }, | |
746 | { 0x5a, TLB_DATA0_2M_4M, 32, " TLB_DATA0 2-MByte or 4 MByte pages, 4-way set associative" }, | |
747 | { 0x5b, TLB_DATA_4K_4M, 64, " TLB_DATA 4 KByte and 4 MByte pages" }, | |
748 | { 0x5c, TLB_DATA_4K_4M, 128, " TLB_DATA 4 KByte and 4 MByte pages" }, | |
749 | { 0x5d, TLB_DATA_4K_4M, 256, " TLB_DATA 4 KByte and 4 MByte pages" }, | |
dd360393 KS |
750 | { 0x61, TLB_INST_4K, 48, " TLB_INST 4 KByte pages, full associative" }, |
751 | { 0x63, TLB_DATA_1G, 4, " TLB_DATA 1 GByte pages, 4-way set associative" }, | |
752 | { 0x76, TLB_INST_2M_4M, 8, " TLB_INST 2-MByte or 4-MByte pages, fully associative" }, | |
e0ba94f1 AS |
753 | { 0xb0, TLB_INST_4K, 128, " TLB_INST 4 KByte pages, 4-way set associative" }, |
754 | { 0xb1, TLB_INST_2M_4M, 4, " TLB_INST 2M pages, 4-way, 8 entries or 4M pages, 4-way entries" }, | |
755 | { 0xb2, TLB_INST_4K, 64, " TLB_INST 4KByte pages, 4-way set associative" }, | |
756 | { 0xb3, TLB_DATA_4K, 128, " TLB_DATA 4 KByte pages, 4-way set associative" }, | |
757 | { 0xb4, TLB_DATA_4K, 256, " TLB_DATA 4 KByte pages, 4-way associative" }, | |
a927792c YG |
758 | { 0xb5, TLB_INST_4K, 64, " TLB_INST 4 KByte pages, 8-way set associative" }, |
759 | { 0xb6, TLB_INST_4K, 128, " TLB_INST 4 KByte pages, 8-way set associative" }, | |
e0ba94f1 AS |
760 | { 0xba, TLB_DATA_4K, 64, " TLB_DATA 4 KByte pages, 4-way associative" }, |
761 | { 0xc0, TLB_DATA_4K_4M, 8, " TLB_DATA 4 KByte and 4 MByte pages, 4-way associative" }, | |
dd360393 KS |
762 | { 0xc1, STLB_4K_2M, 1024, " STLB 4 KByte and 2 MByte pages, 8-way associative" }, |
763 | { 0xc2, TLB_DATA_2M_4M, 16, " DTLB 2 MByte/4MByte pages, 4-way associative" }, | |
e0ba94f1 AS |
764 | { 0xca, STLB_4K, 512, " STLB 4 KByte pages, 4-way associative" }, |
765 | { 0x00, 0, 0 } | |
766 | }; | |
767 | ||
148f9bb8 | 768 | static void intel_tlb_lookup(const unsigned char desc) |
e0ba94f1 AS |
769 | { |
770 | unsigned char k; | |
771 | if (desc == 0) | |
772 | return; | |
773 | ||
774 | /* look up this descriptor in the table */ | |
775 | for (k = 0; intel_tlb_table[k].descriptor != desc && \ | |
776 | intel_tlb_table[k].descriptor != 0; k++) | |
777 | ; | |
778 | ||
779 | if (intel_tlb_table[k].tlb_type == 0) | |
780 | return; | |
781 | ||
782 | switch (intel_tlb_table[k].tlb_type) { | |
783 | case STLB_4K: | |
784 | if (tlb_lli_4k[ENTRIES] < intel_tlb_table[k].entries) | |
785 | tlb_lli_4k[ENTRIES] = intel_tlb_table[k].entries; | |
786 | if (tlb_lld_4k[ENTRIES] < intel_tlb_table[k].entries) | |
787 | tlb_lld_4k[ENTRIES] = intel_tlb_table[k].entries; | |
788 | break; | |
dd360393 KS |
789 | case STLB_4K_2M: |
790 | if (tlb_lli_4k[ENTRIES] < intel_tlb_table[k].entries) | |
791 | tlb_lli_4k[ENTRIES] = intel_tlb_table[k].entries; | |
792 | if (tlb_lld_4k[ENTRIES] < intel_tlb_table[k].entries) | |
793 | tlb_lld_4k[ENTRIES] = intel_tlb_table[k].entries; | |
794 | if (tlb_lli_2m[ENTRIES] < intel_tlb_table[k].entries) | |
795 | tlb_lli_2m[ENTRIES] = intel_tlb_table[k].entries; | |
796 | if (tlb_lld_2m[ENTRIES] < intel_tlb_table[k].entries) | |
797 | tlb_lld_2m[ENTRIES] = intel_tlb_table[k].entries; | |
798 | if (tlb_lli_4m[ENTRIES] < intel_tlb_table[k].entries) | |
799 | tlb_lli_4m[ENTRIES] = intel_tlb_table[k].entries; | |
800 | if (tlb_lld_4m[ENTRIES] < intel_tlb_table[k].entries) | |
801 | tlb_lld_4m[ENTRIES] = intel_tlb_table[k].entries; | |
802 | break; | |
e0ba94f1 AS |
803 | case TLB_INST_ALL: |
804 | if (tlb_lli_4k[ENTRIES] < intel_tlb_table[k].entries) | |
805 | tlb_lli_4k[ENTRIES] = intel_tlb_table[k].entries; | |
806 | if (tlb_lli_2m[ENTRIES] < intel_tlb_table[k].entries) | |
807 | tlb_lli_2m[ENTRIES] = intel_tlb_table[k].entries; | |
808 | if (tlb_lli_4m[ENTRIES] < intel_tlb_table[k].entries) | |
809 | tlb_lli_4m[ENTRIES] = intel_tlb_table[k].entries; | |
810 | break; | |
811 | case TLB_INST_4K: | |
812 | if (tlb_lli_4k[ENTRIES] < intel_tlb_table[k].entries) | |
813 | tlb_lli_4k[ENTRIES] = intel_tlb_table[k].entries; | |
814 | break; | |
815 | case TLB_INST_4M: | |
816 | if (tlb_lli_4m[ENTRIES] < intel_tlb_table[k].entries) | |
817 | tlb_lli_4m[ENTRIES] = intel_tlb_table[k].entries; | |
818 | break; | |
819 | case TLB_INST_2M_4M: | |
820 | if (tlb_lli_2m[ENTRIES] < intel_tlb_table[k].entries) | |
821 | tlb_lli_2m[ENTRIES] = intel_tlb_table[k].entries; | |
822 | if (tlb_lli_4m[ENTRIES] < intel_tlb_table[k].entries) | |
823 | tlb_lli_4m[ENTRIES] = intel_tlb_table[k].entries; | |
824 | break; | |
825 | case TLB_DATA_4K: | |
826 | case TLB_DATA0_4K: | |
827 | if (tlb_lld_4k[ENTRIES] < intel_tlb_table[k].entries) | |
828 | tlb_lld_4k[ENTRIES] = intel_tlb_table[k].entries; | |
829 | break; | |
830 | case TLB_DATA_4M: | |
831 | case TLB_DATA0_4M: | |
832 | if (tlb_lld_4m[ENTRIES] < intel_tlb_table[k].entries) | |
833 | tlb_lld_4m[ENTRIES] = intel_tlb_table[k].entries; | |
834 | break; | |
835 | case TLB_DATA_2M_4M: | |
836 | case TLB_DATA0_2M_4M: | |
837 | if (tlb_lld_2m[ENTRIES] < intel_tlb_table[k].entries) | |
838 | tlb_lld_2m[ENTRIES] = intel_tlb_table[k].entries; | |
839 | if (tlb_lld_4m[ENTRIES] < intel_tlb_table[k].entries) | |
840 | tlb_lld_4m[ENTRIES] = intel_tlb_table[k].entries; | |
841 | break; | |
842 | case TLB_DATA_4K_4M: | |
843 | if (tlb_lld_4k[ENTRIES] < intel_tlb_table[k].entries) | |
844 | tlb_lld_4k[ENTRIES] = intel_tlb_table[k].entries; | |
845 | if (tlb_lld_4m[ENTRIES] < intel_tlb_table[k].entries) | |
846 | tlb_lld_4m[ENTRIES] = intel_tlb_table[k].entries; | |
847 | break; | |
dd360393 KS |
848 | case TLB_DATA_1G: |
849 | if (tlb_lld_1g[ENTRIES] < intel_tlb_table[k].entries) | |
850 | tlb_lld_1g[ENTRIES] = intel_tlb_table[k].entries; | |
e0ba94f1 AS |
851 | break; |
852 | } | |
853 | } | |
854 | ||
148f9bb8 | 855 | static void intel_detect_tlb(struct cpuinfo_x86 *c) |
e0ba94f1 AS |
856 | { |
857 | int i, j, n; | |
858 | unsigned int regs[4]; | |
859 | unsigned char *desc = (unsigned char *)regs; | |
5b556332 BP |
860 | |
861 | if (c->cpuid_level < 2) | |
862 | return; | |
863 | ||
e0ba94f1 AS |
864 | /* Number of times to iterate */ |
865 | n = cpuid_eax(2) & 0xFF; | |
866 | ||
867 | for (i = 0 ; i < n ; i++) { | |
868 | cpuid(2, ®s[0], ®s[1], ®s[2], ®s[3]); | |
869 | ||
870 | /* If bit 31 is set, this is an unknown format */ | |
871 | for (j = 0 ; j < 3 ; j++) | |
872 | if (regs[j] & (1 << 31)) | |
873 | regs[j] = 0; | |
874 | ||
875 | /* Byte 0 is level count, not a descriptor */ | |
876 | for (j = 1 ; j < 16 ; j++) | |
877 | intel_tlb_lookup(desc[j]); | |
878 | } | |
879 | } | |
880 | ||
148f9bb8 | 881 | static const struct cpu_dev intel_cpu_dev = { |
1da177e4 | 882 | .c_vendor = "Intel", |
65eb6b43 | 883 | .c_ident = { "GenuineIntel" }, |
185f3b9d | 884 | #ifdef CONFIG_X86_32 |
09dc68d9 JB |
885 | .legacy_models = { |
886 | { .family = 4, .model_names = | |
65eb6b43 PC |
887 | { |
888 | [0] = "486 DX-25/33", | |
889 | [1] = "486 DX-50", | |
890 | [2] = "486 SX", | |
891 | [3] = "486 DX/2", | |
892 | [4] = "486 SL", | |
893 | [5] = "486 SX/2", | |
894 | [7] = "486 DX/2-WB", | |
895 | [8] = "486 DX/4", | |
1da177e4 LT |
896 | [9] = "486 DX/4-WB" |
897 | } | |
898 | }, | |
09dc68d9 | 899 | { .family = 5, .model_names = |
65eb6b43 PC |
900 | { |
901 | [0] = "Pentium 60/66 A-step", | |
902 | [1] = "Pentium 60/66", | |
1da177e4 | 903 | [2] = "Pentium 75 - 200", |
65eb6b43 | 904 | [3] = "OverDrive PODP5V83", |
1da177e4 | 905 | [4] = "Pentium MMX", |
65eb6b43 | 906 | [7] = "Mobile Pentium 75 - 200", |
aece118e BD |
907 | [8] = "Mobile Pentium MMX", |
908 | [9] = "Quark SoC X1000", | |
1da177e4 LT |
909 | } |
910 | }, | |
09dc68d9 | 911 | { .family = 6, .model_names = |
65eb6b43 | 912 | { |
1da177e4 | 913 | [0] = "Pentium Pro A-step", |
65eb6b43 PC |
914 | [1] = "Pentium Pro", |
915 | [3] = "Pentium II (Klamath)", | |
916 | [4] = "Pentium II (Deschutes)", | |
917 | [5] = "Pentium II (Deschutes)", | |
1da177e4 | 918 | [6] = "Mobile Pentium II", |
65eb6b43 PC |
919 | [7] = "Pentium III (Katmai)", |
920 | [8] = "Pentium III (Coppermine)", | |
1da177e4 LT |
921 | [10] = "Pentium III (Cascades)", |
922 | [11] = "Pentium III (Tualatin)", | |
923 | } | |
924 | }, | |
09dc68d9 | 925 | { .family = 15, .model_names = |
1da177e4 LT |
926 | { |
927 | [0] = "Pentium 4 (Unknown)", | |
928 | [1] = "Pentium 4 (Willamette)", | |
929 | [2] = "Pentium 4 (Northwood)", | |
930 | [4] = "Pentium 4 (Foster)", | |
931 | [5] = "Pentium 4 (Foster)", | |
932 | } | |
933 | }, | |
934 | }, | |
09dc68d9 | 935 | .legacy_cache_size = intel_size_cache, |
185f3b9d | 936 | #endif |
e0ba94f1 | 937 | .c_detect_tlb = intel_detect_tlb, |
03ae5768 | 938 | .c_early_init = early_init_intel, |
1da177e4 | 939 | .c_init = init_intel, |
b51ef52d | 940 | .c_bsp_resume = intel_bsp_resume, |
10a434fc | 941 | .c_x86_vendor = X86_VENDOR_INTEL, |
1da177e4 LT |
942 | }; |
943 | ||
10a434fc | 944 | cpu_dev_register(intel_cpu_dev); |
1da177e4 | 945 |