ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / include / asm-ppc64 / pgtable.h
1 #ifndef _PPC64_PGTABLE_H
2 #define _PPC64_PGTABLE_H
3
4 /*
5  * This file contains the functions and defines necessary to modify and use
6  * the ppc64 hashed page table.
7  */
8
9 #ifndef __ASSEMBLY__
10 #include <linux/config.h>
11 #include <linux/stddef.h>
12 #include <asm/processor.h>              /* For TASK_SIZE */
13 #include <asm/mmu.h>
14 #include <asm/page.h>
15 #include <asm/tlbflush.h>
16 #endif /* __ASSEMBLY__ */
17
18 /* PMD_SHIFT determines what a second-level page table entry can map */
19 #define PMD_SHIFT       (PAGE_SHIFT + PAGE_SHIFT - 3)
20 #define PMD_SIZE        (1UL << PMD_SHIFT)
21 #define PMD_MASK        (~(PMD_SIZE-1))
22
23 /* PGDIR_SHIFT determines what a third-level page table entry can map */
24 #define PGDIR_SHIFT     (PAGE_SHIFT + (PAGE_SHIFT - 3) + (PAGE_SHIFT - 2))
25 #define PGDIR_SIZE      (1UL << PGDIR_SHIFT)
26 #define PGDIR_MASK      (~(PGDIR_SIZE-1))
27
28 /*
29  * Entries per page directory level.  The PTE level must use a 64b record
30  * for each page table entry.  The PMD and PGD level use a 32b record for 
31  * each entry by assuming that each entry is page aligned.
32  */
33 #define PTE_INDEX_SIZE  9
34 #define PMD_INDEX_SIZE  10
35 #define PGD_INDEX_SIZE  10
36
37 #define PTRS_PER_PTE    (1 << PTE_INDEX_SIZE)
38 #define PTRS_PER_PMD    (1 << PMD_INDEX_SIZE)
39 #define PTRS_PER_PGD    (1 << PGD_INDEX_SIZE)
40
41 #define USER_PTRS_PER_PGD       (1024)
42 #define FIRST_USER_PGD_NR       0
43
44 #define EADDR_SIZE (PTE_INDEX_SIZE + PMD_INDEX_SIZE + \
45                     PGD_INDEX_SIZE + PAGE_SHIFT) 
46
47 /*
48  * Define the address range of the vmalloc VM area.
49  */
50 #define VMALLOC_START (0xD000000000000000)
51 #define VMALLOC_END   (VMALLOC_START + VALID_EA_BITS)
52
53 /*
54  * Define the address range of the imalloc VM area.
55  * (used for ioremap)
56  */
57 #define IMALLOC_START     (ioremap_bot)
58 #define IMALLOC_VMADDR(x) ((unsigned long)(x))
59 #define PHBS_IO_BASE      (0xE000000000000000)  /* Reserve 2 gigs for PHBs */
60 #define IMALLOC_BASE      (0xE000000080000000)  
61 #define IMALLOC_END       (IMALLOC_BASE + VALID_EA_BITS)
62
63 /*
64  * Define the address range mapped virt <-> physical
65  */
66 #define KRANGE_START KERNELBASE
67 #define KRANGE_END   (KRANGE_START + VALID_EA_BITS)
68
69 /*
70  * Define the user address range
71  */
72 #define USER_START (0UL)
73 #define USER_END   (USER_START + VALID_EA_BITS)
74
75
76 /*
77  * Bits in a linux-style PTE.  These match the bits in the
78  * (hardware-defined) PowerPC PTE as closely as possible.
79  */
80 #define _PAGE_PRESENT   0x0001 /* software: pte contains a translation */
81 #define _PAGE_USER      0x0002 /* matches one of the PP bits */
82 #define _PAGE_FILE      0x0002 /* (!present only) software: pte holds file offset */
83 #define _PAGE_RW        0x0004 /* software: user write access allowed */
84 #define _PAGE_GUARDED   0x0008
85 #define _PAGE_COHERENT  0x0010 /* M: enforce memory coherence (SMP systems) */
86 #define _PAGE_NO_CACHE  0x0020 /* I: cache inhibit */
87 #define _PAGE_WRITETHRU 0x0040 /* W: cache write-through */
88 #define _PAGE_DIRTY     0x0080 /* C: page changed */
89 #define _PAGE_ACCESSED  0x0100 /* R: page referenced */
90 #define _PAGE_EXEC      0x0200 /* software: i-cache coherence required */
91 #define _PAGE_HASHPTE   0x0400 /* software: pte has an associated HPTE */
92 #define _PAGE_BUSY      0x0800 /* software: PTE & hash are busy */ 
93 #define _PAGE_SECONDARY 0x8000 /* software: HPTE is in secondary group */
94 #define _PAGE_GROUP_IX  0x7000 /* software: HPTE index within group */
95 /* Bits 0x7000 identify the index within an HPT Group */
96 #define _PAGE_HPTEFLAGS (_PAGE_BUSY | _PAGE_HASHPTE | _PAGE_SECONDARY | _PAGE_GROUP_IX)
97 /* PAGE_MASK gives the right answer below, but only by accident */
98 /* It should be preserving the high 48 bits and then specifically */
99 /* preserving _PAGE_SECONDARY | _PAGE_GROUP_IX */
100 #define _PAGE_CHG_MASK  (PAGE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_HPTEFLAGS)
101
102 #define _PAGE_BASE      (_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_COHERENT)
103
104 #define _PAGE_WRENABLE  (_PAGE_RW | _PAGE_DIRTY)
105
106 /* __pgprot defined in asm-ppc64/page.h */
107 #define PAGE_NONE       __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED)
108
109 #define PAGE_SHARED     __pgprot(_PAGE_BASE | _PAGE_RW | _PAGE_USER)
110 #define PAGE_SHARED_X   __pgprot(_PAGE_BASE | _PAGE_RW | _PAGE_USER | _PAGE_EXEC)
111 #define PAGE_COPY       __pgprot(_PAGE_BASE | _PAGE_USER)
112 #define PAGE_COPY_X     __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_EXEC)
113 #define PAGE_READONLY   __pgprot(_PAGE_BASE | _PAGE_USER)
114 #define PAGE_READONLY_X __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_EXEC)
115 #define PAGE_KERNEL     __pgprot(_PAGE_BASE | _PAGE_WRENABLE)
116 #define PAGE_KERNEL_CI  __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED | \
117                                _PAGE_WRENABLE | _PAGE_NO_CACHE | _PAGE_GUARDED)
118
119 /*
120  * The PowerPC can only do execute protection on a segment (256MB) basis,
121  * not on a page basis.  So we consider execute permission the same as read.
122  * Also, write permissions imply read permissions.
123  * This is the closest we can get..
124  */
125 #define __P000  PAGE_NONE
126 #define __P001  PAGE_READONLY_X
127 #define __P010  PAGE_COPY
128 #define __P011  PAGE_COPY_X
129 #define __P100  PAGE_READONLY
130 #define __P101  PAGE_READONLY_X
131 #define __P110  PAGE_COPY
132 #define __P111  PAGE_COPY_X
133
134 #define __S000  PAGE_NONE
135 #define __S001  PAGE_READONLY_X
136 #define __S010  PAGE_SHARED
137 #define __S011  PAGE_SHARED_X
138 #define __S100  PAGE_READONLY
139 #define __S101  PAGE_READONLY_X
140 #define __S110  PAGE_SHARED
141 #define __S111  PAGE_SHARED_X
142
143 #ifndef __ASSEMBLY__
144
145 /*
146  * ZERO_PAGE is a global shared page that is always zero: used
147  * for zero-mapped memory areas etc..
148  */
149 extern unsigned long empty_zero_page[PAGE_SIZE/sizeof(unsigned long)];
150 #define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
151 #endif /* __ASSEMBLY__ */
152
153 /* shift to put page number into pte */
154 #define PTE_SHIFT (16)
155
156 /* We allow 2^41 bytes of real memory, so we need 29 bits in the PMD
157  * to give the PTE page number.  The bottom two bits are for flags. */
158 #define PMD_TO_PTEPAGE_SHIFT (2)
159
160 #ifdef CONFIG_HUGETLB_PAGE
161 #define _PMD_HUGEPAGE   0x00000001U
162 #define HUGEPTE_BATCH_SIZE (1<<(HPAGE_SHIFT-PMD_SHIFT))
163
164 #ifndef __ASSEMBLY__
165 int hash_huge_page(struct mm_struct *mm, unsigned long access,
166                    unsigned long ea, unsigned long vsid, int local);
167 #endif /* __ASSEMBLY__ */
168
169 #define HAVE_ARCH_UNMAPPED_AREA
170 #else
171
172 #define hash_huge_page(mm,a,ea,vsid,local)      -1
173 #define _PMD_HUGEPAGE   0
174
175 #endif
176
177 #ifndef __ASSEMBLY__
178
179 /*
180  * Conversion functions: convert a page and protection to a page entry,
181  * and a page entry and page directory to the page they refer to.
182  *
183  * mk_pte takes a (struct page *) as input
184  */
185 #define mk_pte(page, pgprot)    pfn_pte(page_to_pfn(page), (pgprot))
186
187 #define pfn_pte(pfn,pgprot)                                             \
188 ({                                                                      \
189         pte_t pte;                                                      \
190         pte_val(pte) = ((unsigned long)(pfn) << PTE_SHIFT) |            \
191                         pgprot_val(pgprot);                             \
192         pte;                                                            \
193 })
194
195 #define pte_modify(_pte, newprot) \
196   (__pte((pte_val(_pte) & _PAGE_CHG_MASK) | pgprot_val(newprot)))
197
198 #define pte_none(pte)           ((pte_val(pte) & ~_PAGE_HPTEFLAGS) == 0)
199 #define pte_present(pte)        (pte_val(pte) & _PAGE_PRESENT)
200
201 /* pte_clear moved to later in this file */
202
203 #define pte_pfn(x)              ((unsigned long)((pte_val(x) >> PTE_SHIFT)))
204 #define pte_page(x)             pfn_to_page(pte_pfn(x))
205
206 #define pmd_set(pmdp, ptep)     \
207         (pmd_val(*(pmdp)) = (__ba_to_bpn(ptep) << PMD_TO_PTEPAGE_SHIFT))
208 #define pmd_none(pmd)           (!pmd_val(pmd))
209 #define pmd_hugepage(pmd)       (!!(pmd_val(pmd) & _PMD_HUGEPAGE))
210 #define pmd_bad(pmd)            (((pmd_val(pmd)) == 0) || pmd_hugepage(pmd))
211 #define pmd_present(pmd)        ((!pmd_hugepage(pmd)) \
212                                  && (pmd_val(pmd) & ~_PMD_HUGEPAGE) != 0)
213 #define pmd_clear(pmdp)         (pmd_val(*(pmdp)) = 0)
214 #define pmd_page_kernel(pmd)    \
215         (__bpn_to_ba(pmd_val(pmd) >> PMD_TO_PTEPAGE_SHIFT))
216 #define pmd_page(pmd)           virt_to_page(pmd_page_kernel(pmd))
217 #define pgd_set(pgdp, pmdp)     (pgd_val(*(pgdp)) = (__ba_to_bpn(pmdp)))
218 #define pgd_none(pgd)           (!pgd_val(pgd))
219 #define pgd_bad(pgd)            ((pgd_val(pgd)) == 0)
220 #define pgd_present(pgd)        (pgd_val(pgd) != 0UL)
221 #define pgd_clear(pgdp)         (pgd_val(*(pgdp)) = 0UL)
222 #define pgd_page(pgd)           (__bpn_to_ba(pgd_val(pgd))) 
223
224 /* 
225  * Find an entry in a page-table-directory.  We combine the address region 
226  * (the high order N bits) and the pgd portion of the address.
227  */
228 /* to avoid overflow in free_pgtables we don't use PTRS_PER_PGD here */
229 #define pgd_index(address) (((address) >> (PGDIR_SHIFT)) & 0x7ff)
230
231 #define pgd_offset(mm, address)  ((mm)->pgd + pgd_index(address))
232
233 /* Find an entry in the second-level page table.. */
234 #define pmd_offset(dir,addr) \
235   ((pmd_t *) pgd_page(*(dir)) + (((addr) >> PMD_SHIFT) & (PTRS_PER_PMD - 1)))
236
237 /* Find an entry in the third-level page table.. */
238 #define pte_offset_kernel(dir,addr) \
239   ((pte_t *) pmd_page_kernel(*(dir)) + (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)))
240
241 #define pte_offset_map(dir,addr)        pte_offset_kernel((dir), (addr))
242 #define pte_offset_map_nested(dir,addr) pte_offset_kernel((dir), (addr))
243 #define pte_unmap(pte)                  do { } while(0)
244 #define pte_unmap_nested(pte)           do { } while(0)
245
246 /* to find an entry in a kernel page-table-directory */
247 /* This now only contains the vmalloc pages */
248 #define pgd_offset_k(address) pgd_offset(&init_mm, address)
249
250 /* to find an entry in the ioremap page-table-directory */
251 #define pgd_offset_i(address) (ioremap_pgd + pgd_index(address))
252
253 #define pages_to_mb(x)          ((x) >> (20-PAGE_SHIFT))
254
255 /*
256  * The following only work if pte_present() is true.
257  * Undefined behaviour if not..
258  */
259 static inline int pte_read(pte_t pte)  { return pte_val(pte) & _PAGE_USER;}
260 static inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_RW;}
261 static inline int pte_exec(pte_t pte)  { return pte_val(pte) & _PAGE_EXEC;}
262 static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY;}
263 static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED;}
264 static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE;}
265
266 static inline void pte_uncache(pte_t pte) { pte_val(pte) |= _PAGE_NO_CACHE; }
267 static inline void pte_cache(pte_t pte)   { pte_val(pte) &= ~_PAGE_NO_CACHE; }
268
269 static inline pte_t pte_rdprotect(pte_t pte) {
270         pte_val(pte) &= ~_PAGE_USER; return pte; }
271 static inline pte_t pte_exprotect(pte_t pte) {
272         pte_val(pte) &= ~_PAGE_EXEC; return pte; }
273 static inline pte_t pte_wrprotect(pte_t pte) {
274         pte_val(pte) &= ~(_PAGE_RW); return pte; }
275 static inline pte_t pte_mkclean(pte_t pte) {
276         pte_val(pte) &= ~(_PAGE_DIRTY); return pte; }
277 static inline pte_t pte_mkold(pte_t pte) {
278         pte_val(pte) &= ~_PAGE_ACCESSED; return pte; }
279
280 static inline pte_t pte_mkread(pte_t pte) {
281         pte_val(pte) |= _PAGE_USER; return pte; }
282 static inline pte_t pte_mkexec(pte_t pte) {
283         pte_val(pte) |= _PAGE_USER | _PAGE_EXEC; return pte; }
284 static inline pte_t pte_mkwrite(pte_t pte) {
285         pte_val(pte) |= _PAGE_RW; return pte; }
286 static inline pte_t pte_mkdirty(pte_t pte) {
287         pte_val(pte) |= _PAGE_DIRTY; return pte; }
288 static inline pte_t pte_mkyoung(pte_t pte) {
289         pte_val(pte) |= _PAGE_ACCESSED; return pte; }
290
291 /* Atomic PTE updates */
292 static inline unsigned long pte_update(pte_t *p, unsigned long clr)
293 {
294         unsigned long old, tmp;
295
296         __asm__ __volatile__(
297         "1:     ldarx   %0,0,%3         # pte_update\n\
298         andi.   %1,%0,%6\n\
299         bne-    1b \n\
300         andc    %1,%0,%4 \n\
301         stdcx.  %1,0,%3 \n\
302         bne-    1b"
303         : "=&r" (old), "=&r" (tmp), "=m" (*p)
304         : "r" (p), "r" (clr), "m" (*p), "i" (_PAGE_BUSY)
305         : "cc" );
306         return old;
307 }
308
309 /* PTE updating functions */
310 extern void hpte_update(pte_t *ptep, unsigned long pte, int wrprot);
311
312 static inline int ptep_test_and_clear_young(pte_t *ptep)
313 {
314         unsigned long old;
315
316         if ((pte_val(*ptep) & (_PAGE_ACCESSED | _PAGE_HASHPTE)) == 0)
317                 return 0;
318         old = pte_update(ptep, _PAGE_ACCESSED);
319         if (old & _PAGE_HASHPTE) {
320                 hpte_update(ptep, old, 0);
321                 flush_tlb_pending();    /* XXX generic code doesn't flush */
322         }
323         return (old & _PAGE_ACCESSED) != 0;
324 }
325
326 /*
327  * On RW/DIRTY bit transitions we can avoid flushing the hpte. For the
328  * moment we always flush but we need to fix hpte_update and test if the
329  * optimisation is worth it.
330  */
331 static inline int ptep_test_and_clear_dirty(pte_t *ptep)
332 {
333         unsigned long old;
334
335         if ((pte_val(*ptep) & _PAGE_DIRTY) == 0)
336                 return 0;
337         old = pte_update(ptep, _PAGE_DIRTY);
338         if (old & _PAGE_HASHPTE)
339                 hpte_update(ptep, old, 0);
340         return (old & _PAGE_DIRTY) != 0;
341 }
342
343 static inline void ptep_set_wrprotect(pte_t *ptep)
344 {
345         unsigned long old;
346
347         if ((pte_val(*ptep) & _PAGE_RW) == 0)
348                 return;
349         old = pte_update(ptep, _PAGE_RW);
350         if (old & _PAGE_HASHPTE)
351                 hpte_update(ptep, old, 0);
352 }
353
354 /*
355  * We currently remove entries from the hashtable regardless of whether
356  * the entry was young or dirty. The generic routines only flush if the
357  * entry was young or dirty which is not good enough.
358  *
359  * We should be more intelligent about this but for the moment we override
360  * these functions and force a tlb flush unconditionally
361  */
362 #define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH
363 #define ptep_clear_flush_young(__vma, __address, __ptep)                \
364 ({                                                                      \
365         int __young = ptep_test_and_clear_young(__ptep);                \
366         __young;                                                        \
367 })
368
369 #define __HAVE_ARCH_PTEP_CLEAR_DIRTY_FLUSH
370 #define ptep_clear_flush_dirty(__vma, __address, __ptep)                \
371 ({                                                                      \
372         int __dirty = ptep_test_and_clear_dirty(__ptep);                \
373         flush_tlb_page(__vma, __address);                               \
374         __dirty;                                                        \
375 })
376
377 static inline pte_t ptep_get_and_clear(pte_t *ptep)
378 {
379         unsigned long old = pte_update(ptep, ~0UL);
380
381         if (old & _PAGE_HASHPTE)
382                 hpte_update(ptep, old, 0);
383         return __pte(old);
384 }
385
386 static inline void pte_clear(pte_t * ptep)
387 {
388         unsigned long old = pte_update(ptep, ~0UL);
389
390         if (old & _PAGE_HASHPTE)
391                 hpte_update(ptep, old, 0);
392 }
393
394 /*
395  * set_pte stores a linux PTE into the linux page table.
396  */
397 static inline void set_pte(pte_t *ptep, pte_t pte)
398 {
399         if (pte_present(*ptep))
400                 pte_clear(ptep);
401         *ptep = __pte(pte_val(pte)) & ~_PAGE_HPTEFLAGS;
402 }
403
404 /*
405  * Macro to mark a page protection value as "uncacheable".
406  */
407 #define pgprot_noncached(prot)  (__pgprot(pgprot_val(prot) | _PAGE_NO_CACHE | _PAGE_GUARDED))
408
409 #define pte_same(A,B)   (((pte_val(A) ^ pte_val(B)) & ~_PAGE_HPTEFLAGS) == 0)
410
411 extern unsigned long ioremap_bot, ioremap_base;
412
413 #define USER_PGD_PTRS (PAGE_OFFSET >> PGDIR_SHIFT)
414 #define KERNEL_PGD_PTRS (PTRS_PER_PGD-USER_PGD_PTRS)
415
416 #define pte_ERROR(e) \
417         printk("%s:%d: bad pte %016lx.\n", __FILE__, __LINE__, pte_val(e))
418 #define pmd_ERROR(e) \
419         printk("%s:%d: bad pmd %08x.\n", __FILE__, __LINE__, pmd_val(e))
420 #define pgd_ERROR(e) \
421         printk("%s:%d: bad pgd %08x.\n", __FILE__, __LINE__, pgd_val(e))
422
423 extern pgd_t swapper_pg_dir[1024];
424 extern pgd_t ioremap_dir[1024];
425
426 extern void paging_init(void);
427
428 /*
429  * This gets called at the end of handling a page fault, when
430  * the kernel has put a new PTE into the page table for the process.
431  * We use it to put a corresponding HPTE into the hash table
432  * ahead of time, instead of waiting for the inevitable extra
433  * hash-table miss exception.
434  */
435 struct vm_area_struct;
436 extern void update_mmu_cache(struct vm_area_struct *, unsigned long, pte_t);
437
438 /* Encode and de-code a swap entry */
439 #define __swp_type(entry)       (((entry).val >> 1) & 0x3f)
440 #define __swp_offset(entry)     ((entry).val >> 8)
441 #define __swp_entry(type, offset) ((swp_entry_t) { ((type) << 1) | ((offset) << 8) })
442 #define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) >> PTE_SHIFT })
443 #define __swp_entry_to_pte(x)   ((pte_t) { (x).val << PTE_SHIFT })
444 #define pte_to_pgoff(pte)       (pte_val(pte) >> PTE_SHIFT)
445 #define pgoff_to_pte(off)       ((pte_t) {((off) << PTE_SHIFT)|_PAGE_FILE})
446 #define PTE_FILE_MAX_BITS       (BITS_PER_LONG - PTE_SHIFT)
447
448 /*
449  * kern_addr_valid is intended to indicate whether an address is a valid
450  * kernel address.  Most 32-bit archs define it as always true (like this)
451  * but most 64-bit archs actually perform a test.  What should we do here?
452  * The only use is in fs/ncpfs/dir.c
453  */
454 #define kern_addr_valid(addr)   (1)
455
456 #define io_remap_page_range remap_page_range 
457
458 void pgtable_cache_init(void);
459
460 extern void hpte_init_pSeries(void);
461 extern void hpte_init_iSeries(void);
462
463 /* imalloc region types */
464 #define IM_REGION_UNUSED        0x1
465 #define IM_REGION_SUBSET        0x2
466 #define IM_REGION_EXISTS        0x4
467 #define IM_REGION_OVERLAP       0x8
468
469 extern struct vm_struct * im_get_free_area(unsigned long size);
470 extern struct vm_struct * im_get_area(unsigned long v_addr, unsigned long size,
471                         int region_type);
472 unsigned long im_free(void *addr);
473
474 typedef pte_t *pte_addr_t;
475
476 long pSeries_lpar_hpte_insert(unsigned long hpte_group,
477                               unsigned long va, unsigned long prpn,
478                               int secondary, unsigned long hpteflags,
479                               int bolted, int large);
480
481 long pSeries_hpte_insert(unsigned long hpte_group, unsigned long va,
482                          unsigned long prpn, int secondary,
483                          unsigned long hpteflags, int bolted, int large);
484
485 /*
486  * find_linux_pte returns the address of a linux pte for a given 
487  * effective address and directory.  If not found, it returns zero.
488  */
489 static inline pte_t *find_linux_pte(pgd_t *pgdir, unsigned long ea)
490 {
491         pgd_t *pg;
492         pmd_t *pm;
493         pte_t *pt = NULL;
494         pte_t pte;
495
496         pg = pgdir + pgd_index(ea);
497         if (!pgd_none(*pg)) {
498
499                 pm = pmd_offset(pg, ea);
500                 if (pmd_present(*pm)) { 
501                         pt = pte_offset_kernel(pm, ea);
502                         pte = *pt;
503                         if (!pte_present(pte))
504                                 pt = NULL;
505                 }
506         }
507
508         return pt;
509 }
510
511 #endif /* __ASSEMBLY__ */
512
513 #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
514 #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY
515 #define __HAVE_ARCH_PTEP_GET_AND_CLEAR
516 #define __HAVE_ARCH_PTEP_SET_WRPROTECT
517 #define __HAVE_ARCH_PTEP_MKDIRTY
518 #define __HAVE_ARCH_PTE_SAME
519 #include <asm-generic/pgtable.h>
520
521 #endif /* _PPC64_PGTABLE_H */