1
2
3
4#ifndef _ASM_X86_CPUFEATURE_H
5#define _ASM_X86_CPUFEATURE_H
6
7#include <asm/required-features.h>
8
9#define NCAPINTS 8
10
11
12#define X86_FEATURE_FPU (0*32+ 0)
13#define X86_FEATURE_VME (0*32+ 1)
14#define X86_FEATURE_DE (0*32+ 2)
15#define X86_FEATURE_PSE (0*32+ 3)
16#define X86_FEATURE_TSC (0*32+ 4)
17#define X86_FEATURE_MSR (0*32+ 5)
18#define X86_FEATURE_PAE (0*32+ 6)
19#define X86_FEATURE_MCE (0*32+ 7)
20#define X86_FEATURE_CX8 (0*32+ 8)
21#define X86_FEATURE_APIC (0*32+ 9)
22#define X86_FEATURE_SEP (0*32+11)
23#define X86_FEATURE_MTRR (0*32+12)
24#define X86_FEATURE_PGE (0*32+13)
25#define X86_FEATURE_MCA (0*32+14)
26#define X86_FEATURE_CMOV (0*32+15)
27#define X86_FEATURE_PAT (0*32+16)
28#define X86_FEATURE_PSE36 (0*32+17)
29#define X86_FEATURE_PN (0*32+18)
30#define X86_FEATURE_CLFLSH (0*32+19)
31#define X86_FEATURE_DS (0*32+21)
32#define X86_FEATURE_ACPI (0*32+22)
33#define X86_FEATURE_MMX (0*32+23)
34#define X86_FEATURE_FXSR (0*32+24)
35
36#define X86_FEATURE_XMM (0*32+25)
37#define X86_FEATURE_XMM2 (0*32+26)
38#define X86_FEATURE_SELFSNOOP (0*32+27)
39#define X86_FEATURE_HT (0*32+28)
40#define X86_FEATURE_ACC (0*32+29)
41#define X86_FEATURE_IA64 (0*32+30)
42
43
44
45#define X86_FEATURE_SYSCALL (1*32+11)
46#define X86_FEATURE_MP (1*32+19)
47#define X86_FEATURE_NX (1*32+20)
48#define X86_FEATURE_MMXEXT (1*32+22)
49#define X86_FEATURE_GBPAGES (1*32+26)
50#define X86_FEATURE_RDTSCP (1*32+27)
51#define X86_FEATURE_LM (1*32+29)
52#define X86_FEATURE_3DNOWEXT (1*32+30)
53#define X86_FEATURE_3DNOW (1*32+31)
54
55
56#define X86_FEATURE_RECOVERY (2*32+ 0)
57#define X86_FEATURE_LONGRUN (2*32+ 1)
58#define X86_FEATURE_LRTI (2*32+ 3)
59
60
61
62#define X86_FEATURE_CXMMX (3*32+ 0)
63#define X86_FEATURE_K6_MTRR (3*32+ 1)
64#define X86_FEATURE_CYRIX_ARR (3*32+ 2)
65#define X86_FEATURE_CENTAUR_MCR (3*32+ 3)
66
67#define X86_FEATURE_K8 (3*32+ 4)
68#define X86_FEATURE_K7 (3*32+ 5)
69#define X86_FEATURE_P3 (3*32+ 6)
70#define X86_FEATURE_P4 (3*32+ 7)
71#define X86_FEATURE_CONSTANT_TSC (3*32+ 8)
72#define X86_FEATURE_UP (3*32+ 9)
73#define X86_FEATURE_FXSAVE_LEAK (3*32+10)
74#define X86_FEATURE_ARCH_PERFMON (3*32+11)
75#define X86_FEATURE_PEBS (3*32+12)
76#define X86_FEATURE_BTS (3*32+13)
77
78
79#define X86_FEATURE_REP_GOOD (3*32+16)
80#define X86_FEATURE_MFENCE_RDTSC (3*32+17)
81#define X86_FEATURE_LFENCE_RDTSC (3*32+18)
82
83
84#define X86_FEATURE_XMM3 (4*32+ 0)
85#define X86_FEATURE_MWAIT (4*32+ 3)
86#define X86_FEATURE_DSCPL (4*32+ 4)
87#define X86_FEATURE_EST (4*32+ 7)
88#define X86_FEATURE_TM2 (4*32+ 8)
89#define X86_FEATURE_CID (4*32+10)
90#define X86_FEATURE_CX16 (4*32+13)
91#define X86_FEATURE_XTPR (4*32+14)
92#define X86_FEATURE_DCA (4*32+18)
93
94
95#define X86_FEATURE_XSTORE (5*32+ 2)
96#define X86_FEATURE_XSTORE_EN (5*32+ 3)
97#define X86_FEATURE_XCRYPT (5*32+ 6)
98#define X86_FEATURE_XCRYPT_EN (5*32+ 7)
99#define X86_FEATURE_ACE2 (5*32+ 8)
100#define X86_FEATURE_ACE2_EN (5*32+ 9)
101#define X86_FEATURE_PHE (5*32+ 10)
102#define X86_FEATURE_PHE_EN (5*32+ 11)
103#define X86_FEATURE_PMM (5*32+ 12)
104#define X86_FEATURE_PMM_EN (5*32+ 13)
105
106
107#define X86_FEATURE_LAHF_LM (6*32+ 0)
108#define X86_FEATURE_CMP_LEGACY (6*32+ 1)
109
110
111
112
113
114#define X86_FEATURE_IDA (7*32+ 0)
115
116#if defined(__KERNEL__) && !defined(__ASSEMBLY__)
117
118#include <linux/bitops.h>
119
120extern const char * const x86_cap_flags[NCAPINTS*32];
121extern const char * const x86_power_flags[32];
122
123#define cpu_has(c, bit) \
124 (__builtin_constant_p(bit) && \
125 ( (((bit)>>5)==0 && (1UL<<((bit)&31) & REQUIRED_MASK0)) || \
126 (((bit)>>5)==1 && (1UL<<((bit)&31) & REQUIRED_MASK1)) || \
127 (((bit)>>5)==2 && (1UL<<((bit)&31) & REQUIRED_MASK2)) || \
128 (((bit)>>5)==3 && (1UL<<((bit)&31) & REQUIRED_MASK3)) || \
129 (((bit)>>5)==4 && (1UL<<((bit)&31) & REQUIRED_MASK4)) || \
130 (((bit)>>5)==5 && (1UL<<((bit)&31) & REQUIRED_MASK5)) || \
131 (((bit)>>5)==6 && (1UL<<((bit)&31) & REQUIRED_MASK6)) || \
132 (((bit)>>5)==7 && (1UL<<((bit)&31) & REQUIRED_MASK7)) ) \
133 ? 1 : \
134 test_bit(bit, (unsigned long *)((c)->x86_capability)))
135#define boot_cpu_has(bit) cpu_has(&boot_cpu_data, bit)
136
137#define set_cpu_cap(c, bit) set_bit(bit, (unsigned long *)((c)->x86_capability))
138#define clear_cpu_cap(c, bit) clear_bit(bit, (unsigned long *)((c)->x86_capability))
139#define setup_clear_cpu_cap(bit) do { \
140 clear_cpu_cap(&boot_cpu_data, bit); \
141 set_bit(bit, cleared_cpu_caps); \
142} while (0)
143#define setup_force_cpu_cap(bit) do { \
144 set_cpu_cap(&boot_cpu_data, bit); \
145 clear_bit(bit, cleared_cpu_caps); \
146} while (0)
147
148#define cpu_has_fpu boot_cpu_has(X86_FEATURE_FPU)
149#define cpu_has_vme boot_cpu_has(X86_FEATURE_VME)
150#define cpu_has_de boot_cpu_has(X86_FEATURE_DE)
151#define cpu_has_pse boot_cpu_has(X86_FEATURE_PSE)
152#define cpu_has_tsc boot_cpu_has(X86_FEATURE_TSC)
153#define cpu_has_pae boot_cpu_has(X86_FEATURE_PAE)
154#define cpu_has_pge boot_cpu_has(X86_FEATURE_PGE)
155#define cpu_has_apic boot_cpu_has(X86_FEATURE_APIC)
156#define cpu_has_sep boot_cpu_has(X86_FEATURE_SEP)
157#define cpu_has_mtrr boot_cpu_has(X86_FEATURE_MTRR)
158#define cpu_has_mmx boot_cpu_has(X86_FEATURE_MMX)
159#define cpu_has_fxsr boot_cpu_has(X86_FEATURE_FXSR)
160#define cpu_has_xmm boot_cpu_has(X86_FEATURE_XMM)
161#define cpu_has_xmm2 boot_cpu_has(X86_FEATURE_XMM2)
162#define cpu_has_xmm3 boot_cpu_has(X86_FEATURE_XMM3)
163#define cpu_has_ht boot_cpu_has(X86_FEATURE_HT)
164#define cpu_has_mp boot_cpu_has(X86_FEATURE_MP)
165#define cpu_has_nx boot_cpu_has(X86_FEATURE_NX)
166#define cpu_has_k6_mtrr boot_cpu_has(X86_FEATURE_K6_MTRR)
167#define cpu_has_cyrix_arr boot_cpu_has(X86_FEATURE_CYRIX_ARR)
168#define cpu_has_centaur_mcr boot_cpu_has(X86_FEATURE_CENTAUR_MCR)
169#define cpu_has_xstore boot_cpu_has(X86_FEATURE_XSTORE)
170#define cpu_has_xstore_enabled boot_cpu_has(X86_FEATURE_XSTORE_EN)
171#define cpu_has_xcrypt boot_cpu_has(X86_FEATURE_XCRYPT)
172#define cpu_has_xcrypt_enabled boot_cpu_has(X86_FEATURE_XCRYPT_EN)
173#define cpu_has_ace2 boot_cpu_has(X86_FEATURE_ACE2)
174#define cpu_has_ace2_enabled boot_cpu_has(X86_FEATURE_ACE2_EN)
175#define cpu_has_phe boot_cpu_has(X86_FEATURE_PHE)
176#define cpu_has_phe_enabled boot_cpu_has(X86_FEATURE_PHE_EN)
177#define cpu_has_pmm boot_cpu_has(X86_FEATURE_PMM)
178#define cpu_has_pmm_enabled boot_cpu_has(X86_FEATURE_PMM_EN)
179#define cpu_has_ds boot_cpu_has(X86_FEATURE_DS)
180#define cpu_has_pebs boot_cpu_has(X86_FEATURE_PEBS)
181#define cpu_has_clflush boot_cpu_has(X86_FEATURE_CLFLSH)
182#define cpu_has_bts boot_cpu_has(X86_FEATURE_BTS)
183#define cpu_has_gbpages boot_cpu_has(X86_FEATURE_GBPAGES)
184
185#if defined(CONFIG_X86_INVLPG) || defined(CONFIG_X86_64)
186# define cpu_has_invlpg 1
187#else
188# define cpu_has_invlpg (boot_cpu_data.x86 > 3)
189#endif
190
191#ifdef CONFIG_X86_64
192
193#undef cpu_has_vme
194#define cpu_has_vme 0
195
196#undef cpu_has_pae
197#define cpu_has_pae ___BUG___
198
199#undef cpu_has_mp
200#define cpu_has_mp 1
201
202#undef cpu_has_k6_mtrr
203#define cpu_has_k6_mtrr 0
204
205#undef cpu_has_cyrix_arr
206#define cpu_has_cyrix_arr 0
207
208#undef cpu_has_centaur_mcr
209#define cpu_has_centaur_mcr 0
210
211#endif
212
213#endif
214
215#endif
216