.. | .. |
---|
1 | | -/* |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0 */ |
---|
| 2 | +/* |
---|
2 | 3 | * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
---|
3 | 4 | * Copyright 2003 PathScale, Inc. |
---|
4 | 5 | * Derived from include/asm-i386/pgtable.h |
---|
5 | | - * Licensed under the GPL |
---|
6 | 6 | */ |
---|
7 | 7 | |
---|
8 | 8 | #ifndef __UM_PGTABLE_H |
---|
.. | .. |
---|
31 | 31 | |
---|
32 | 32 | /* zero page used for uninitialized stuff */ |
---|
33 | 33 | extern unsigned long *empty_zero_page; |
---|
34 | | - |
---|
35 | | -#define pgtable_cache_init() do ; while (0) |
---|
36 | 34 | |
---|
37 | 35 | /* Just any arbitrary offset to the start of the vmalloc VM area: the |
---|
38 | 36 | * current 8MB value just means that there will be a 8MB "hole" after the |
---|
.. | .. |
---|
108 | 106 | #define pud_newpage(x) (pud_val(x) & _PAGE_NEWPAGE) |
---|
109 | 107 | #define pud_mkuptodate(x) (pud_val(x) &= ~_PAGE_NEWPAGE) |
---|
110 | 108 | |
---|
| 109 | +#define p4d_newpage(x) (p4d_val(x) & _PAGE_NEWPAGE) |
---|
| 110 | +#define p4d_mkuptodate(x) (p4d_val(x) &= ~_PAGE_NEWPAGE) |
---|
| 111 | + |
---|
111 | 112 | #define pmd_page(pmd) phys_to_page(pmd_val(pmd) & PAGE_MASK) |
---|
112 | 113 | |
---|
113 | 114 | #define pte_page(x) pfn_to_page(pte_pfn(x)) |
---|
.. | .. |
---|
130 | 131 | * Undefined behaviour if not.. |
---|
131 | 132 | */ |
---|
132 | 133 | static inline int pte_read(pte_t pte) |
---|
133 | | -{ |
---|
| 134 | +{ |
---|
134 | 135 | return((pte_get_bits(pte, _PAGE_USER)) && |
---|
135 | 136 | !(pte_get_bits(pte, _PAGE_PROTNONE))); |
---|
136 | 137 | } |
---|
.. | .. |
---|
162 | 163 | } |
---|
163 | 164 | |
---|
164 | 165 | static inline int pte_newprot(pte_t pte) |
---|
165 | | -{ |
---|
166 | | - return(pte_present(pte) && (pte_get_bits(pte, _PAGE_NEWPROT))); |
---|
167 | | -} |
---|
168 | | - |
---|
169 | | -static inline int pte_special(pte_t pte) |
---|
170 | 166 | { |
---|
171 | | - return 0; |
---|
| 167 | + return(pte_present(pte) && (pte_get_bits(pte, _PAGE_NEWPROT))); |
---|
172 | 168 | } |
---|
173 | 169 | |
---|
174 | 170 | /* |
---|
.. | .. |
---|
189 | 185 | return(pte); |
---|
190 | 186 | } |
---|
191 | 187 | |
---|
192 | | -static inline pte_t pte_mkold(pte_t pte) |
---|
193 | | -{ |
---|
| 188 | +static inline pte_t pte_mkold(pte_t pte) |
---|
| 189 | +{ |
---|
194 | 190 | pte_clear_bits(pte, _PAGE_ACCESSED); |
---|
195 | 191 | return(pte); |
---|
196 | 192 | } |
---|
197 | 193 | |
---|
198 | 194 | static inline pte_t pte_wrprotect(pte_t pte) |
---|
199 | | -{ |
---|
| 195 | +{ |
---|
200 | 196 | if (likely(pte_get_bits(pte, _PAGE_RW))) |
---|
201 | 197 | pte_clear_bits(pte, _PAGE_RW); |
---|
202 | 198 | else |
---|
203 | 199 | return pte; |
---|
204 | | - return(pte_mknewprot(pte)); |
---|
| 200 | + return(pte_mknewprot(pte)); |
---|
205 | 201 | } |
---|
206 | 202 | |
---|
207 | 203 | static inline pte_t pte_mkread(pte_t pte) |
---|
208 | | -{ |
---|
| 204 | +{ |
---|
209 | 205 | if (unlikely(pte_get_bits(pte, _PAGE_USER))) |
---|
210 | 206 | return pte; |
---|
211 | 207 | pte_set_bits(pte, _PAGE_USER); |
---|
212 | | - return(pte_mknewprot(pte)); |
---|
| 208 | + return(pte_mknewprot(pte)); |
---|
213 | 209 | } |
---|
214 | 210 | |
---|
215 | 211 | static inline pte_t pte_mkdirty(pte_t pte) |
---|
216 | | -{ |
---|
| 212 | +{ |
---|
217 | 213 | pte_set_bits(pte, _PAGE_DIRTY); |
---|
218 | 214 | return(pte); |
---|
219 | 215 | } |
---|
.. | .. |
---|
224 | 220 | return(pte); |
---|
225 | 221 | } |
---|
226 | 222 | |
---|
227 | | -static inline pte_t pte_mkwrite(pte_t pte) |
---|
| 223 | +static inline pte_t pte_mkwrite(pte_t pte) |
---|
228 | 224 | { |
---|
229 | 225 | if (unlikely(pte_get_bits(pte, _PAGE_RW))) |
---|
230 | 226 | return pte; |
---|
231 | 227 | pte_set_bits(pte, _PAGE_RW); |
---|
232 | | - return(pte_mknewprot(pte)); |
---|
| 228 | + return(pte_mknewprot(pte)); |
---|
233 | 229 | } |
---|
234 | 230 | |
---|
235 | | -static inline pte_t pte_mkuptodate(pte_t pte) |
---|
| 231 | +static inline pte_t pte_mkuptodate(pte_t pte) |
---|
236 | 232 | { |
---|
237 | 233 | pte_clear_bits(pte, _PAGE_NEWPAGE); |
---|
238 | 234 | if(pte_present(pte)) |
---|
239 | 235 | pte_clear_bits(pte, _PAGE_NEWPROT); |
---|
240 | | - return(pte); |
---|
| 236 | + return(pte); |
---|
241 | 237 | } |
---|
242 | 238 | |
---|
243 | 239 | static inline pte_t pte_mknewpage(pte_t pte) |
---|
244 | 240 | { |
---|
245 | 241 | pte_set_bits(pte, _PAGE_NEWPAGE); |
---|
246 | | - return(pte); |
---|
247 | | -} |
---|
248 | | - |
---|
249 | | -static inline pte_t pte_mkspecial(pte_t pte) |
---|
250 | | -{ |
---|
251 | 242 | return(pte); |
---|
252 | 243 | } |
---|
253 | 244 | |
---|
.. | .. |
---|
263 | 254 | *pteptr = pte_mknewpage(*pteptr); |
---|
264 | 255 | if(pte_present(*pteptr)) *pteptr = pte_mknewprot(*pteptr); |
---|
265 | 256 | } |
---|
266 | | -#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval) |
---|
| 257 | + |
---|
| 258 | +static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, |
---|
| 259 | + pte_t *pteptr, pte_t pteval) |
---|
| 260 | +{ |
---|
| 261 | + set_pte(pteptr, pteval); |
---|
| 262 | +} |
---|
267 | 263 | |
---|
268 | 264 | #define __HAVE_ARCH_PTE_SAME |
---|
269 | 265 | static inline int pte_same(pte_t pte_a, pte_t pte_b) |
---|
.. | .. |
---|
292 | 288 | static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) |
---|
293 | 289 | { |
---|
294 | 290 | pte_set_val(pte, (pte_val(pte) & _PAGE_CHG_MASK), newprot); |
---|
295 | | - return pte; |
---|
| 291 | + return pte; |
---|
296 | 292 | } |
---|
297 | | - |
---|
298 | | -/* |
---|
299 | | - * the pgd page can be thought of an array like this: pgd_t[PTRS_PER_PGD] |
---|
300 | | - * |
---|
301 | | - * this macro returns the index of the entry in the pgd page which would |
---|
302 | | - * control the given virtual address |
---|
303 | | - */ |
---|
304 | | -#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1)) |
---|
305 | | - |
---|
306 | | -/* |
---|
307 | | - * pgd_offset() returns a (pgd_t *) |
---|
308 | | - * pgd_index() is used get the offset into the pgd page's array of pgd_t's; |
---|
309 | | - */ |
---|
310 | | -#define pgd_offset(mm, address) ((mm)->pgd+pgd_index(address)) |
---|
311 | | - |
---|
312 | | -/* |
---|
313 | | - * a shortcut which implies the use of the kernel's pgd, instead |
---|
314 | | - * of a process's |
---|
315 | | - */ |
---|
316 | | -#define pgd_offset_k(address) pgd_offset(&init_mm, address) |
---|
317 | 293 | |
---|
318 | 294 | /* |
---|
319 | 295 | * the pmd page can be thought of an array like this: pmd_t[PTRS_PER_PMD] |
---|
.. | .. |
---|
322 | 298 | * control the given virtual address |
---|
323 | 299 | */ |
---|
324 | 300 | #define pmd_page_vaddr(pmd) ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK)) |
---|
325 | | -#define pmd_index(address) (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1)) |
---|
326 | | - |
---|
327 | | -#define pmd_page_vaddr(pmd) \ |
---|
328 | | - ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK)) |
---|
329 | | - |
---|
330 | | -/* |
---|
331 | | - * the pte page can be thought of an array like this: pte_t[PTRS_PER_PTE] |
---|
332 | | - * |
---|
333 | | - * this macro returns the index of the entry in the pte page which would |
---|
334 | | - * control the given virtual address |
---|
335 | | - */ |
---|
336 | | -#define pte_index(address) (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)) |
---|
337 | | -#define pte_offset_kernel(dir, address) \ |
---|
338 | | - ((pte_t *) pmd_page_vaddr(*(dir)) + pte_index(address)) |
---|
339 | | -#define pte_offset_map(dir, address) \ |
---|
340 | | - ((pte_t *)page_address(pmd_page(*(dir))) + pte_index(address)) |
---|
341 | | -#define pte_unmap(pte) do { } while (0) |
---|
342 | 301 | |
---|
343 | 302 | struct mm_struct; |
---|
344 | 303 | extern pte_t *virt_to_pte(struct mm_struct *mm, unsigned long addr); |
---|
.. | .. |
---|
356 | 315 | #define __swp_entry_to_pte(x) ((pte_t) { (x).val }) |
---|
357 | 316 | |
---|
358 | 317 | #define kern_addr_valid(addr) (1) |
---|
359 | | - |
---|
360 | | -#include <asm-generic/pgtable.h> |
---|
361 | 318 | |
---|
362 | 319 | /* Clear a kernel PTE and flush it from the TLB */ |
---|
363 | 320 | #define kpte_clear_flush(ptep, vaddr) \ |
---|