diff options
Diffstat (limited to 'include/asm-x86/pgtable.h')
-rw-r--r-- | include/asm-x86/pgtable.h | 73 |
1 files changed, 38 insertions, 35 deletions
diff --git a/include/asm-x86/pgtable.h b/include/asm-x86/pgtable.h index 55c3a0e3a8ce..bcb5446a08d1 100644 --- a/include/asm-x86/pgtable.h +++ b/include/asm-x86/pgtable.h | |||
@@ -20,30 +20,25 @@ | |||
20 | #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */ | 20 | #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */ |
21 | #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */ | 21 | #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */ |
22 | 22 | ||
23 | /* | 23 | #define _PAGE_PRESENT (_AT(pteval_t, 1) << _PAGE_BIT_PRESENT) |
24 | * Note: we use _AC(1, L) instead of _AC(1, UL) so that we get a | 24 | #define _PAGE_RW (_AT(pteval_t, 1) << _PAGE_BIT_RW) |
25 | * sign-extended value on 32-bit with all 1's in the upper word, | 25 | #define _PAGE_USER (_AT(pteval_t, 1) << _PAGE_BIT_USER) |
26 | * which preserves the upper pte values on 64-bit ptes: | 26 | #define _PAGE_PWT (_AT(pteval_t, 1) << _PAGE_BIT_PWT) |
27 | */ | 27 | #define _PAGE_PCD (_AT(pteval_t, 1) << _PAGE_BIT_PCD) |
28 | #define _PAGE_PRESENT (_AC(1, L)<<_PAGE_BIT_PRESENT) | 28 | #define _PAGE_ACCESSED (_AT(pteval_t, 1) << _PAGE_BIT_ACCESSED) |
29 | #define _PAGE_RW (_AC(1, L)<<_PAGE_BIT_RW) | 29 | #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY) |
30 | #define _PAGE_USER (_AC(1, L)<<_PAGE_BIT_USER) | 30 | #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE) |
31 | #define _PAGE_PWT (_AC(1, L)<<_PAGE_BIT_PWT) | 31 | #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL) |
32 | #define _PAGE_PCD (_AC(1, L)<<_PAGE_BIT_PCD) | 32 | #define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1) |
33 | #define _PAGE_ACCESSED (_AC(1, L)<<_PAGE_BIT_ACCESSED) | 33 | #define _PAGE_UNUSED2 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED2) |
34 | #define _PAGE_DIRTY (_AC(1, L)<<_PAGE_BIT_DIRTY) | 34 | #define _PAGE_UNUSED3 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED3) |
35 | #define _PAGE_PSE (_AC(1, L)<<_PAGE_BIT_PSE) /* 2MB page */ | 35 | #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT) |
36 | #define _PAGE_GLOBAL (_AC(1, L)<<_PAGE_BIT_GLOBAL) /* Global TLB entry */ | 36 | #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE) |
37 | #define _PAGE_UNUSED1 (_AC(1, L)<<_PAGE_BIT_UNUSED1) | ||
38 | #define _PAGE_UNUSED2 (_AC(1, L)<<_PAGE_BIT_UNUSED2) | ||
39 | #define _PAGE_UNUSED3 (_AC(1, L)<<_PAGE_BIT_UNUSED3) | ||
40 | #define _PAGE_PAT (_AC(1, L)<<_PAGE_BIT_PAT) | ||
41 | #define _PAGE_PAT_LARGE (_AC(1, L)<<_PAGE_BIT_PAT_LARGE) | ||
42 | 37 | ||
43 | #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE) | 38 | #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE) |
44 | #define _PAGE_NX (_AC(1, ULL) << _PAGE_BIT_NX) | 39 | #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX) |
45 | #else | 40 | #else |
46 | #define _PAGE_NX 0 | 41 | #define _PAGE_NX (_AT(pteval_t, 0)) |
47 | #endif | 42 | #endif |
48 | 43 | ||
49 | /* If _PAGE_PRESENT is clear, we use these: */ | 44 | /* If _PAGE_PRESENT is clear, we use these: */ |
@@ -57,6 +52,7 @@ | |||
57 | #define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | \ | 52 | #define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | \ |
58 | _PAGE_DIRTY) | 53 | _PAGE_DIRTY) |
59 | 54 | ||
55 | /* Set of bits not changed in pte_modify */ | ||
60 | #define _PAGE_CHG_MASK (PTE_MASK | _PAGE_PCD | _PAGE_PWT | \ | 56 | #define _PAGE_CHG_MASK (PTE_MASK | _PAGE_PCD | _PAGE_PWT | \ |
61 | _PAGE_ACCESSED | _PAGE_DIRTY) | 57 | _PAGE_ACCESSED | _PAGE_DIRTY) |
62 | 58 | ||
@@ -163,37 +159,37 @@ extern struct list_head pgd_list; | |||
163 | */ | 159 | */ |
164 | static inline int pte_dirty(pte_t pte) | 160 | static inline int pte_dirty(pte_t pte) |
165 | { | 161 | { |
166 | return pte_val(pte) & _PAGE_DIRTY; | 162 | return pte_flags(pte) & _PAGE_DIRTY; |
167 | } | 163 | } |
168 | 164 | ||
169 | static inline int pte_young(pte_t pte) | 165 | static inline int pte_young(pte_t pte) |
170 | { | 166 | { |
171 | return pte_val(pte) & _PAGE_ACCESSED; | 167 | return pte_flags(pte) & _PAGE_ACCESSED; |
172 | } | 168 | } |
173 | 169 | ||
174 | static inline int pte_write(pte_t pte) | 170 | static inline int pte_write(pte_t pte) |
175 | { | 171 | { |
176 | return pte_val(pte) & _PAGE_RW; | 172 | return pte_flags(pte) & _PAGE_RW; |
177 | } | 173 | } |
178 | 174 | ||
179 | static inline int pte_file(pte_t pte) | 175 | static inline int pte_file(pte_t pte) |
180 | { | 176 | { |
181 | return pte_val(pte) & _PAGE_FILE; | 177 | return pte_flags(pte) & _PAGE_FILE; |
182 | } | 178 | } |
183 | 179 | ||
184 | static inline int pte_huge(pte_t pte) | 180 | static inline int pte_huge(pte_t pte) |
185 | { | 181 | { |
186 | return pte_val(pte) & _PAGE_PSE; | 182 | return pte_flags(pte) & _PAGE_PSE; |
187 | } | 183 | } |
188 | 184 | ||
189 | static inline int pte_global(pte_t pte) | 185 | static inline int pte_global(pte_t pte) |
190 | { | 186 | { |
191 | return pte_val(pte) & _PAGE_GLOBAL; | 187 | return pte_flags(pte) & _PAGE_GLOBAL; |
192 | } | 188 | } |
193 | 189 | ||
194 | static inline int pte_exec(pte_t pte) | 190 | static inline int pte_exec(pte_t pte) |
195 | { | 191 | { |
196 | return !(pte_val(pte) & _PAGE_NX); | 192 | return !(pte_flags(pte) & _PAGE_NX); |
197 | } | 193 | } |
198 | 194 | ||
199 | static inline int pte_special(pte_t pte) | 195 | static inline int pte_special(pte_t pte) |
@@ -209,22 +205,22 @@ static inline int pmd_large(pmd_t pte) | |||
209 | 205 | ||
210 | static inline pte_t pte_mkclean(pte_t pte) | 206 | static inline pte_t pte_mkclean(pte_t pte) |
211 | { | 207 | { |
212 | return __pte(pte_val(pte) & ~(pteval_t)_PAGE_DIRTY); | 208 | return __pte(pte_val(pte) & ~_PAGE_DIRTY); |
213 | } | 209 | } |
214 | 210 | ||
215 | static inline pte_t pte_mkold(pte_t pte) | 211 | static inline pte_t pte_mkold(pte_t pte) |
216 | { | 212 | { |
217 | return __pte(pte_val(pte) & ~(pteval_t)_PAGE_ACCESSED); | 213 | return __pte(pte_val(pte) & ~_PAGE_ACCESSED); |
218 | } | 214 | } |
219 | 215 | ||
220 | static inline pte_t pte_wrprotect(pte_t pte) | 216 | static inline pte_t pte_wrprotect(pte_t pte) |
221 | { | 217 | { |
222 | return __pte(pte_val(pte) & ~(pteval_t)_PAGE_RW); | 218 | return __pte(pte_val(pte) & ~_PAGE_RW); |
223 | } | 219 | } |
224 | 220 | ||
225 | static inline pte_t pte_mkexec(pte_t pte) | 221 | static inline pte_t pte_mkexec(pte_t pte) |
226 | { | 222 | { |
227 | return __pte(pte_val(pte) & ~(pteval_t)_PAGE_NX); | 223 | return __pte(pte_val(pte) & ~_PAGE_NX); |
228 | } | 224 | } |
229 | 225 | ||
230 | static inline pte_t pte_mkdirty(pte_t pte) | 226 | static inline pte_t pte_mkdirty(pte_t pte) |
@@ -249,7 +245,7 @@ static inline pte_t pte_mkhuge(pte_t pte) | |||
249 | 245 | ||
250 | static inline pte_t pte_clrhuge(pte_t pte) | 246 | static inline pte_t pte_clrhuge(pte_t pte) |
251 | { | 247 | { |
252 | return __pte(pte_val(pte) & ~(pteval_t)_PAGE_PSE); | 248 | return __pte(pte_val(pte) & ~_PAGE_PSE); |
253 | } | 249 | } |
254 | 250 | ||
255 | static inline pte_t pte_mkglobal(pte_t pte) | 251 | static inline pte_t pte_mkglobal(pte_t pte) |
@@ -259,7 +255,7 @@ static inline pte_t pte_mkglobal(pte_t pte) | |||
259 | 255 | ||
260 | static inline pte_t pte_clrglobal(pte_t pte) | 256 | static inline pte_t pte_clrglobal(pte_t pte) |
261 | { | 257 | { |
262 | return __pte(pte_val(pte) & ~(pteval_t)_PAGE_GLOBAL); | 258 | return __pte(pte_val(pte) & ~_PAGE_GLOBAL); |
263 | } | 259 | } |
264 | 260 | ||
265 | static inline pte_t pte_mkspecial(pte_t pte) | 261 | static inline pte_t pte_mkspecial(pte_t pte) |
@@ -304,7 +300,7 @@ static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot) | |||
304 | return __pgprot(preservebits | addbits); | 300 | return __pgprot(preservebits | addbits); |
305 | } | 301 | } |
306 | 302 | ||
307 | #define pte_pgprot(x) __pgprot(pte_val(x) & (0xfff | _PAGE_NX)) | 303 | #define pte_pgprot(x) __pgprot(pte_flags(x) & ~PTE_MASK) |
308 | 304 | ||
309 | #define canon_pgprot(p) __pgprot(pgprot_val(p) & __supported_pte_mask) | 305 | #define canon_pgprot(p) __pgprot(pgprot_val(p) & __supported_pte_mask) |
310 | 306 | ||
@@ -368,8 +364,15 @@ enum { | |||
368 | PG_LEVEL_4K, | 364 | PG_LEVEL_4K, |
369 | PG_LEVEL_2M, | 365 | PG_LEVEL_2M, |
370 | PG_LEVEL_1G, | 366 | PG_LEVEL_1G, |
367 | PG_LEVEL_NUM | ||
371 | }; | 368 | }; |
372 | 369 | ||
370 | #ifdef CONFIG_PROC_FS | ||
371 | extern void update_page_count(int level, unsigned long pages); | ||
372 | #else | ||
373 | static inline void update_page_count(int level, unsigned long pages) { } | ||
374 | #endif | ||
375 | |||
373 | /* | 376 | /* |
374 | * Helper function that returns the kernel pagetable entry controlling | 377 | * Helper function that returns the kernel pagetable entry controlling |
375 | * the virtual address 'address'. NULL means no pagetable entry present. | 378 | * the virtual address 'address'. NULL means no pagetable entry present. |