1 #ifndef _ASM_POWERPC_PGTABLE_PPC64_H_
2 #define _ASM_POWERPC_PGTABLE_PPC64_H_
8 #ifdef CONFIG_PPC_64K_PAGES
14 #define FIRST_USER_ADDRESS 0
19 #define PGTABLE_EADDR_SIZE (PTE_INDEX_SIZE + PMD_INDEX_SIZE + \
20 PUD_INDEX_SIZE + PGD_INDEX_SIZE + PAGE_SHIFT)
21 #define PGTABLE_RANGE (ASM_CONST(1) << PGTABLE_EADDR_SIZE)
28 #ifdef CONFIG_PPC_BOOK3E
29 #define KERN_VIRT_START ASM_CONST(0x8000000000000000)
31 #define KERN_VIRT_START ASM_CONST(0xD000000000000000)
33 #define KERN_VIRT_SIZE ASM_CONST(0x0000100000000000)
40 #define VMALLOC_START KERN_VIRT_START
41 #ifdef CONFIG_PPC_BOOK3E
42 #define VMALLOC_SIZE (KERN_VIRT_SIZE >> 2)
44 #define VMALLOC_SIZE (KERN_VIRT_SIZE >> 1)
46 #define VMALLOC_END (VMALLOC_START + VMALLOC_SIZE)
57 #define KERN_IO_START (KERN_VIRT_START + (KERN_VIRT_SIZE >> 1))
58 #define FULL_IO_SIZE 0x80000000ul
59 #define ISA_IO_BASE (KERN_IO_START)
60 #define ISA_IO_END (KERN_IO_START + 0x10000ul)
61 #define PHB_IO_BASE (ISA_IO_END)
62 #define PHB_IO_END (KERN_IO_START + FULL_IO_SIZE)
63 #define IOREMAP_BASE (PHB_IO_END)
64 #define IOREMAP_END (KERN_VIRT_START + KERN_VIRT_SIZE)
70 #define REGION_SHIFT 60UL
71 #define REGION_MASK (0xfUL << REGION_SHIFT)
72 #define REGION_ID(ea) (((unsigned long)(ea)) >> REGION_SHIFT)
74 #define VMALLOC_REGION_ID (REGION_ID(VMALLOC_START))
75 #define KERNEL_REGION_ID (REGION_ID(PAGE_OFFSET))
76 #define VMEMMAP_REGION_ID (0xfUL)
77 #define USER_REGION_ID (0UL)
83 #ifdef CONFIG_PPC_BOOK3E
84 #define VMEMMAP_BASE VMALLOC_END
85 #define VMEMMAP_END KERN_IO_START
87 #define VMEMMAP_BASE (VMEMMAP_REGION_ID << REGION_SHIFT)
89 #define vmemmap ((struct page *)VMEMMAP_BASE)
95 #ifdef CONFIG_PPC_BOOK3S
102 #ifdef CONFIG_PPC_MM_SLICES
103 #define HAVE_ARCH_UNMAPPED_AREA
104 #define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
116 #ifdef STRICT_MM_TYPECHECKS
117 #define __real_pte(e,p) ((real_pte_t){(e)})
118 #define __rpte_to_pte(r) ((r).pte)
120 #define __real_pte(e,p) (e)
121 #define __rpte_to_pte(r) (__pte(r))
123 #define __rpte_to_hidx(r,index) (pte_val(__rpte_to_pte(r)) >> 12)
125 #define pte_iterate_hashed_subpages(rpte, psize, va, index, shift) \
128 shift = mmu_psize_defs[psize].shift; \
130 #define pte_iterate_hashed_end() } while(0)
132 #ifdef CONFIG_PPC_HAS_HASH_64K
133 #define pte_pagesize_index(mm, addr, pte) get_slice_psize(mm, addr)
135 #define pte_pagesize_index(mm, addr, pte) MMU_PAGE_4K
143 #define PMD_BAD_BITS (PTE_TABLE_SIZE-1)
144 #define PUD_BAD_BITS (PMD_TABLE_SIZE-1)
146 #define pmd_set(pmdp, pmdval) (pmd_val(*(pmdp)) = (pmdval))
147 #define pmd_none(pmd) (!pmd_val(pmd))
148 #define pmd_bad(pmd) (!is_kernel_addr(pmd_val(pmd)) \
149 || (pmd_val(pmd) & PMD_BAD_BITS))
150 #define pmd_present(pmd) (pmd_val(pmd) != 0)
151 #define pmd_clear(pmdp) (pmd_val(*(pmdp)) = 0)
152 #define pmd_page_vaddr(pmd) (pmd_val(pmd) & ~PMD_MASKED_BITS)
153 #define pmd_page(pmd) virt_to_page(pmd_page_vaddr(pmd))
155 #define pud_set(pudp, pudval) (pud_val(*(pudp)) = (pudval))
156 #define pud_none(pud) (!pud_val(pud))
157 #define pud_bad(pud) (!is_kernel_addr(pud_val(pud)) \
158 || (pud_val(pud) & PUD_BAD_BITS))
159 #define pud_present(pud) (pud_val(pud) != 0)
160 #define pud_clear(pudp) (pud_val(*(pudp)) = 0)
161 #define pud_page_vaddr(pud) (pud_val(pud) & ~PUD_MASKED_BITS)
162 #define pud_page(pud) virt_to_page(pud_page_vaddr(pud))
164 #define pgd_set(pgdp, pudp) ({pgd_val(*(pgdp)) = (unsigned long)(pudp);})
171 #define pgd_index(address) (((address) >> (PGDIR_SHIFT)) & 0x1ff)
173 #define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
175 #define pmd_offset(pudp,addr) \
176 (((pmd_t *) pud_page_vaddr(*(pudp))) + (((addr) >> PMD_SHIFT) & (PTRS_PER_PMD - 1)))
178 #define pte_offset_kernel(dir,addr) \
179 (((pte_t *) pmd_page_vaddr(*(dir))) + (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)))
181 #define pte_offset_map(dir,addr) pte_offset_kernel((dir), (addr))
182 #define pte_unmap(pte) do { } while(0)
186 #define pgd_offset_k(address) pgd_offset(&init_mm, address)
188 pte_t *ptep,
unsigned long pte,
int huge);
193 pte_t *ptep,
unsigned long clr,
196 #ifdef PTE_ATOMIC_UPDATES
197 unsigned long old,
tmp;
200 "1: ldarx %0,0,%3 # pte_update\n\
206 :
"=&r" (old),
"=&r" (tmp),
"=m" (*ptep)
207 :
"r" (ptep),
"r" (clr),
"m" (*ptep),
"i" (_PAGE_BUSY)
210 unsigned long old =
pte_val(*ptep);
211 *ptep =
__pte(old & ~clr);
215 assert_pte_locked(mm, addr);
217 #ifdef CONFIG_PPC_STD_MMU_64
225 static inline int __ptep_test_and_clear_young(
struct mm_struct *mm,
226 unsigned long addr,
pte_t *ptep)
235 #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
236 #define ptep_test_and_clear_young(__vma, __addr, __ptep) \
239 __r = __ptep_test_and_clear_young((__vma)->vm_mm, __addr, __ptep); \
243 #define __HAVE_ARCH_PTEP_SET_WRPROTECT
244 static inline void ptep_set_wrprotect(
struct mm_struct *mm,
unsigned long addr,
255 unsigned long addr,
pte_t *ptep)
271 #define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH
272 #define ptep_clear_flush_young(__vma, __address, __ptep) \
274 int __young = __ptep_test_and_clear_young((__vma)->vm_mm, __address, \
279 #define __HAVE_ARCH_PTEP_GET_AND_CLEAR
281 unsigned long addr,
pte_t *ptep)
283 unsigned long old =
pte_update(mm, addr, ptep, ~0
UL, 0);
302 #ifdef PTE_ATOMIC_UPDATES
303 unsigned long old,
tmp;
312 :
"=&r" (old),
"=&r" (tmp),
"=m" (*ptep)
313 :
"r" (bits),
"r" (ptep),
"m" (*ptep),
"i" (_PAGE_BUSY)
316 unsigned long old =
pte_val(*ptep);
317 *ptep =
__pte(old | bits);
321 #define __HAVE_ARCH_PTE_SAME
322 #define pte_same(A,B) (((pte_val(A) ^ pte_val(B)) & ~_PAGE_HPTEFLAGS) == 0)
324 #define pte_ERROR(e) \
325 printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, pte_val(e))
326 #define pmd_ERROR(e) \
327 printk("%s:%d: bad pmd %08lx.\n", __FILE__, __LINE__, pmd_val(e))
328 #define pgd_ERROR(e) \
329 printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e))
332 #define __swp_type(entry) (((entry).val >> 1) & 0x3f)
333 #define __swp_offset(entry) ((entry).val >> 8)
334 #define __swp_entry(type, offset) ((swp_entry_t){((type)<< 1)|((offset)<<8)})
335 #define __pte_to_swp_entry(pte) ((swp_entry_t){pte_val(pte) >> PTE_RPN_SHIFT})
336 #define __swp_entry_to_pte(x) ((pte_t) { (x).val << PTE_RPN_SHIFT })
337 #define pte_to_pgoff(pte) (pte_val(pte) >> PTE_RPN_SHIFT)
338 #define pgoff_to_pte(off) ((pte_t) {((off) << PTE_RPN_SHIFT)|_PAGE_FILE})
339 #define PTE_FILE_MAX_BITS (BITS_PER_LONG - PTE_RPN_SHIFT)
367 #ifdef CONFIG_HUGETLB_PAGE
376 return find_linux_pte(pgdir, ea);