2 * Routines to indentify additional cpu features that are scattered in
8 #include <asm/processor.h>
10 #include <mach_apic.h>
26 void __cpuinit init_scattered_cpuid_features(struct cpuinfo_x86 *c)
30 const struct cpuid_bit *cb;
32 static const struct cpuid_bit cpuid_bits[] = {
33 { X86_FEATURE_IDA, CR_EAX, 1, 0x00000006 },
37 for (cb = cpuid_bits; cb->feature; cb++) {
39 /* Verify that the level is valid */
40 max_level = cpuid_eax(cb->level & 0xffff0000);
41 if (max_level < cb->level ||
42 max_level > (cb->level | 0xffff))
45 cpuid(cb->level, ®s[CR_EAX], ®s[CR_EBX],
46 ®s[CR_ECX], ®s[CR_EDX]);
48 if (regs[cb->reg] & (1 << cb->bit))
49 set_cpu_cap(c, cb->feature);
53 /* leaf 0xb SMT level */
56 /* leaf 0xb sub-leaf types */
57 #define INVALID_TYPE 0
61 #define LEAFB_SUBTYPE(ecx) (((ecx) >> 8) & 0xff)
62 #define BITS_SHIFT_NEXT_LEVEL(eax) ((eax) & 0x1f)
63 #define LEVEL_MAX_SIBLINGS(ebx) ((ebx) & 0xffff)
66 * Check for extended topology enumeration cpuid leaf 0xb and if it
67 * exists, use it for populating initial_apicid and cpu topology
70 void __cpuinit detect_extended_topology(struct cpuinfo_x86 *c)
73 unsigned int eax, ebx, ecx, edx, sub_index;
74 unsigned int ht_mask_width, core_plus_mask_width;
75 unsigned int core_select_mask, core_level_siblings;
77 if (c->cpuid_level < 0xb)
80 cpuid_count(0xb, SMT_LEVEL, &eax, &ebx, &ecx, &edx);
83 * check if the cpuid leaf 0xb is actually implemented.
85 if (ebx == 0 || (LEAFB_SUBTYPE(ecx) != SMT_TYPE))
88 set_cpu_cap(c, X86_FEATURE_XTOPOLOGY);
91 * initial apic id, which also represents 32-bit extended x2apic id.
93 c->initial_apicid = edx;
96 * Populate HT related information from sub-leaf level 0.
98 core_level_siblings = smp_num_siblings = LEVEL_MAX_SIBLINGS(ebx);
99 core_plus_mask_width = ht_mask_width = BITS_SHIFT_NEXT_LEVEL(eax);
103 cpuid_count(0xb, sub_index, &eax, &ebx, &ecx, &edx);
106 * Check for the Core type in the implemented sub leaves.
108 if (LEAFB_SUBTYPE(ecx) == CORE_TYPE) {
109 core_level_siblings = LEVEL_MAX_SIBLINGS(ebx);
110 core_plus_mask_width = BITS_SHIFT_NEXT_LEVEL(eax);
115 } while (LEAFB_SUBTYPE(ecx) != INVALID_TYPE);
117 core_select_mask = (~(-1 << core_plus_mask_width)) >> ht_mask_width;
120 c->cpu_core_id = phys_pkg_id(c->initial_apicid, ht_mask_width)
122 c->phys_proc_id = phys_pkg_id(c->initial_apicid, core_plus_mask_width);
124 c->cpu_core_id = phys_pkg_id(ht_mask_width) & core_select_mask;
125 c->phys_proc_id = phys_pkg_id(core_plus_mask_width);
127 c->x86_max_cores = (core_level_siblings / smp_num_siblings);
130 printk(KERN_INFO "CPU: Physical Processor ID: %d\n",
132 if (c->x86_max_cores > 1)
133 printk(KERN_INFO "CPU: Processor Core ID: %d\n",
139 #ifdef CONFIG_X86_PAT
140 void __cpuinit validate_pat_support(struct cpuinfo_x86 *c)
143 pat_disable("PAT not supported by CPU.");
145 switch (c->x86_vendor) {
146 case X86_VENDOR_INTEL:
148 * There is a known erratum on Pentium III and Core Solo
150 * " Page with PAT set to WC while associated MTRR is UC
151 * may consolidate to UC "
152 * Because of this erratum, it is better to stick with
153 * setting WC in MTRR rather than using PAT on these CPUs.
155 * Enable PAT WC only on P4, Core 2 or later CPUs.
157 if (c->x86 > 0x6 || (c->x86 == 6 && c->x86_model >= 15))
160 pat_disable("PAT WC disabled due to known CPU erratum.");
164 case X86_VENDOR_CENTAUR:
165 case X86_VENDOR_TRANSMETA:
169 pat_disable("PAT disabled. Not yet verified on this CPU type.");