aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-x86/pgtable.h
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2008-07-18 15:13:20 -0400
committerIngo Molnar <mingo@elte.hu>2008-07-18 15:13:20 -0400
commitf6dc8ccaab6d8f63cbae1e6c73fe972b26f5376c (patch)
treec5643fcdc884a8d0bfc3f1bc28039cab7394e5bc /include/asm-x86/pgtable.h
parent323ec001c6bb98eeabb5abbdbb8c8055d9496554 (diff)
parent5b664cb235e97afbf34db9c4d77f08ebd725335e (diff)
Merge branch 'linus' into core/generic-dma-coherent
Conflicts: kernel/Makefile Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include/asm-x86/pgtable.h')
-rw-r--r--include/asm-x86/pgtable.h141
1 files changed, 77 insertions, 64 deletions
diff --git a/include/asm-x86/pgtable.h b/include/asm-x86/pgtable.h
index 97c271b2910b..49cbd76b9547 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: */
@@ -83,19 +78,9 @@
83#define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \ 78#define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
84 _PAGE_ACCESSED) 79 _PAGE_ACCESSED)
85 80
86#ifdef CONFIG_X86_32
87#define _PAGE_KERNEL_EXEC \
88 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED)
89#define _PAGE_KERNEL (_PAGE_KERNEL_EXEC | _PAGE_NX)
90
91#ifndef __ASSEMBLY__
92extern pteval_t __PAGE_KERNEL, __PAGE_KERNEL_EXEC;
93#endif /* __ASSEMBLY__ */
94#else
95#define __PAGE_KERNEL_EXEC \ 81#define __PAGE_KERNEL_EXEC \
96 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED) 82 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
97#define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX) 83#define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
98#endif
99 84
100#define __PAGE_KERNEL_RO (__PAGE_KERNEL & ~_PAGE_RW) 85#define __PAGE_KERNEL_RO (__PAGE_KERNEL & ~_PAGE_RW)
101#define __PAGE_KERNEL_RX (__PAGE_KERNEL_EXEC & ~_PAGE_RW) 86#define __PAGE_KERNEL_RX (__PAGE_KERNEL_EXEC & ~_PAGE_RW)
@@ -106,26 +91,22 @@ extern pteval_t __PAGE_KERNEL, __PAGE_KERNEL_EXEC;
106#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER) 91#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
107#define __PAGE_KERNEL_VSYSCALL_NOCACHE (__PAGE_KERNEL_VSYSCALL | _PAGE_PCD | _PAGE_PWT) 92#define __PAGE_KERNEL_VSYSCALL_NOCACHE (__PAGE_KERNEL_VSYSCALL | _PAGE_PCD | _PAGE_PWT)
108#define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE) 93#define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
94#define __PAGE_KERNEL_LARGE_NOCACHE (__PAGE_KERNEL | _PAGE_CACHE_UC | _PAGE_PSE)
109#define __PAGE_KERNEL_LARGE_EXEC (__PAGE_KERNEL_EXEC | _PAGE_PSE) 95#define __PAGE_KERNEL_LARGE_EXEC (__PAGE_KERNEL_EXEC | _PAGE_PSE)
110 96
111#ifdef CONFIG_X86_32 97#define PAGE_KERNEL __pgprot(__PAGE_KERNEL)
112# define MAKE_GLOBAL(x) __pgprot((x)) 98#define PAGE_KERNEL_RO __pgprot(__PAGE_KERNEL_RO)
113#else 99#define PAGE_KERNEL_EXEC __pgprot(__PAGE_KERNEL_EXEC)
114# define MAKE_GLOBAL(x) __pgprot((x) | _PAGE_GLOBAL) 100#define PAGE_KERNEL_RX __pgprot(__PAGE_KERNEL_RX)
115#endif 101#define PAGE_KERNEL_WC __pgprot(__PAGE_KERNEL_WC)
116 102#define PAGE_KERNEL_NOCACHE __pgprot(__PAGE_KERNEL_NOCACHE)
117#define PAGE_KERNEL MAKE_GLOBAL(__PAGE_KERNEL) 103#define PAGE_KERNEL_UC_MINUS __pgprot(__PAGE_KERNEL_UC_MINUS)
118#define PAGE_KERNEL_RO MAKE_GLOBAL(__PAGE_KERNEL_RO) 104#define PAGE_KERNEL_EXEC_NOCACHE __pgprot(__PAGE_KERNEL_EXEC_NOCACHE)
119#define PAGE_KERNEL_EXEC MAKE_GLOBAL(__PAGE_KERNEL_EXEC) 105#define PAGE_KERNEL_LARGE __pgprot(__PAGE_KERNEL_LARGE)
120#define PAGE_KERNEL_RX MAKE_GLOBAL(__PAGE_KERNEL_RX) 106#define PAGE_KERNEL_LARGE_NOCACHE __pgprot(__PAGE_KERNEL_LARGE_NOCACHE)
121#define PAGE_KERNEL_WC MAKE_GLOBAL(__PAGE_KERNEL_WC) 107#define PAGE_KERNEL_LARGE_EXEC __pgprot(__PAGE_KERNEL_LARGE_EXEC)
122#define PAGE_KERNEL_NOCACHE MAKE_GLOBAL(__PAGE_KERNEL_NOCACHE) 108#define PAGE_KERNEL_VSYSCALL __pgprot(__PAGE_KERNEL_VSYSCALL)
123#define PAGE_KERNEL_UC_MINUS MAKE_GLOBAL(__PAGE_KERNEL_UC_MINUS) 109#define PAGE_KERNEL_VSYSCALL_NOCACHE __pgprot(__PAGE_KERNEL_VSYSCALL_NOCACHE)
124#define PAGE_KERNEL_EXEC_NOCACHE MAKE_GLOBAL(__PAGE_KERNEL_EXEC_NOCACHE)
125#define PAGE_KERNEL_LARGE MAKE_GLOBAL(__PAGE_KERNEL_LARGE)
126#define PAGE_KERNEL_LARGE_EXEC MAKE_GLOBAL(__PAGE_KERNEL_LARGE_EXEC)
127#define PAGE_KERNEL_VSYSCALL MAKE_GLOBAL(__PAGE_KERNEL_VSYSCALL)
128#define PAGE_KERNEL_VSYSCALL_NOCACHE MAKE_GLOBAL(__PAGE_KERNEL_VSYSCALL_NOCACHE)
129 110
130/* xwr */ 111/* xwr */
131#define __P000 PAGE_NONE 112#define __P000 PAGE_NONE
@@ -164,37 +145,37 @@ extern struct list_head pgd_list;
164 */ 145 */
165static inline int pte_dirty(pte_t pte) 146static inline int pte_dirty(pte_t pte)
166{ 147{
167 return pte_val(pte) & _PAGE_DIRTY; 148 return pte_flags(pte) & _PAGE_DIRTY;
168} 149}
169 150
170static inline int pte_young(pte_t pte) 151static inline int pte_young(pte_t pte)
171{ 152{
172 return pte_val(pte) & _PAGE_ACCESSED; 153 return pte_flags(pte) & _PAGE_ACCESSED;
173} 154}
174 155
175static inline int pte_write(pte_t pte) 156static inline int pte_write(pte_t pte)
176{ 157{
177 return pte_val(pte) & _PAGE_RW; 158 return pte_flags(pte) & _PAGE_RW;
178} 159}
179 160
180static inline int pte_file(pte_t pte) 161static inline int pte_file(pte_t pte)
181{ 162{
182 return pte_val(pte) & _PAGE_FILE; 163 return pte_flags(pte) & _PAGE_FILE;
183} 164}
184 165
185static inline int pte_huge(pte_t pte) 166static inline int pte_huge(pte_t pte)
186{ 167{
187 return pte_val(pte) & _PAGE_PSE; 168 return pte_flags(pte) & _PAGE_PSE;
188} 169}
189 170
190static inline int pte_global(pte_t pte) 171static inline int pte_global(pte_t pte)
191{ 172{
192 return pte_val(pte) & _PAGE_GLOBAL; 173 return pte_flags(pte) & _PAGE_GLOBAL;
193} 174}
194 175
195static inline int pte_exec(pte_t pte) 176static inline int pte_exec(pte_t pte)
196{ 177{
197 return !(pte_val(pte) & _PAGE_NX); 178 return !(pte_flags(pte) & _PAGE_NX);
198} 179}
199 180
200static inline int pte_special(pte_t pte) 181static inline int pte_special(pte_t pte)
@@ -210,22 +191,22 @@ static inline int pmd_large(pmd_t pte)
210 191
211static inline pte_t pte_mkclean(pte_t pte) 192static inline pte_t pte_mkclean(pte_t pte)
212{ 193{
213 return __pte(pte_val(pte) & ~(pteval_t)_PAGE_DIRTY); 194 return __pte(pte_val(pte) & ~_PAGE_DIRTY);
214} 195}
215 196
216static inline pte_t pte_mkold(pte_t pte) 197static inline pte_t pte_mkold(pte_t pte)
217{ 198{
218 return __pte(pte_val(pte) & ~(pteval_t)_PAGE_ACCESSED); 199 return __pte(pte_val(pte) & ~_PAGE_ACCESSED);
219} 200}
220 201
221static inline pte_t pte_wrprotect(pte_t pte) 202static inline pte_t pte_wrprotect(pte_t pte)
222{ 203{
223 return __pte(pte_val(pte) & ~(pteval_t)_PAGE_RW); 204 return __pte(pte_val(pte) & ~_PAGE_RW);
224} 205}
225 206
226static inline pte_t pte_mkexec(pte_t pte) 207static inline pte_t pte_mkexec(pte_t pte)
227{ 208{
228 return __pte(pte_val(pte) & ~(pteval_t)_PAGE_NX); 209 return __pte(pte_val(pte) & ~_PAGE_NX);
229} 210}
230 211
231static inline pte_t pte_mkdirty(pte_t pte) 212static inline pte_t pte_mkdirty(pte_t pte)
@@ -250,7 +231,7 @@ static inline pte_t pte_mkhuge(pte_t pte)
250 231
251static inline pte_t pte_clrhuge(pte_t pte) 232static inline pte_t pte_clrhuge(pte_t pte)
252{ 233{
253 return __pte(pte_val(pte) & ~(pteval_t)_PAGE_PSE); 234 return __pte(pte_val(pte) & ~_PAGE_PSE);
254} 235}
255 236
256static inline pte_t pte_mkglobal(pte_t pte) 237static inline pte_t pte_mkglobal(pte_t pte)
@@ -260,7 +241,7 @@ static inline pte_t pte_mkglobal(pte_t pte)
260 241
261static inline pte_t pte_clrglobal(pte_t pte) 242static inline pte_t pte_clrglobal(pte_t pte)
262{ 243{
263 return __pte(pte_val(pte) & ~(pteval_t)_PAGE_GLOBAL); 244 return __pte(pte_val(pte) & ~_PAGE_GLOBAL);
264} 245}
265 246
266static inline pte_t pte_mkspecial(pte_t pte) 247static inline pte_t pte_mkspecial(pte_t pte)
@@ -305,7 +286,7 @@ static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
305 return __pgprot(preservebits | addbits); 286 return __pgprot(preservebits | addbits);
306} 287}
307 288
308#define pte_pgprot(x) __pgprot(pte_val(x) & ~PTE_MASK) 289#define pte_pgprot(x) __pgprot(pte_flags(x) & ~PTE_MASK)
309 290
310#define canon_pgprot(p) __pgprot(pgprot_val(p) & __supported_pte_mask) 291#define canon_pgprot(p) __pgprot(pgprot_val(p) & __supported_pte_mask)
311 292
@@ -318,6 +299,9 @@ int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn,
318 unsigned long size, pgprot_t *vma_prot); 299 unsigned long size, pgprot_t *vma_prot);
319#endif 300#endif
320 301
302/* Install a pte for a particular vaddr in kernel space. */
303void set_pte_vaddr(unsigned long vaddr, pte_t pte);
304
321#ifdef CONFIG_PARAVIRT 305#ifdef CONFIG_PARAVIRT
322#include <asm/paravirt.h> 306#include <asm/paravirt.h>
323#else /* !CONFIG_PARAVIRT */ 307#else /* !CONFIG_PARAVIRT */
@@ -359,6 +343,26 @@ int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn,
359# include "pgtable_64.h" 343# include "pgtable_64.h"
360#endif 344#endif
361 345
346/*
347 * the pgd page can be thought of an array like this: pgd_t[PTRS_PER_PGD]
348 *
349 * this macro returns the index of the entry in the pgd page which would
350 * control the given virtual address
351 */
352#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1))
353
354/*
355 * pgd_offset() returns a (pgd_t *)
356 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
357 */
358#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
359/*
360 * a shortcut which implies the use of the kernel's pgd, instead
361 * of a process's
362 */
363#define pgd_offset_k(address) pgd_offset(&init_mm, (address))
364
365
362#define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET) 366#define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
363#define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY) 367#define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
364 368
@@ -369,8 +373,15 @@ enum {
369 PG_LEVEL_4K, 373 PG_LEVEL_4K,
370 PG_LEVEL_2M, 374 PG_LEVEL_2M,
371 PG_LEVEL_1G, 375 PG_LEVEL_1G,
376 PG_LEVEL_NUM
372}; 377};
373 378
379#ifdef CONFIG_PROC_FS
380extern void update_page_count(int level, unsigned long pages);
381#else
382static inline void update_page_count(int level, unsigned long pages) { }
383#endif
384
374/* 385/*
375 * Helper function that returns the kernel pagetable entry controlling 386 * Helper function that returns the kernel pagetable entry controlling
376 * the virtual address 'address'. NULL means no pagetable entry present. 387 * the virtual address 'address'. NULL means no pagetable entry present.
@@ -420,6 +431,8 @@ static inline void native_set_pte_at(struct mm_struct *mm, unsigned long addr,
420 * race with other CPU's that might be updating the dirty 431 * race with other CPU's that might be updating the dirty
421 * bit at the same time. 432 * bit at the same time.
422 */ 433 */
434struct vm_area_struct;
435
423#define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS 436#define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS
424extern int ptep_set_access_flags(struct vm_area_struct *vma, 437extern int ptep_set_access_flags(struct vm_area_struct *vma,
425 unsigned long address, pte_t *ptep, 438 unsigned long address, pte_t *ptep,