Merge branch 'for_linus' of git://git.infradead.org/~dedekind/ubifs-2.6
[linux-2.6] / arch / x86 / kernel / cpu / addon_cpuid_features.c
1 /*
2  *      Routines to indentify additional cpu features that are scattered in
3  *      cpuid space.
4  */
5 #include <linux/cpu.h>
6
7 #include <asm/pat.h>
8 #include <asm/processor.h>
9
10 struct cpuid_bit {
11         u16 feature;
12         u8 reg;
13         u8 bit;
14         u32 level;
15 };
16
17 enum cpuid_regs {
18         CR_EAX = 0,
19         CR_ECX,
20         CR_EDX,
21         CR_EBX
22 };
23
24 void __cpuinit init_scattered_cpuid_features(struct cpuinfo_x86 *c)
25 {
26         u32 max_level;
27         u32 regs[4];
28         const struct cpuid_bit *cb;
29
30         static const struct cpuid_bit cpuid_bits[] = {
31                 { X86_FEATURE_IDA, CR_EAX, 1, 0x00000006 },
32                 { 0, 0, 0, 0 }
33         };
34
35         for (cb = cpuid_bits; cb->feature; cb++) {
36
37                 /* Verify that the level is valid */
38                 max_level = cpuid_eax(cb->level & 0xffff0000);
39                 if (max_level < cb->level ||
40                     max_level > (cb->level | 0xffff))
41                         continue;
42
43                 cpuid(cb->level, &regs[CR_EAX], &regs[CR_EBX],
44                         &regs[CR_ECX], &regs[CR_EDX]);
45
46                 if (regs[cb->reg] & (1 << cb->bit))
47                         set_cpu_cap(c, cb->feature);
48         }
49 }
50
51 #ifdef CONFIG_X86_PAT
52 void __cpuinit validate_pat_support(struct cpuinfo_x86 *c)
53 {
54         if (!cpu_has_pat)
55                 pat_disable("PAT not supported by CPU.");
56
57         switch (c->x86_vendor) {
58         case X86_VENDOR_INTEL:
59                 if (c->x86 == 0xF || (c->x86 == 6 && c->x86_model >= 15))
60                         return;
61                 break;
62         case X86_VENDOR_AMD:
63         case X86_VENDOR_CENTAUR:
64         case X86_VENDOR_TRANSMETA:
65                 return;
66         }
67
68         pat_disable("PAT disabled. Not yet verified on this CPU type.");
69 }
70 #endif