1 #include <linux/kernel.h>
3 #include <linux/string.h>
4 #include <linux/bitops.h>
6 #include <linux/sched.h>
7 #include <linux/thread_info.h>
8 #include <linux/init.h>
9 #include <linux/uaccess.h>
11 #include <asm/cpufeature.h>
12 #include <asm/pgtable.h>
16 #include <asm/intel-family.h>
19 #include <linux/topology.h>
24 #ifdef CONFIG_X86_LOCAL_APIC
25 #include <asm/mpspec.h>
30 * Just in case our CPU detection goes bad, or you have a weird system,
31 * allow a way to override the automatic disabling of MPX.
35 static int __init
forcempx_setup(char *__unused
)
41 __setup("intel-skd-046-workaround=disable", forcempx_setup
);
43 void check_mpx_erratum(struct cpuinfo_x86
*c
)
48 * Turn off the MPX feature on CPUs where SMEP is not
49 * available or disabled.
51 * Works around Intel Erratum SKD046: "Branch Instructions
52 * May Initialize MPX Bound Registers Incorrectly".
54 * This might falsely disable MPX on systems without
55 * SMEP, like Atom processors without SMEP. But there
56 * is no such hardware known at the moment.
58 if (cpu_has(c
, X86_FEATURE_MPX
) && !cpu_has(c
, X86_FEATURE_SMEP
)) {
59 setup_clear_cpu_cap(X86_FEATURE_MPX
);
60 pr_warn("x86/mpx: Disabling MPX since SMEP not present\n");
64 static void early_init_intel(struct cpuinfo_x86
*c
)
68 /* Unmask CPUID levels if masked: */
69 if (c
->x86
> 6 || (c
->x86
== 6 && c
->x86_model
>= 0xd)) {
70 if (msr_clear_bit(MSR_IA32_MISC_ENABLE
,
71 MSR_IA32_MISC_ENABLE_LIMIT_CPUID_BIT
) > 0) {
72 c
->cpuid_level
= cpuid_eax(0);
77 if ((c
->x86
== 0xf && c
->x86_model
>= 0x03) ||
78 (c
->x86
== 0x6 && c
->x86_model
>= 0x0e))
79 set_cpu_cap(c
, X86_FEATURE_CONSTANT_TSC
);
81 if (c
->x86
>= 6 && !cpu_has(c
, X86_FEATURE_IA64
)) {
84 wrmsr(MSR_IA32_UCODE_REV
, 0, 0);
85 /* Required by the SDM */
87 rdmsr(MSR_IA32_UCODE_REV
, lower_word
, c
->microcode
);
91 * Atom erratum AAE44/AAF40/AAG38/AAH41:
93 * A race condition between speculative fetches and invalidating
94 * a large page. This is worked around in microcode, but we
95 * need the microcode to have already been loaded... so if it is
96 * not, recommend a BIOS update and disable large pages.
98 if (c
->x86
== 6 && c
->x86_model
== 0x1c && c
->x86_mask
<= 2 &&
99 c
->microcode
< 0x20e) {
100 pr_warn("Atom PSE erratum detected, BIOS microcode update recommended\n");
101 clear_cpu_cap(c
, X86_FEATURE_PSE
);
105 set_cpu_cap(c
, X86_FEATURE_SYSENTER32
);
107 /* Netburst reports 64 bytes clflush size, but does IO in 128 bytes */
108 if (c
->x86
== 15 && c
->x86_cache_alignment
== 64)
109 c
->x86_cache_alignment
= 128;
112 /* CPUID workaround for 0F33/0F34 CPU */
113 if (c
->x86
== 0xF && c
->x86_model
== 0x3
114 && (c
->x86_mask
== 0x3 || c
->x86_mask
== 0x4))
115 c
->x86_phys_bits
= 36;
118 * c->x86_power is 8000_0007 edx. Bit 8 is TSC runs at constant rate
119 * with P/T states and does not stop in deep C-states.
121 * It is also reliable across cores and sockets. (but not across
122 * cabinets - we turn it off in that case explicitly.)
124 if (c
->x86_power
& (1 << 8)) {
125 set_cpu_cap(c
, X86_FEATURE_CONSTANT_TSC
);
126 set_cpu_cap(c
, X86_FEATURE_NONSTOP_TSC
);
127 if (!check_tsc_unstable())
128 set_sched_clock_stable();
131 /* Penwell and Cloverview have the TSC which doesn't sleep on S3 */
133 switch (c
->x86_model
) {
134 case 0x27: /* Penwell */
135 case 0x35: /* Cloverview */
136 case 0x4a: /* Merrifield */
137 set_cpu_cap(c
, X86_FEATURE_NONSTOP_TSC_S3
);
145 * There is a known erratum on Pentium III and Core Solo
147 * " Page with PAT set to WC while associated MTRR is UC
148 * may consolidate to UC "
149 * Because of this erratum, it is better to stick with
150 * setting WC in MTRR rather than using PAT on these CPUs.
152 * Enable PAT WC only on P4, Core 2 or later CPUs.
154 if (c
->x86
== 6 && c
->x86_model
< 15)
155 clear_cpu_cap(c
, X86_FEATURE_PAT
);
157 #ifdef CONFIG_KMEMCHECK
159 * P4s have a "fast strings" feature which causes single-
160 * stepping REP instructions to only generate a #DB on
161 * cache-line boundaries.
163 * Ingo Molnar reported a Pentium D (model 6) and a Xeon
164 * (model 2) with the same problem.
167 if (msr_clear_bit(MSR_IA32_MISC_ENABLE
,
168 MSR_IA32_MISC_ENABLE_FAST_STRING_BIT
) > 0)
169 pr_info("kmemcheck: Disabling fast string operations\n");
173 * If fast string is not enabled in IA32_MISC_ENABLE for any reason,
174 * clear the fast string and enhanced fast string CPU capabilities.
176 if (c
->x86
> 6 || (c
->x86
== 6 && c
->x86_model
>= 0xd)) {
177 rdmsrl(MSR_IA32_MISC_ENABLE
, misc_enable
);
178 if (!(misc_enable
& MSR_IA32_MISC_ENABLE_FAST_STRING
)) {
179 pr_info("Disabled fast string operations\n");
180 setup_clear_cpu_cap(X86_FEATURE_REP_GOOD
);
181 setup_clear_cpu_cap(X86_FEATURE_ERMS
);
186 * Intel Quark Core DevMan_001.pdf section 6.4.11
187 * "The operating system also is required to invalidate (i.e., flush)
188 * the TLB when any changes are made to any of the page table entries.
189 * The operating system must reload CR3 to cause the TLB to be flushed"
191 * As a result, boot_cpu_has(X86_FEATURE_PGE) in arch/x86/include/asm/tlbflush.h
192 * should be false so that __flush_tlb_all() causes CR3 insted of CR4.PGE
195 if (c
->x86
== 5 && c
->x86_model
== 9) {
196 pr_info("Disabling PGE capability bit\n");
197 setup_clear_cpu_cap(X86_FEATURE_PGE
);
200 if (c
->cpuid_level
>= 0x00000001) {
201 u32 eax
, ebx
, ecx
, edx
;
203 cpuid(0x00000001, &eax
, &ebx
, &ecx
, &edx
);
205 * If HTT (EDX[28]) is set EBX[16:23] contain the number of
206 * apicids which are reserved per package. Store the resulting
207 * shift value for the package management code.
209 if (edx
& (1U << 28))
210 c
->x86_coreid_bits
= get_count_order((ebx
>> 16) & 0xff);
213 check_mpx_erratum(c
);
218 * Early probe support logic for ppro memory erratum #50
220 * This is called before we do cpu ident work
223 int ppro_with_ram_bug(void)
225 /* Uses data from early_cpu_detect now */
226 if (boot_cpu_data
.x86_vendor
== X86_VENDOR_INTEL
&&
227 boot_cpu_data
.x86
== 6 &&
228 boot_cpu_data
.x86_model
== 1 &&
229 boot_cpu_data
.x86_mask
< 8) {
230 pr_info("Pentium Pro with Errata#50 detected. Taking evasive action.\n");
236 static void intel_smp_check(struct cpuinfo_x86
*c
)
238 /* calling is from identify_secondary_cpu() ? */
243 * Mask B, Pentium, but not Pentium MMX
246 c
->x86_mask
>= 1 && c
->x86_mask
<= 4 &&
249 * Remember we have B step Pentia with bugs
251 WARN_ONCE(1, "WARNING: SMP operation may be unreliable"
252 "with B stepping processors.\n");
257 static int __init
forcepae_setup(char *__unused
)
262 __setup("forcepae", forcepae_setup
);
264 static void intel_workarounds(struct cpuinfo_x86
*c
)
266 #ifdef CONFIG_X86_F00F_BUG
268 * All models of Pentium and Pentium with MMX technology CPUs
269 * have the F0 0F bug, which lets nonprivileged users lock up the
270 * system. Announce that the fault handler will be checking for it.
271 * The Quark is also family 5, but does not have the same bug.
273 clear_cpu_bug(c
, X86_BUG_F00F
);
274 if (c
->x86
== 5 && c
->x86_model
< 9) {
275 static int f00f_workaround_enabled
;
277 set_cpu_bug(c
, X86_BUG_F00F
);
278 if (!f00f_workaround_enabled
) {
279 pr_notice("Intel Pentium with F0 0F bug - workaround enabled.\n");
280 f00f_workaround_enabled
= 1;
286 * SEP CPUID bug: Pentium Pro reports SEP but doesn't have it until
289 if ((c
->x86
<<8 | c
->x86_model
<<4 | c
->x86_mask
) < 0x633)
290 clear_cpu_cap(c
, X86_FEATURE_SEP
);
293 * PAE CPUID issue: many Pentium M report no PAE but may have a
294 * functionally usable PAE implementation.
295 * Forcefully enable PAE if kernel parameter "forcepae" is present.
298 pr_warn("PAE forced!\n");
299 set_cpu_cap(c
, X86_FEATURE_PAE
);
300 add_taint(TAINT_CPU_OUT_OF_SPEC
, LOCKDEP_NOW_UNRELIABLE
);
304 * P4 Xeon erratum 037 workaround.
305 * Hardware prefetcher may cause stale data to be loaded into the cache.
307 if ((c
->x86
== 15) && (c
->x86_model
== 1) && (c
->x86_mask
== 1)) {
308 if (msr_set_bit(MSR_IA32_MISC_ENABLE
,
309 MSR_IA32_MISC_ENABLE_PREFETCH_DISABLE_BIT
) > 0) {
310 pr_info("CPU: C0 stepping P4 Xeon detected.\n");
311 pr_info("CPU: Disabling hardware prefetching (Erratum 037)\n");
316 * See if we have a good local APIC by checking for buggy Pentia,
317 * i.e. all B steppings and the C2 stepping of P54C when using their
318 * integrated APIC (see 11AP erratum in "Pentium Processor
319 * Specification Update").
321 if (boot_cpu_has(X86_FEATURE_APIC
) && (c
->x86
<<8 | c
->x86_model
<<4) == 0x520 &&
322 (c
->x86_mask
< 0x6 || c
->x86_mask
== 0xb))
323 set_cpu_bug(c
, X86_BUG_11AP
);
326 #ifdef CONFIG_X86_INTEL_USERCOPY
328 * Set up the preferred alignment for movsl bulk memory moves
331 case 4: /* 486: untested */
333 case 5: /* Old Pentia: untested */
335 case 6: /* PII/PIII only like movsl with 8-byte alignment */
338 case 15: /* P4 is OK down to 8-byte alignment */
347 static void intel_workarounds(struct cpuinfo_x86
*c
)
352 static void srat_detect_node(struct cpuinfo_x86
*c
)
356 int cpu
= smp_processor_id();
358 /* Don't do the funky fallback heuristics the AMD version employs
360 node
= numa_cpu_node(cpu
);
361 if (node
== NUMA_NO_NODE
|| !node_online(node
)) {
362 /* reuse the value from init_cpu_to_node() */
363 node
= cpu_to_node(cpu
);
365 numa_set_node(cpu
, node
);
370 * find out the number of processor cores on the die
372 static int intel_num_cpu_cores(struct cpuinfo_x86
*c
)
374 unsigned int eax
, ebx
, ecx
, edx
;
376 if (!IS_ENABLED(CONFIG_SMP
) || c
->cpuid_level
< 4)
379 /* Intel has a non-standard dependency on %ecx for this CPUID level. */
380 cpuid_count(4, 0, &eax
, &ebx
, &ecx
, &edx
);
382 return (eax
>> 26) + 1;
387 static void detect_vmx_virtcap(struct cpuinfo_x86
*c
)
389 /* Intel VMX MSR indicated features */
390 #define X86_VMX_FEATURE_PROC_CTLS_TPR_SHADOW 0x00200000
391 #define X86_VMX_FEATURE_PROC_CTLS_VNMI 0x00400000
392 #define X86_VMX_FEATURE_PROC_CTLS_2ND_CTLS 0x80000000
393 #define X86_VMX_FEATURE_PROC_CTLS2_VIRT_APIC 0x00000001
394 #define X86_VMX_FEATURE_PROC_CTLS2_EPT 0x00000002
395 #define X86_VMX_FEATURE_PROC_CTLS2_VPID 0x00000020
397 u32 vmx_msr_low
, vmx_msr_high
, msr_ctl
, msr_ctl2
;
399 clear_cpu_cap(c
, X86_FEATURE_TPR_SHADOW
);
400 clear_cpu_cap(c
, X86_FEATURE_VNMI
);
401 clear_cpu_cap(c
, X86_FEATURE_FLEXPRIORITY
);
402 clear_cpu_cap(c
, X86_FEATURE_EPT
);
403 clear_cpu_cap(c
, X86_FEATURE_VPID
);
405 rdmsr(MSR_IA32_VMX_PROCBASED_CTLS
, vmx_msr_low
, vmx_msr_high
);
406 msr_ctl
= vmx_msr_high
| vmx_msr_low
;
407 if (msr_ctl
& X86_VMX_FEATURE_PROC_CTLS_TPR_SHADOW
)
408 set_cpu_cap(c
, X86_FEATURE_TPR_SHADOW
);
409 if (msr_ctl
& X86_VMX_FEATURE_PROC_CTLS_VNMI
)
410 set_cpu_cap(c
, X86_FEATURE_VNMI
);
411 if (msr_ctl
& X86_VMX_FEATURE_PROC_CTLS_2ND_CTLS
) {
412 rdmsr(MSR_IA32_VMX_PROCBASED_CTLS2
,
413 vmx_msr_low
, vmx_msr_high
);
414 msr_ctl2
= vmx_msr_high
| vmx_msr_low
;
415 if ((msr_ctl2
& X86_VMX_FEATURE_PROC_CTLS2_VIRT_APIC
) &&
416 (msr_ctl
& X86_VMX_FEATURE_PROC_CTLS_TPR_SHADOW
))
417 set_cpu_cap(c
, X86_FEATURE_FLEXPRIORITY
);
418 if (msr_ctl2
& X86_VMX_FEATURE_PROC_CTLS2_EPT
)
419 set_cpu_cap(c
, X86_FEATURE_EPT
);
420 if (msr_ctl2
& X86_VMX_FEATURE_PROC_CTLS2_VPID
)
421 set_cpu_cap(c
, X86_FEATURE_VPID
);
425 static void init_intel_energy_perf(struct cpuinfo_x86
*c
)
430 * Initialize MSR_IA32_ENERGY_PERF_BIAS if not already initialized.
431 * (x86_energy_perf_policy(8) is available to change it at run-time.)
433 if (!cpu_has(c
, X86_FEATURE_EPB
))
436 rdmsrl(MSR_IA32_ENERGY_PERF_BIAS
, epb
);
437 if ((epb
& 0xF) != ENERGY_PERF_BIAS_PERFORMANCE
)
440 pr_warn_once("ENERGY_PERF_BIAS: Set to 'normal', was 'performance'\n");
441 pr_warn_once("ENERGY_PERF_BIAS: View and update with x86_energy_perf_policy(8)\n");
442 epb
= (epb
& ~0xF) | ENERGY_PERF_BIAS_NORMAL
;
443 wrmsrl(MSR_IA32_ENERGY_PERF_BIAS
, epb
);
446 static void intel_bsp_resume(struct cpuinfo_x86
*c
)
449 * MSR_IA32_ENERGY_PERF_BIAS is lost across suspend/resume,
450 * so reinitialize it properly like during bootup:
452 init_intel_energy_perf(c
);
455 static void init_intel(struct cpuinfo_x86
*c
)
461 intel_workarounds(c
);
464 * Detect the extended topology information if available. This
465 * will reinitialise the initial_apicid which will be used
466 * in init_intel_cacheinfo()
468 detect_extended_topology(c
);
470 if (!cpu_has(c
, X86_FEATURE_XTOPOLOGY
)) {
472 * let's use the legacy cpuid vector 0x1 and 0x4 for topology
475 c
->x86_max_cores
= intel_num_cpu_cores(c
);
481 l2
= init_intel_cacheinfo(c
);
483 /* Detect legacy cache sizes if init_intel_cacheinfo did not */
485 cpu_detect_cache_sizes(c
);
486 l2
= c
->x86_cache_size
;
489 if (c
->cpuid_level
> 9) {
490 unsigned eax
= cpuid_eax(10);
491 /* Check for version and the number of counters */
492 if ((eax
& 0xff) && (((eax
>>8) & 0xff) > 1))
493 set_cpu_cap(c
, X86_FEATURE_ARCH_PERFMON
);
496 if (cpu_has(c
, X86_FEATURE_XMM2
))
497 set_cpu_cap(c
, X86_FEATURE_LFENCE_RDTSC
);
499 if (boot_cpu_has(X86_FEATURE_DS
)) {
501 rdmsr(MSR_IA32_MISC_ENABLE
, l1
, l2
);
503 set_cpu_cap(c
, X86_FEATURE_BTS
);
505 set_cpu_cap(c
, X86_FEATURE_PEBS
);
508 if (c
->x86
== 6 && boot_cpu_has(X86_FEATURE_CLFLUSH
) &&
509 (c
->x86_model
== 29 || c
->x86_model
== 46 || c
->x86_model
== 47))
510 set_cpu_bug(c
, X86_BUG_CLFLUSH_MONITOR
);
512 if (c
->x86
== 6 && boot_cpu_has(X86_FEATURE_MWAIT
) &&
513 ((c
->x86_model
== INTEL_FAM6_ATOM_GOLDMONT
)))
514 set_cpu_bug(c
, X86_BUG_MONITOR
);
518 c
->x86_cache_alignment
= c
->x86_clflush_size
* 2;
520 set_cpu_cap(c
, X86_FEATURE_REP_GOOD
);
523 * Names for the Pentium II/Celeron processors
524 * detectable only by also checking the cache size.
525 * Dixon is NOT a Celeron.
530 switch (c
->x86_model
) {
533 p
= "Celeron (Covington)";
535 p
= "Mobile Pentium II (Dixon)";
540 p
= "Celeron (Mendocino)";
541 else if (c
->x86_mask
== 0 || c
->x86_mask
== 5)
547 p
= "Celeron (Coppermine)";
552 strcpy(c
->x86_model_id
, p
);
556 set_cpu_cap(c
, X86_FEATURE_P4
);
558 set_cpu_cap(c
, X86_FEATURE_P3
);
561 /* Work around errata */
564 if (cpu_has(c
, X86_FEATURE_VMX
))
565 detect_vmx_virtcap(c
);
567 init_intel_energy_perf(c
);
571 static unsigned int intel_size_cache(struct cpuinfo_x86
*c
, unsigned int size
)
574 * Intel PIII Tualatin. This comes in two flavours.
575 * One has 256kb of cache, the other 512. We have no way
576 * to determine which, so we use a boottime override
577 * for the 512kb model, and assume 256 otherwise.
579 if ((c
->x86
== 6) && (c
->x86_model
== 11) && (size
== 0))
583 * Intel Quark SoC X1000 contains a 4-way set associative
584 * 16K cache with a 16 byte cache line and 256 lines per tag
586 if ((c
->x86
== 5) && (c
->x86_model
== 9))
592 #define TLB_INST_4K 0x01
593 #define TLB_INST_4M 0x02
594 #define TLB_INST_2M_4M 0x03
596 #define TLB_INST_ALL 0x05
597 #define TLB_INST_1G 0x06
599 #define TLB_DATA_4K 0x11
600 #define TLB_DATA_4M 0x12
601 #define TLB_DATA_2M_4M 0x13
602 #define TLB_DATA_4K_4M 0x14
604 #define TLB_DATA_1G 0x16
606 #define TLB_DATA0_4K 0x21
607 #define TLB_DATA0_4M 0x22
608 #define TLB_DATA0_2M_4M 0x23
611 #define STLB_4K_2M 0x42
613 static const struct _tlb_table intel_tlb_table
[] = {
614 { 0x01, TLB_INST_4K
, 32, " TLB_INST 4 KByte pages, 4-way set associative" },
615 { 0x02, TLB_INST_4M
, 2, " TLB_INST 4 MByte pages, full associative" },
616 { 0x03, TLB_DATA_4K
, 64, " TLB_DATA 4 KByte pages, 4-way set associative" },
617 { 0x04, TLB_DATA_4M
, 8, " TLB_DATA 4 MByte pages, 4-way set associative" },
618 { 0x05, TLB_DATA_4M
, 32, " TLB_DATA 4 MByte pages, 4-way set associative" },
619 { 0x0b, TLB_INST_4M
, 4, " TLB_INST 4 MByte pages, 4-way set associative" },
620 { 0x4f, TLB_INST_4K
, 32, " TLB_INST 4 KByte pages */" },
621 { 0x50, TLB_INST_ALL
, 64, " TLB_INST 4 KByte and 2-MByte or 4-MByte pages" },
622 { 0x51, TLB_INST_ALL
, 128, " TLB_INST 4 KByte and 2-MByte or 4-MByte pages" },
623 { 0x52, TLB_INST_ALL
, 256, " TLB_INST 4 KByte and 2-MByte or 4-MByte pages" },
624 { 0x55, TLB_INST_2M_4M
, 7, " TLB_INST 2-MByte or 4-MByte pages, fully associative" },
625 { 0x56, TLB_DATA0_4M
, 16, " TLB_DATA0 4 MByte pages, 4-way set associative" },
626 { 0x57, TLB_DATA0_4K
, 16, " TLB_DATA0 4 KByte pages, 4-way associative" },
627 { 0x59, TLB_DATA0_4K
, 16, " TLB_DATA0 4 KByte pages, fully associative" },
628 { 0x5a, TLB_DATA0_2M_4M
, 32, " TLB_DATA0 2-MByte or 4 MByte pages, 4-way set associative" },
629 { 0x5b, TLB_DATA_4K_4M
, 64, " TLB_DATA 4 KByte and 4 MByte pages" },
630 { 0x5c, TLB_DATA_4K_4M
, 128, " TLB_DATA 4 KByte and 4 MByte pages" },
631 { 0x5d, TLB_DATA_4K_4M
, 256, " TLB_DATA 4 KByte and 4 MByte pages" },
632 { 0x61, TLB_INST_4K
, 48, " TLB_INST 4 KByte pages, full associative" },
633 { 0x63, TLB_DATA_1G
, 4, " TLB_DATA 1 GByte pages, 4-way set associative" },
634 { 0x76, TLB_INST_2M_4M
, 8, " TLB_INST 2-MByte or 4-MByte pages, fully associative" },
635 { 0xb0, TLB_INST_4K
, 128, " TLB_INST 4 KByte pages, 4-way set associative" },
636 { 0xb1, TLB_INST_2M_4M
, 4, " TLB_INST 2M pages, 4-way, 8 entries or 4M pages, 4-way entries" },
637 { 0xb2, TLB_INST_4K
, 64, " TLB_INST 4KByte pages, 4-way set associative" },
638 { 0xb3, TLB_DATA_4K
, 128, " TLB_DATA 4 KByte pages, 4-way set associative" },
639 { 0xb4, TLB_DATA_4K
, 256, " TLB_DATA 4 KByte pages, 4-way associative" },
640 { 0xb5, TLB_INST_4K
, 64, " TLB_INST 4 KByte pages, 8-way set associative" },
641 { 0xb6, TLB_INST_4K
, 128, " TLB_INST 4 KByte pages, 8-way set associative" },
642 { 0xba, TLB_DATA_4K
, 64, " TLB_DATA 4 KByte pages, 4-way associative" },
643 { 0xc0, TLB_DATA_4K_4M
, 8, " TLB_DATA 4 KByte and 4 MByte pages, 4-way associative" },
644 { 0xc1, STLB_4K_2M
, 1024, " STLB 4 KByte and 2 MByte pages, 8-way associative" },
645 { 0xc2, TLB_DATA_2M_4M
, 16, " DTLB 2 MByte/4MByte pages, 4-way associative" },
646 { 0xca, STLB_4K
, 512, " STLB 4 KByte pages, 4-way associative" },
650 static void intel_tlb_lookup(const unsigned char desc
)
656 /* look up this descriptor in the table */
657 for (k
= 0; intel_tlb_table
[k
].descriptor
!= desc
&& \
658 intel_tlb_table
[k
].descriptor
!= 0; k
++)
661 if (intel_tlb_table
[k
].tlb_type
== 0)
664 switch (intel_tlb_table
[k
].tlb_type
) {
666 if (tlb_lli_4k
[ENTRIES
] < intel_tlb_table
[k
].entries
)
667 tlb_lli_4k
[ENTRIES
] = intel_tlb_table
[k
].entries
;
668 if (tlb_lld_4k
[ENTRIES
] < intel_tlb_table
[k
].entries
)
669 tlb_lld_4k
[ENTRIES
] = intel_tlb_table
[k
].entries
;
672 if (tlb_lli_4k
[ENTRIES
] < intel_tlb_table
[k
].entries
)
673 tlb_lli_4k
[ENTRIES
] = intel_tlb_table
[k
].entries
;
674 if (tlb_lld_4k
[ENTRIES
] < intel_tlb_table
[k
].entries
)
675 tlb_lld_4k
[ENTRIES
] = intel_tlb_table
[k
].entries
;
676 if (tlb_lli_2m
[ENTRIES
] < intel_tlb_table
[k
].entries
)
677 tlb_lli_2m
[ENTRIES
] = intel_tlb_table
[k
].entries
;
678 if (tlb_lld_2m
[ENTRIES
] < intel_tlb_table
[k
].entries
)
679 tlb_lld_2m
[ENTRIES
] = intel_tlb_table
[k
].entries
;
680 if (tlb_lli_4m
[ENTRIES
] < intel_tlb_table
[k
].entries
)
681 tlb_lli_4m
[ENTRIES
] = intel_tlb_table
[k
].entries
;
682 if (tlb_lld_4m
[ENTRIES
] < intel_tlb_table
[k
].entries
)
683 tlb_lld_4m
[ENTRIES
] = intel_tlb_table
[k
].entries
;
686 if (tlb_lli_4k
[ENTRIES
] < intel_tlb_table
[k
].entries
)
687 tlb_lli_4k
[ENTRIES
] = intel_tlb_table
[k
].entries
;
688 if (tlb_lli_2m
[ENTRIES
] < intel_tlb_table
[k
].entries
)
689 tlb_lli_2m
[ENTRIES
] = intel_tlb_table
[k
].entries
;
690 if (tlb_lli_4m
[ENTRIES
] < intel_tlb_table
[k
].entries
)
691 tlb_lli_4m
[ENTRIES
] = intel_tlb_table
[k
].entries
;
694 if (tlb_lli_4k
[ENTRIES
] < intel_tlb_table
[k
].entries
)
695 tlb_lli_4k
[ENTRIES
] = intel_tlb_table
[k
].entries
;
698 if (tlb_lli_4m
[ENTRIES
] < intel_tlb_table
[k
].entries
)
699 tlb_lli_4m
[ENTRIES
] = intel_tlb_table
[k
].entries
;
702 if (tlb_lli_2m
[ENTRIES
] < intel_tlb_table
[k
].entries
)
703 tlb_lli_2m
[ENTRIES
] = intel_tlb_table
[k
].entries
;
704 if (tlb_lli_4m
[ENTRIES
] < intel_tlb_table
[k
].entries
)
705 tlb_lli_4m
[ENTRIES
] = intel_tlb_table
[k
].entries
;
709 if (tlb_lld_4k
[ENTRIES
] < intel_tlb_table
[k
].entries
)
710 tlb_lld_4k
[ENTRIES
] = intel_tlb_table
[k
].entries
;
714 if (tlb_lld_4m
[ENTRIES
] < intel_tlb_table
[k
].entries
)
715 tlb_lld_4m
[ENTRIES
] = intel_tlb_table
[k
].entries
;
718 case TLB_DATA0_2M_4M
:
719 if (tlb_lld_2m
[ENTRIES
] < intel_tlb_table
[k
].entries
)
720 tlb_lld_2m
[ENTRIES
] = intel_tlb_table
[k
].entries
;
721 if (tlb_lld_4m
[ENTRIES
] < intel_tlb_table
[k
].entries
)
722 tlb_lld_4m
[ENTRIES
] = intel_tlb_table
[k
].entries
;
725 if (tlb_lld_4k
[ENTRIES
] < intel_tlb_table
[k
].entries
)
726 tlb_lld_4k
[ENTRIES
] = intel_tlb_table
[k
].entries
;
727 if (tlb_lld_4m
[ENTRIES
] < intel_tlb_table
[k
].entries
)
728 tlb_lld_4m
[ENTRIES
] = intel_tlb_table
[k
].entries
;
731 if (tlb_lld_1g
[ENTRIES
] < intel_tlb_table
[k
].entries
)
732 tlb_lld_1g
[ENTRIES
] = intel_tlb_table
[k
].entries
;
737 static void intel_detect_tlb(struct cpuinfo_x86
*c
)
740 unsigned int regs
[4];
741 unsigned char *desc
= (unsigned char *)regs
;
743 if (c
->cpuid_level
< 2)
746 /* Number of times to iterate */
747 n
= cpuid_eax(2) & 0xFF;
749 for (i
= 0 ; i
< n
; i
++) {
750 cpuid(2, ®s
[0], ®s
[1], ®s
[2], ®s
[3]);
752 /* If bit 31 is set, this is an unknown format */
753 for (j
= 0 ; j
< 3 ; j
++)
754 if (regs
[j
] & (1 << 31))
757 /* Byte 0 is level count, not a descriptor */
758 for (j
= 1 ; j
< 16 ; j
++)
759 intel_tlb_lookup(desc
[j
]);
763 static const struct cpu_dev intel_cpu_dev
= {
765 .c_ident
= { "GenuineIntel" },
768 { .family
= 4, .model_names
=
770 [0] = "486 DX-25/33",
781 { .family
= 5, .model_names
=
783 [0] = "Pentium 60/66 A-step",
784 [1] = "Pentium 60/66",
785 [2] = "Pentium 75 - 200",
786 [3] = "OverDrive PODP5V83",
788 [7] = "Mobile Pentium 75 - 200",
789 [8] = "Mobile Pentium MMX",
790 [9] = "Quark SoC X1000",
793 { .family
= 6, .model_names
=
795 [0] = "Pentium Pro A-step",
797 [3] = "Pentium II (Klamath)",
798 [4] = "Pentium II (Deschutes)",
799 [5] = "Pentium II (Deschutes)",
800 [6] = "Mobile Pentium II",
801 [7] = "Pentium III (Katmai)",
802 [8] = "Pentium III (Coppermine)",
803 [10] = "Pentium III (Cascades)",
804 [11] = "Pentium III (Tualatin)",
807 { .family
= 15, .model_names
=
809 [0] = "Pentium 4 (Unknown)",
810 [1] = "Pentium 4 (Willamette)",
811 [2] = "Pentium 4 (Northwood)",
812 [4] = "Pentium 4 (Foster)",
813 [5] = "Pentium 4 (Foster)",
817 .legacy_cache_size
= intel_size_cache
,
819 .c_detect_tlb
= intel_detect_tlb
,
820 .c_early_init
= early_init_intel
,
821 .c_init
= init_intel
,
822 .c_bsp_resume
= intel_bsp_resume
,
823 .c_x86_vendor
= X86_VENDOR_INTEL
,
826 cpu_dev_register(intel_cpu_dev
);