ia64/xen-unstable

view linux-2.6-xen-sparse/include/asm-generic/pgtable.h @ 6726:0c7379b702e5

common/kernel.o contains changeset/compiler info.
Blow away on every build.
author kaf24@firebug.cl.cam.ac.uk
date Fri Sep 09 16:26:20 2005 +0000 (2005-09-09)
parents dd668f7527cb
children b2f4823b6ff0 b35215021b32 9af349b055e5 3233e7ecfa9f
line source
1 #ifndef _ASM_GENERIC_PGTABLE_H
2 #define _ASM_GENERIC_PGTABLE_H
4 #ifndef __HAVE_ARCH_PTEP_ESTABLISH
5 /*
6 * Establish a new mapping:
7 * - flush the old one
8 * - update the page tables
9 * - inform the TLB about the new one
10 *
11 * We hold the mm semaphore for reading and vma->vm_mm->page_table_lock.
12 *
13 * Note: the old pte is known to not be writable, so we don't need to
14 * worry about dirty bits etc getting lost.
15 */
16 #ifndef __HAVE_ARCH_SET_PTE_ATOMIC
17 #define ptep_establish(__vma, __address, __ptep, __entry) \
18 do { \
19 set_pte_at((__vma)->vm_mm, (__address), __ptep, __entry); \
20 flush_tlb_page(__vma, __address); \
21 } while (0)
22 #else /* __HAVE_ARCH_SET_PTE_ATOMIC */
23 #define ptep_establish(__vma, __address, __ptep, __entry) \
24 do { \
25 set_pte_atomic(__ptep, __entry); \
26 flush_tlb_page(__vma, __address); \
27 } while (0)
28 #endif /* __HAVE_ARCH_SET_PTE_ATOMIC */
29 #endif
31 #ifndef __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS
32 /*
33 * Largely same as above, but only sets the access flags (dirty,
34 * accessed, and writable). Furthermore, we know it always gets set
35 * to a "more permissive" setting, which allows most architectures
36 * to optimize this.
37 */
38 #define ptep_set_access_flags(__vma, __address, __ptep, __entry, __dirty) \
39 do { \
40 set_pte_at((__vma)->vm_mm, (__address), __ptep, __entry); \
41 flush_tlb_page(__vma, __address); \
42 } while (0)
43 #endif
45 #ifndef __HAVE_ARCH_PTEP_ESTABLISH_NEW
46 /*
47 * Establish a mapping where none previously existed
48 */
49 #define ptep_establish_new(__vma, __address, __ptep, __entry) \
50 do { \
51 set_pte(__ptep, __entry); \
52 } while (0)
53 #endif
55 #ifndef __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
56 #define ptep_test_and_clear_young(__vma, __address, __ptep) \
57 ({ \
58 pte_t __pte = *(__ptep); \
59 int r = 1; \
60 if (!pte_young(__pte)) \
61 r = 0; \
62 else \
63 set_pte_at((__vma)->vm_mm, (__address), \
64 (__ptep), pte_mkold(__pte)); \
65 r; \
66 })
67 #endif
69 #ifndef __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH
70 #define ptep_clear_flush_young(__vma, __address, __ptep) \
71 ({ \
72 int __young; \
73 __young = ptep_test_and_clear_young(__vma, __address, __ptep); \
74 if (__young) \
75 flush_tlb_page(__vma, __address); \
76 __young; \
77 })
78 #endif
80 #ifndef __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY
81 #define ptep_test_and_clear_dirty(__vma, __address, __ptep) \
82 ({ \
83 pte_t __pte = *__ptep; \
84 int r = 1; \
85 if (!pte_dirty(__pte)) \
86 r = 0; \
87 else \
88 set_pte_at((__vma)->vm_mm, (__address), (__ptep), \
89 pte_mkclean(__pte)); \
90 r; \
91 })
92 #endif
94 #ifndef __HAVE_ARCH_PTEP_CLEAR_DIRTY_FLUSH
95 #define ptep_clear_flush_dirty(__vma, __address, __ptep) \
96 ({ \
97 int __dirty; \
98 __dirty = ptep_test_and_clear_dirty(__vma, __address, __ptep); \
99 if (__dirty) \
100 flush_tlb_page(__vma, __address); \
101 __dirty; \
102 })
103 #endif
105 #ifndef __HAVE_ARCH_PTEP_GET_AND_CLEAR
106 #define ptep_get_and_clear(__mm, __address, __ptep) \
107 ({ \
108 pte_t __pte = *(__ptep); \
109 pte_clear((__mm), (__address), (__ptep)); \
110 __pte; \
111 })
112 #endif
114 #ifndef __HAVE_ARCH_PTEP_CLEAR_FLUSH
115 #define ptep_clear_flush(__vma, __address, __ptep) \
116 ({ \
117 pte_t __pte; \
118 __pte = ptep_get_and_clear((__vma)->vm_mm, __address, __ptep); \
119 flush_tlb_page(__vma, __address); \
120 __pte; \
121 })
122 #endif
124 #ifndef __HAVE_ARCH_PTEP_SET_WRPROTECT
125 static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long address, pte_t *ptep)
126 {
127 pte_t old_pte = *ptep;
128 set_pte_at(mm, address, ptep, pte_wrprotect(old_pte));
129 }
130 #endif
132 #ifndef __HAVE_ARCH_PTE_SAME
133 #define pte_same(A,B) (pte_val(A) == pte_val(B))
134 #endif
136 #ifndef __HAVE_ARCH_PAGE_TEST_AND_CLEAR_DIRTY
137 #define page_test_and_clear_dirty(page) (0)
138 #endif
140 #ifndef __HAVE_ARCH_PAGE_TEST_AND_CLEAR_YOUNG
141 #define page_test_and_clear_young(page) (0)
142 #endif
144 #ifndef __HAVE_ARCH_PGD_OFFSET_GATE
145 #define pgd_offset_gate(mm, addr) pgd_offset(mm, addr)
146 #endif
148 #ifndef __HAVE_ARCH_LAZY_MMU_PROT_UPDATE
149 #define lazy_mmu_prot_update(pte) do { } while (0)
150 #endif
152 /*
153 * When walking page tables, get the address of the next boundary,
154 * or the end address of the range if that comes earlier. Although no
155 * vma end wraps to 0, rounded up __boundary may wrap to 0 throughout.
156 */
158 #define pgd_addr_end(addr, end) \
159 ({ unsigned long __boundary = ((addr) + PGDIR_SIZE) & PGDIR_MASK; \
160 (__boundary - 1 < (end) - 1)? __boundary: (end); \
161 })
163 #ifndef pud_addr_end
164 #define pud_addr_end(addr, end) \
165 ({ unsigned long __boundary = ((addr) + PUD_SIZE) & PUD_MASK; \
166 (__boundary - 1 < (end) - 1)? __boundary: (end); \
167 })
168 #endif
170 #ifndef pmd_addr_end
171 #define pmd_addr_end(addr, end) \
172 ({ unsigned long __boundary = ((addr) + PMD_SIZE) & PMD_MASK; \
173 (__boundary - 1 < (end) - 1)? __boundary: (end); \
174 })
175 #endif
177 #ifndef __ASSEMBLY__
178 /*
179 * When walking page tables, we usually want to skip any p?d_none entries;
180 * and any p?d_bad entries - reporting the error before resetting to none.
181 * Do the tests inline, but report and clear the bad entry in mm/memory.c.
182 */
183 void pgd_clear_bad(pgd_t *);
184 void pud_clear_bad(pud_t *);
185 void pmd_clear_bad(pmd_t *);
187 static inline int pgd_none_or_clear_bad(pgd_t *pgd)
188 {
189 if (pgd_none(*pgd))
190 return 1;
191 if (unlikely(pgd_bad(*pgd))) {
192 pgd_clear_bad(pgd);
193 return 1;
194 }
195 return 0;
196 }
198 static inline int pud_none_or_clear_bad(pud_t *pud)
199 {
200 if (pud_none(*pud))
201 return 1;
202 if (unlikely(pud_bad(*pud))) {
203 pud_clear_bad(pud);
204 return 1;
205 }
206 return 0;
207 }
209 static inline int pmd_none_or_clear_bad(pmd_t *pmd)
210 {
211 if (pmd_none(*pmd))
212 return 1;
213 if (unlikely(pmd_bad(*pmd))) {
214 pmd_clear_bad(pmd);
215 return 1;
216 }
217 return 0;
218 }
219 #endif /* !__ASSEMBLY__ */
221 #endif /* _ASM_GENERIC_PGTABLE_H */