aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-powerpc/page_64.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-powerpc/page_64.h')
-rw-r--r--include/asm-powerpc/page_64.h183
1 files changed, 183 insertions, 0 deletions
diff --git a/include/asm-powerpc/page_64.h b/include/asm-powerpc/page_64.h
new file mode 100644
index 000000000000..6642c0125001
--- /dev/null
+++ b/include/asm-powerpc/page_64.h
@@ -0,0 +1,183 @@
1#ifndef _ASM_POWERPC_PAGE_64_H
2#define _ASM_POWERPC_PAGE_64_H
3
4/*
5 * Copyright (C) 2001 PPC64 Team, IBM Corp
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12
13/*
14 * We always define HW_PAGE_SHIFT to 12 as use of 64K pages remains Linux
15 * specific, every notion of page number shared with the firmware, TCEs,
16 * iommu, etc... still uses a page size of 4K.
17 */
18#define HW_PAGE_SHIFT 12
19#define HW_PAGE_SIZE (ASM_CONST(1) << HW_PAGE_SHIFT)
20#define HW_PAGE_MASK (~(HW_PAGE_SIZE-1))
21
22/*
23 * PAGE_FACTOR is the number of bits factor between PAGE_SHIFT and
24 * HW_PAGE_SHIFT, that is 4K pages.
25 */
26#define PAGE_FACTOR (PAGE_SHIFT - HW_PAGE_SHIFT)
27
28#define REGION_SIZE 4UL
29#define REGION_SHIFT 60UL
30#define REGION_MASK (((1UL<<REGION_SIZE)-1UL)<<REGION_SHIFT)
31
32#define VMALLOCBASE ASM_CONST(0xD000000000000000)
33#define VMALLOC_REGION_ID (VMALLOCBASE >> REGION_SHIFT)
34#define KERNEL_REGION_ID (KERNELBASE >> REGION_SHIFT)
35#define USER_REGION_ID (0UL)
36#define REGION_ID(ea) (((unsigned long)(ea)) >> REGION_SHIFT)
37
38/* Segment size */
39#define SID_SHIFT 28
40#define SID_MASK 0xfffffffffUL
41#define ESID_MASK 0xfffffffff0000000UL
42#define GET_ESID(x) (((x) >> SID_SHIFT) & SID_MASK)
43
44#ifndef __ASSEMBLY__
45#include <asm/cache.h>
46
47typedef unsigned long pte_basic_t;
48
49static __inline__ void clear_page(void *addr)
50{
51 unsigned long lines, line_size;
52
53 line_size = ppc64_caches.dline_size;
54 lines = ppc64_caches.dlines_per_page;
55
56 __asm__ __volatile__(
57 "mtctr %1 # clear_page\n\
581: dcbz 0,%0\n\
59 add %0,%0,%3\n\
60 bdnz+ 1b"
61 : "=r" (addr)
62 : "r" (lines), "0" (addr), "r" (line_size)
63 : "ctr", "memory");
64}
65
66extern void copy_4K_page(void *to, void *from);
67
68#ifdef CONFIG_PPC_64K_PAGES
69static inline void copy_page(void *to, void *from)
70{
71 unsigned int i;
72 for (i=0; i < (1 << (PAGE_SHIFT - 12)); i++) {
73 copy_4K_page(to, from);
74 to += 4096;
75 from += 4096;
76 }
77}
78#else /* CONFIG_PPC_64K_PAGES */
79static inline void copy_page(void *to, void *from)
80{
81 copy_4K_page(to, from);
82}
83#endif /* CONFIG_PPC_64K_PAGES */
84
85/* Log 2 of page table size */
86extern u64 ppc64_pft_size;
87
88/* Large pages size */
89#ifdef CONFIG_HUGETLB_PAGE
90extern unsigned int HPAGE_SHIFT;
91#else
92#define HPAGE_SHIFT PAGE_SHIFT
93#endif
94#define HPAGE_SIZE ((1UL) << HPAGE_SHIFT)
95#define HPAGE_MASK (~(HPAGE_SIZE - 1))
96#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
97
98#endif /* __ASSEMBLY__ */
99
100#ifdef CONFIG_HUGETLB_PAGE
101
102#define HTLB_AREA_SHIFT 40
103#define HTLB_AREA_SIZE (1UL << HTLB_AREA_SHIFT)
104#define GET_HTLB_AREA(x) ((x) >> HTLB_AREA_SHIFT)
105
106#define LOW_ESID_MASK(addr, len) \
107 (((1U << (GET_ESID(min((addr)+(len)-1, 0x100000000UL))+1)) \
108 - (1U << GET_ESID(min((addr), 0x100000000UL)))) & 0xffff)
109#define HTLB_AREA_MASK(addr, len) (((1U << (GET_HTLB_AREA(addr+len-1)+1)) \
110 - (1U << GET_HTLB_AREA(addr))) & 0xffff)
111
112#define ARCH_HAS_HUGEPAGE_ONLY_RANGE
113#define ARCH_HAS_PREPARE_HUGEPAGE_RANGE
114#define ARCH_HAS_SETCLEAR_HUGE_PTE
115
116#define touches_hugepage_low_range(mm, addr, len) \
117 (((addr) < 0x100000000UL) \
118 && (LOW_ESID_MASK((addr), (len)) & (mm)->context.low_htlb_areas))
119#define touches_hugepage_high_range(mm, addr, len) \
120 ((((addr) + (len)) > 0x100000000UL) \
121 && (HTLB_AREA_MASK((addr), (len)) & (mm)->context.high_htlb_areas))
122
123#define __within_hugepage_low_range(addr, len, segmask) \
124 ( (((addr)+(len)) <= 0x100000000UL) \
125 && ((LOW_ESID_MASK((addr), (len)) | (segmask)) == (segmask)))
126#define within_hugepage_low_range(addr, len) \
127 __within_hugepage_low_range((addr), (len), \
128 current->mm->context.low_htlb_areas)
129#define __within_hugepage_high_range(addr, len, zonemask) \
130 ( ((addr) >= 0x100000000UL) \
131 && ((HTLB_AREA_MASK((addr), (len)) | (zonemask)) == (zonemask)))
132#define within_hugepage_high_range(addr, len) \
133 __within_hugepage_high_range((addr), (len), \
134 current->mm->context.high_htlb_areas)
135
136#define is_hugepage_only_range(mm, addr, len) \
137 (touches_hugepage_high_range((mm), (addr), (len)) || \
138 touches_hugepage_low_range((mm), (addr), (len)))
139#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
140
141#define in_hugepage_area(context, addr) \
142 (cpu_has_feature(CPU_FTR_16M_PAGE) && \
143 ( ( (addr) >= 0x100000000UL) \
144 ? ((1 << GET_HTLB_AREA(addr)) & (context).high_htlb_areas) \
145 : ((1 << GET_ESID(addr)) & (context).low_htlb_areas) ) )
146
147#else /* !CONFIG_HUGETLB_PAGE */
148
149#define in_hugepage_area(mm, addr) 0
150
151#endif /* !CONFIG_HUGETLB_PAGE */
152
153#ifdef MODULE
154#define __page_aligned __attribute__((__aligned__(PAGE_SIZE)))
155#else
156#define __page_aligned \
157 __attribute__((__aligned__(PAGE_SIZE), \
158 __section__(".data.page_aligned")))
159#endif
160
161#define VM_DATA_DEFAULT_FLAGS \
162 (test_thread_flag(TIF_32BIT) ? \
163 VM_DATA_DEFAULT_FLAGS32 : VM_DATA_DEFAULT_FLAGS64)
164
165/*
166 * This is the default if a program doesn't have a PT_GNU_STACK
167 * program header entry. The PPC64 ELF ABI has a non executable stack
168 * stack by default, so in the absense of a PT_GNU_STACK program header
169 * we turn execute permission off.
170 */
171#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
172 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
173
174#define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
175 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
176
177#define VM_STACK_DEFAULT_FLAGS \
178 (test_thread_flag(TIF_32BIT) ? \
179 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
180
181#include <asm-generic/page.h>
182
183#endif /* _ASM_POWERPC_PAGE_64_H */