Commit | Line | Data |
---|---|---|
71087002 BH |
1 | /* Included from asm/pgtable-*.h only ! */ |
2 | ||
3 | /* | |
4 | * Some bits are only used on some cpu families... Make sure that all | |
5 | * the undefined gets a sensible default | |
6 | */ | |
7 | #ifndef _PAGE_HASHPTE | |
8 | #define _PAGE_HASHPTE 0 | |
9 | #endif | |
10 | #ifndef _PAGE_SHARED | |
11 | #define _PAGE_SHARED 0 | |
12 | #endif | |
13 | #ifndef _PAGE_HWWRITE | |
14 | #define _PAGE_HWWRITE 0 | |
15 | #endif | |
71087002 BH |
16 | #ifndef _PAGE_EXEC |
17 | #define _PAGE_EXEC 0 | |
18 | #endif | |
19 | #ifndef _PAGE_ENDIAN | |
20 | #define _PAGE_ENDIAN 0 | |
21 | #endif | |
22 | #ifndef _PAGE_COHERENT | |
23 | #define _PAGE_COHERENT 0 | |
24 | #endif | |
25 | #ifndef _PAGE_WRITETHRU | |
26 | #define _PAGE_WRITETHRU 0 | |
27 | #endif | |
28 | #ifndef _PAGE_SPECIAL | |
29 | #define _PAGE_SPECIAL 0 | |
30 | #endif | |
31 | #ifndef _PAGE_4K_PFN | |
32 | #define _PAGE_4K_PFN 0 | |
33 | #endif | |
57e2a99f BH |
34 | #ifndef _PAGE_SAO |
35 | #define _PAGE_SAO 0 | |
36 | #endif | |
71087002 BH |
37 | #ifndef _PAGE_PSIZE |
38 | #define _PAGE_PSIZE 0 | |
39 | #endif | |
40 | #ifndef _PMD_PRESENT_MASK | |
41 | #define _PMD_PRESENT_MASK _PMD_PRESENT | |
42 | #endif | |
43 | #ifndef _PMD_SIZE | |
44 | #define _PMD_SIZE 0 | |
45 | #define PMD_PAGE_SIZE(pmd) bad_call_to_PMD_PAGE_SIZE() | |
46 | #endif | |
47 | #ifndef _PAGE_KERNEL_RO | |
ea3cc330 BH |
48 | #define _PAGE_KERNEL_RO 0 |
49 | #endif | |
50 | #ifndef _PAGE_KERNEL_ROX | |
51 | #define _PAGE_KERNEL_ROX (_PAGE_EXEC) | |
71087002 BH |
52 | #endif |
53 | #ifndef _PAGE_KERNEL_RW | |
ea3cc330 BH |
54 | #define _PAGE_KERNEL_RW (_PAGE_DIRTY | _PAGE_RW | _PAGE_HWWRITE) |
55 | #endif | |
56 | #ifndef _PAGE_KERNEL_RWX | |
57 | #define _PAGE_KERNEL_RWX (_PAGE_DIRTY | _PAGE_RW | _PAGE_HWWRITE | _PAGE_EXEC) | |
71087002 BH |
58 | #endif |
59 | #ifndef _PAGE_HPTEFLAGS | |
60 | #define _PAGE_HPTEFLAGS _PAGE_HASHPTE | |
61 | #endif | |
62 | #ifndef _PTE_NONE_MASK | |
63 | #define _PTE_NONE_MASK _PAGE_HPTEFLAGS | |
64 | #endif | |
65 | ||
66 | /* Make sure we get a link error if PMD_PAGE_SIZE is ever called on a | |
67 | * kernel without large page PMD support | |
68 | */ | |
69 | #ifndef __ASSEMBLY__ | |
70 | extern unsigned long bad_call_to_PMD_PAGE_SIZE(void); | |
71 | #endif /* __ASSEMBLY__ */ | |
72 | ||
73 | /* Location of the PFN in the PTE. Most 32-bit platforms use the same | |
74 | * as _PAGE_SHIFT here (ie, naturally aligned). | |
75 | * Platform who don't just pre-define the value so we don't override it here | |
76 | */ | |
77 | #ifndef PTE_RPN_SHIFT | |
78 | #define PTE_RPN_SHIFT (PAGE_SHIFT) | |
79 | #endif | |
80 | ||
81 | /* The mask convered by the RPN must be a ULL on 32-bit platforms with | |
82 | * 64-bit PTEs | |
83 | */ | |
84 | #if defined(CONFIG_PPC32) && defined(CONFIG_PTE_64BIT) | |
85 | #define PTE_RPN_MAX (1ULL << (64 - PTE_RPN_SHIFT)) | |
86 | #define PTE_RPN_MASK (~((1ULL<<PTE_RPN_SHIFT)-1)) | |
87 | #else | |
88 | #define PTE_RPN_MAX (1UL << (32 - PTE_RPN_SHIFT)) | |
89 | #define PTE_RPN_MASK (~((1UL<<PTE_RPN_SHIFT)-1)) | |
90 | #endif | |
91 | ||
92 | /* _PAGE_CHG_MASK masks of bits that are to be preserved accross | |
93 | * pgprot changes | |
94 | */ | |
95 | #define _PAGE_CHG_MASK (PTE_RPN_MASK | _PAGE_HPTEFLAGS | _PAGE_DIRTY | \ | |
96 | _PAGE_ACCESSED | _PAGE_SPECIAL) | |
97 | ||
98 | /* Mask of bits returned by pte_pgprot() */ | |
99 | #define PAGE_PROT_BITS (_PAGE_GUARDED | _PAGE_COHERENT | _PAGE_NO_CACHE | \ | |
100 | _PAGE_WRITETHRU | _PAGE_ENDIAN | _PAGE_4K_PFN | \ | |
101 | _PAGE_USER | _PAGE_ACCESSED | \ | |
ea3cc330 | 102 | _PAGE_RW | _PAGE_HWWRITE | _PAGE_DIRTY | _PAGE_EXEC) |
71087002 BH |
103 | |
104 | /* | |
105 | * We define 2 sets of base prot bits, one for basic pages (ie, | |
106 | * cacheable kernel and user pages) and one for non cacheable | |
107 | * pages. We always set _PAGE_COHERENT when SMP is enabled or | |
108 | * the processor might need it for DMA coherency. | |
109 | */ | |
110 | #define _PAGE_BASE_NC (_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_PSIZE) | |
111 | #if defined(CONFIG_SMP) || defined(CONFIG_PPC_STD_MMU) | |
112 | #define _PAGE_BASE (_PAGE_BASE_NC | _PAGE_COHERENT) | |
113 | #else | |
114 | #define _PAGE_BASE (_PAGE_BASE_NC) | |
115 | #endif | |
116 | ||
117 | /* Permission masks used to generate the __P and __S table, | |
118 | * | |
119 | * Note:__pgprot is defined in arch/powerpc/include/asm/page.h | |
120 | * | |
121 | * Write permissions imply read permissions for now (we could make write-only | |
122 | * pages on BookE but we don't bother for now). Execute permission control is | |
123 | * possible on platforms that define _PAGE_EXEC | |
124 | * | |
125 | * Note due to the way vm flags are laid out, the bits are XWR | |
126 | */ | |
127 | #define PAGE_NONE __pgprot(_PAGE_BASE) | |
128 | #define PAGE_SHARED __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_RW) | |
129 | #define PAGE_SHARED_X __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_RW | _PAGE_EXEC) | |
130 | #define PAGE_COPY __pgprot(_PAGE_BASE | _PAGE_USER) | |
131 | #define PAGE_COPY_X __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_EXEC) | |
132 | #define PAGE_READONLY __pgprot(_PAGE_BASE | _PAGE_USER) | |
133 | #define PAGE_READONLY_X __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_EXEC) | |
134 | ||
135 | #define __P000 PAGE_NONE | |
136 | #define __P001 PAGE_READONLY | |
137 | #define __P010 PAGE_COPY | |
138 | #define __P011 PAGE_COPY | |
139 | #define __P100 PAGE_READONLY_X | |
140 | #define __P101 PAGE_READONLY_X | |
141 | #define __P110 PAGE_COPY_X | |
142 | #define __P111 PAGE_COPY_X | |
143 | ||
144 | #define __S000 PAGE_NONE | |
145 | #define __S001 PAGE_READONLY | |
146 | #define __S010 PAGE_SHARED | |
147 | #define __S011 PAGE_SHARED | |
148 | #define __S100 PAGE_READONLY_X | |
149 | #define __S101 PAGE_READONLY_X | |
150 | #define __S110 PAGE_SHARED_X | |
151 | #define __S111 PAGE_SHARED_X | |
152 | ||
153 | /* Permission masks used for kernel mappings */ | |
154 | #define PAGE_KERNEL __pgprot(_PAGE_BASE | _PAGE_KERNEL_RW) | |
155 | #define PAGE_KERNEL_NC __pgprot(_PAGE_BASE_NC | _PAGE_KERNEL_RW | \ | |
156 | _PAGE_NO_CACHE) | |
157 | #define PAGE_KERNEL_NCG __pgprot(_PAGE_BASE_NC | _PAGE_KERNEL_RW | \ | |
158 | _PAGE_NO_CACHE | _PAGE_GUARDED) | |
ea3cc330 | 159 | #define PAGE_KERNEL_X __pgprot(_PAGE_BASE | _PAGE_KERNEL_RWX) |
71087002 | 160 | #define PAGE_KERNEL_RO __pgprot(_PAGE_BASE | _PAGE_KERNEL_RO) |
ea3cc330 | 161 | #define PAGE_KERNEL_ROX __pgprot(_PAGE_BASE | _PAGE_KERNEL_ROX) |
71087002 BH |
162 | |
163 | /* Protection used for kernel text. We want the debuggers to be able to | |
164 | * set breakpoints anywhere, so don't write protect the kernel text | |
165 | * on platforms where such control is possible. | |
166 | */ | |
167 | #if defined(CONFIG_KGDB) || defined(CONFIG_XMON) || defined(CONFIG_BDI_SWITCH) ||\ | |
168 | defined(CONFIG_KPROBES) | |
169 | #define PAGE_KERNEL_TEXT PAGE_KERNEL_X | |
170 | #else | |
171 | #define PAGE_KERNEL_TEXT PAGE_KERNEL_ROX | |
172 | #endif | |
173 | ||
174 | /* Make modules code happy. We don't set RO yet */ | |
175 | #define PAGE_KERNEL_EXEC PAGE_KERNEL_X | |
176 | ||
177 | /* Advertise special mapping type for AGP */ | |
178 | #define PAGE_AGP (PAGE_KERNEL_NC) | |
179 | #define HAVE_PAGE_AGP | |
180 | ||
181 | /* Advertise support for _PAGE_SPECIAL */ | |
182 | #ifdef _PAGE_SPECIAL | |
183 | #define __HAVE_ARCH_PTE_SPECIAL | |
184 | #endif | |
185 |