]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/x86/include/asm/pgtable_64.h
x86: unify pmd_bad
[linux-2.6-omap-h63xx.git] / arch / x86 / include / asm / pgtable_64.h
1 #ifndef _ASM_X86_PGTABLE_64_H
2 #define _ASM_X86_PGTABLE_64_H
3
4 #include <linux/const.h>
5 #ifndef __ASSEMBLY__
6
7 /*
8  * This file contains the functions and defines necessary to modify and use
9  * the x86-64 page table tree.
10  */
11 #include <asm/processor.h>
12 #include <linux/bitops.h>
13 #include <linux/threads.h>
14 #include <asm/pda.h>
15
16 extern pud_t level3_kernel_pgt[512];
17 extern pud_t level3_ident_pgt[512];
18 extern pmd_t level2_kernel_pgt[512];
19 extern pmd_t level2_fixmap_pgt[512];
20 extern pmd_t level2_ident_pgt[512];
21 extern pgd_t init_level4_pgt[];
22
23 #define swapper_pg_dir init_level4_pgt
24
25 extern void paging_init(void);
26
27 #endif /* !__ASSEMBLY__ */
28
29 #define SHARED_KERNEL_PMD       0
30
31 /*
32  * PGDIR_SHIFT determines what a top-level page table entry can map
33  */
34 #define PGDIR_SHIFT     39
35 #define PTRS_PER_PGD    512
36
37 /*
38  * 3rd level page
39  */
40 #define PUD_SHIFT       30
41 #define PTRS_PER_PUD    512
42
43 /*
44  * PMD_SHIFT determines the size of the area a middle-level
45  * page table can map
46  */
47 #define PMD_SHIFT       21
48 #define PTRS_PER_PMD    512
49
50 /*
51  * entries per page directory level
52  */
53 #define PTRS_PER_PTE    512
54
55 #ifndef __ASSEMBLY__
56
57 #define pte_ERROR(e)                                    \
58         printk("%s:%d: bad pte %p(%016lx).\n",          \
59                __FILE__, __LINE__, &(e), pte_val(e))
60 #define pmd_ERROR(e)                                    \
61         printk("%s:%d: bad pmd %p(%016lx).\n",          \
62                __FILE__, __LINE__, &(e), pmd_val(e))
63 #define pud_ERROR(e)                                    \
64         printk("%s:%d: bad pud %p(%016lx).\n",          \
65                __FILE__, __LINE__, &(e), pud_val(e))
66 #define pgd_ERROR(e)                                    \
67         printk("%s:%d: bad pgd %p(%016lx).\n",          \
68                __FILE__, __LINE__, &(e), pgd_val(e))
69
70 #define pgd_none(x)     (!pgd_val(x))
71 #define pud_none(x)     (!pud_val(x))
72
73 struct mm_struct;
74
75 void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte);
76
77
78 static inline void native_pte_clear(struct mm_struct *mm, unsigned long addr,
79                                     pte_t *ptep)
80 {
81         *ptep = native_make_pte(0);
82 }
83
84 static inline void native_set_pte(pte_t *ptep, pte_t pte)
85 {
86         *ptep = pte;
87 }
88
89 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
90 {
91         native_set_pte(ptep, pte);
92 }
93
94 static inline pte_t native_ptep_get_and_clear(pte_t *xp)
95 {
96 #ifdef CONFIG_SMP
97         return native_make_pte(xchg(&xp->pte, 0));
98 #else
99         /* native_local_ptep_get_and_clear,
100            but duplicated because of cyclic dependency */
101         pte_t ret = *xp;
102         native_pte_clear(NULL, 0, xp);
103         return ret;
104 #endif
105 }
106
107 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
108 {
109         *pmdp = pmd;
110 }
111
112 static inline void native_pmd_clear(pmd_t *pmd)
113 {
114         native_set_pmd(pmd, native_make_pmd(0));
115 }
116
117 static inline void native_set_pud(pud_t *pudp, pud_t pud)
118 {
119         *pudp = pud;
120 }
121
122 static inline void native_pud_clear(pud_t *pud)
123 {
124         native_set_pud(pud, native_make_pud(0));
125 }
126
127 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
128 {
129         *pgdp = pgd;
130 }
131
132 static inline void native_pgd_clear(pgd_t *pgd)
133 {
134         native_set_pgd(pgd, native_make_pgd(0));
135 }
136
137 #endif /* !__ASSEMBLY__ */
138
139 #define PMD_SIZE        (_AC(1, UL) << PMD_SHIFT)
140 #define PMD_MASK        (~(PMD_SIZE - 1))
141 #define PUD_SIZE        (_AC(1, UL) << PUD_SHIFT)
142 #define PUD_MASK        (~(PUD_SIZE - 1))
143 #define PGDIR_SIZE      (_AC(1, UL) << PGDIR_SHIFT)
144 #define PGDIR_MASK      (~(PGDIR_SIZE - 1))
145
146
147 #define MAXMEM           _AC(__AC(1, UL) << MAX_PHYSMEM_BITS, UL)
148 #define VMALLOC_START    _AC(0xffffc20000000000, UL)
149 #define VMALLOC_END      _AC(0xffffe1ffffffffff, UL)
150 #define VMEMMAP_START    _AC(0xffffe20000000000, UL)
151 #define MODULES_VADDR    _AC(0xffffffffa0000000, UL)
152 #define MODULES_END      _AC(0xffffffffff000000, UL)
153 #define MODULES_LEN   (MODULES_END - MODULES_VADDR)
154
155 #ifndef __ASSEMBLY__
156
157 #define pages_to_mb(x)  ((x) >> (20 - PAGE_SHIFT))   /* FIXME: is this right? */
158
159 /*
160  * Conversion functions: convert a page and protection to a page entry,
161  * and a page entry and page directory to the page they refer to.
162  */
163
164 /*
165  * Level 4 access.
166  */
167 static inline int pgd_large(pgd_t pgd) { return 0; }
168 #define mk_kernel_pgd(address) __pgd((address) | _KERNPG_TABLE)
169
170 /* PUD - Level3 access */
171
172 /* PMD  - Level 2 access */
173 #define pte_to_pgoff(pte) ((pte_val((pte)) & PHYSICAL_PAGE_MASK) >> PAGE_SHIFT)
174 #define pgoff_to_pte(off) ((pte_t) { .pte = ((off) << PAGE_SHIFT) |     \
175                                             _PAGE_FILE })
176 #define PTE_FILE_MAX_BITS __PHYSICAL_MASK_SHIFT
177
178 /* PTE - Level 1 access. */
179
180 /* x86-64 always has all page tables mapped. */
181 #define pte_offset_map(dir, address) pte_offset_kernel((dir), (address))
182 #define pte_offset_map_nested(dir, address) pte_offset_kernel((dir), (address))
183 #define pte_unmap(pte) /* NOP */
184 #define pte_unmap_nested(pte) /* NOP */
185
186 #define update_mmu_cache(vma, address, pte) do { } while (0)
187
188 extern int direct_gbpages;
189
190 /* Encode and de-code a swap entry */
191 #if _PAGE_BIT_FILE < _PAGE_BIT_PROTNONE
192 #define SWP_TYPE_BITS (_PAGE_BIT_FILE - _PAGE_BIT_PRESENT - 1)
193 #define SWP_OFFSET_SHIFT (_PAGE_BIT_PROTNONE + 1)
194 #else
195 #define SWP_TYPE_BITS (_PAGE_BIT_PROTNONE - _PAGE_BIT_PRESENT - 1)
196 #define SWP_OFFSET_SHIFT (_PAGE_BIT_FILE + 1)
197 #endif
198
199 #define MAX_SWAPFILES_CHECK() BUILD_BUG_ON(MAX_SWAPFILES_SHIFT > SWP_TYPE_BITS)
200
201 #define __swp_type(x)                   (((x).val >> (_PAGE_BIT_PRESENT + 1)) \
202                                          & ((1U << SWP_TYPE_BITS) - 1))
203 #define __swp_offset(x)                 ((x).val >> SWP_OFFSET_SHIFT)
204 #define __swp_entry(type, offset)       ((swp_entry_t) { \
205                                          ((type) << (_PAGE_BIT_PRESENT + 1)) \
206                                          | ((offset) << SWP_OFFSET_SHIFT) })
207 #define __pte_to_swp_entry(pte)         ((swp_entry_t) { pte_val((pte)) })
208 #define __swp_entry_to_pte(x)           ((pte_t) { .pte = (x).val })
209
210 extern int kern_addr_valid(unsigned long addr);
211 extern void cleanup_highmap(void);
212
213 #define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
214         remap_pfn_range(vma, vaddr, pfn, size, prot)
215
216 #define HAVE_ARCH_UNMAPPED_AREA
217 #define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
218
219 #define pgtable_cache_init()   do { } while (0)
220 #define check_pgt_cache()      do { } while (0)
221
222 #define PAGE_AGP    PAGE_KERNEL_NOCACHE
223 #define HAVE_PAGE_AGP 1
224
225 /* fs/proc/kcore.c */
226 #define kc_vaddr_to_offset(v) ((v) & __VIRTUAL_MASK)
227 #define kc_offset_to_vaddr(o)                           \
228         (((o) & (1UL << (__VIRTUAL_MASK_SHIFT - 1)))    \
229          ? ((o) | ~__VIRTUAL_MASK)                      \
230          : (o))
231
232 #define __HAVE_ARCH_PTE_SAME
233 #endif /* !__ASSEMBLY__ */
234
235 #endif /* _ASM_X86_PGTABLE_64_H */