.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) |
---|
3 | | - * |
---|
4 | | - * This program is free software; you can redistribute it and/or modify |
---|
5 | | - * it under the terms of the GNU General Public License version 2 as |
---|
6 | | - * published by the Free Software Foundation. |
---|
7 | 4 | * |
---|
8 | 5 | * vineetg: May 2011 |
---|
9 | 6 | * -Folded PAGE_PRESENT (used by VM) and PAGE_VALID (used by MMU) into 1. |
---|
.. | .. |
---|
35 | 32 | #ifndef _ASM_ARC_PGTABLE_H |
---|
36 | 33 | #define _ASM_ARC_PGTABLE_H |
---|
37 | 34 | |
---|
38 | | -#include <linux/const.h> |
---|
39 | | -#define __ARCH_USE_5LEVEL_HACK |
---|
| 35 | +#include <linux/bits.h> |
---|
40 | 36 | #include <asm-generic/pgtable-nopmd.h> |
---|
41 | 37 | #include <asm/page.h> |
---|
42 | 38 | #include <asm/mmu.h> /* to propagate CONFIG_ARC_MMU_VER <n> */ |
---|
.. | .. |
---|
111 | 107 | #define ___DEF (_PAGE_PRESENT | _PAGE_CACHEABLE) |
---|
112 | 108 | |
---|
113 | 109 | /* Set of bits not changed in pte_modify */ |
---|
114 | | -#define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_SPECIAL) |
---|
115 | | - |
---|
| 110 | +#define _PAGE_CHG_MASK (PAGE_MASK_PHYS | _PAGE_ACCESSED | _PAGE_DIRTY | \ |
---|
| 111 | + _PAGE_SPECIAL) |
---|
116 | 112 | /* More Abbrevaited helpers */ |
---|
117 | 113 | #define PAGE_U_NONE __pgprot(___DEF) |
---|
118 | 114 | #define PAGE_U_R __pgprot(___DEF | _PAGE_READ) |
---|
.. | .. |
---|
136 | 132 | #define PTE_BITS_IN_PD0 (_PAGE_GLOBAL | _PAGE_PRESENT | _PAGE_HW_SZ) |
---|
137 | 133 | #define PTE_BITS_RWX (_PAGE_EXECUTE | _PAGE_WRITE | _PAGE_READ) |
---|
138 | 134 | |
---|
139 | | -#ifdef CONFIG_ARC_HAS_PAE40 |
---|
140 | | -#define PTE_BITS_NON_RWX_IN_PD1 (0xff00000000 | PAGE_MASK | _PAGE_CACHEABLE) |
---|
141 | | -#define MAX_POSSIBLE_PHYSMEM_BITS 40 |
---|
142 | | -#else |
---|
143 | | -#define PTE_BITS_NON_RWX_IN_PD1 (PAGE_MASK | _PAGE_CACHEABLE) |
---|
144 | | -#define MAX_POSSIBLE_PHYSMEM_BITS 32 |
---|
145 | | -#endif |
---|
| 135 | +#define PTE_BITS_NON_RWX_IN_PD1 (PAGE_MASK_PHYS | _PAGE_CACHEABLE) |
---|
146 | 136 | |
---|
147 | 137 | /************************************************************************** |
---|
148 | 138 | * Mapping of vm_flags (Generic VM) to PTE flags (arch specific) |
---|
.. | .. |
---|
220 | 210 | #define BITS_FOR_PTE (PGDIR_SHIFT - PAGE_SHIFT) |
---|
221 | 211 | #define BITS_FOR_PGD (32 - PGDIR_SHIFT) |
---|
222 | 212 | |
---|
223 | | -#define PGDIR_SIZE _BITUL(PGDIR_SHIFT) /* vaddr span, not PDG sz */ |
---|
| 213 | +#define PGDIR_SIZE BIT(PGDIR_SHIFT) /* vaddr span, not PDG sz */ |
---|
224 | 214 | #define PGDIR_MASK (~(PGDIR_SIZE-1)) |
---|
225 | 215 | |
---|
226 | | -#define PTRS_PER_PTE _BITUL(BITS_FOR_PTE) |
---|
227 | | -#define PTRS_PER_PGD _BITUL(BITS_FOR_PGD) |
---|
| 216 | +#define PTRS_PER_PTE BIT(BITS_FOR_PTE) |
---|
| 217 | +#define PTRS_PER_PGD BIT(BITS_FOR_PGD) |
---|
228 | 218 | |
---|
229 | 219 | /* |
---|
230 | 220 | * Number of entries a user land program use. |
---|
.. | .. |
---|
254 | 244 | extern char empty_zero_page[PAGE_SIZE]; |
---|
255 | 245 | #define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page)) |
---|
256 | 246 | |
---|
257 | | -#define pte_unmap(pte) do { } while (0) |
---|
258 | | -#define pte_unmap_nested(pte) do { } while (0) |
---|
259 | | - |
---|
260 | 247 | #define set_pte(pteptr, pteval) ((*(pteptr)) = (pteval)) |
---|
261 | 248 | #define set_pmd(pmdptr, pmdval) (*(pmdptr) = pmdval) |
---|
262 | 249 | |
---|
.. | .. |
---|
279 | 266 | #define pmd_none(x) (!pmd_val(x)) |
---|
280 | 267 | #define pmd_bad(x) ((pmd_val(x) & ~PAGE_MASK)) |
---|
281 | 268 | #define pmd_present(x) (pmd_val(x)) |
---|
| 269 | +#define pmd_leaf(x) (pmd_val(x) & _PAGE_HW_SZ) |
---|
282 | 270 | #define pmd_clear(xp) do { pmd_val(*(xp)) = 0; } while (0) |
---|
283 | 271 | |
---|
284 | 272 | #define pte_page(pte) pfn_to_page(pte_pfn(pte)) |
---|
.. | .. |
---|
287 | 275 | |
---|
288 | 276 | /* Don't use virt_to_pfn for macros below: could cause truncations for PAE40*/ |
---|
289 | 277 | #define pte_pfn(pte) (pte_val(pte) >> PAGE_SHIFT) |
---|
290 | | -#define __pte_index(addr) (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)) |
---|
291 | | - |
---|
292 | | -/* |
---|
293 | | - * pte_offset gets a @ptr to PMD entry (PGD in our 2-tier paging system) |
---|
294 | | - * and returns ptr to PTE entry corresponding to @addr |
---|
295 | | - */ |
---|
296 | | -#define pte_offset(dir, addr) ((pte_t *)(pmd_page_vaddr(*dir)) +\ |
---|
297 | | - __pte_index(addr)) |
---|
298 | | - |
---|
299 | | -/* No mapping of Page Tables in high mem etc, so following same as above */ |
---|
300 | | -#define pte_offset_kernel(dir, addr) pte_offset(dir, addr) |
---|
301 | | -#define pte_offset_map(dir, addr) pte_offset(dir, addr) |
---|
302 | 278 | |
---|
303 | 279 | /* Zoo of pte_xxx function */ |
---|
304 | 280 | #define pte_read(pte) (pte_val(pte) & _PAGE_READ) |
---|
.. | .. |
---|
337 | 313 | } |
---|
338 | 314 | |
---|
339 | 315 | /* |
---|
340 | | - * All kernel related VM pages are in init's mm. |
---|
341 | | - */ |
---|
342 | | -#define pgd_offset_k(address) pgd_offset(&init_mm, address) |
---|
343 | | -#define pgd_index(addr) ((addr) >> PGDIR_SHIFT) |
---|
344 | | -#define pgd_offset(mm, addr) (((mm)->pgd)+pgd_index(addr)) |
---|
345 | | - |
---|
346 | | -/* |
---|
347 | 316 | * Macro to quickly access the PGD entry, utlising the fact that some |
---|
348 | 317 | * arch may cache the pointer to Page Directory of "current" task |
---|
349 | 318 | * in a MMU register |
---|
.. | .. |
---|
356 | 325 | * Thus use this macro only when you are certain that "current" is current |
---|
357 | 326 | * e.g. when dealing with signal frame setup code etc |
---|
358 | 327 | */ |
---|
359 | | -#ifndef CONFIG_SMP |
---|
| 328 | +#ifdef ARC_USE_SCRATCH_REG |
---|
360 | 329 | #define pgd_offset_fast(mm, addr) \ |
---|
361 | 330 | ({ \ |
---|
362 | 331 | pgd_t *pgd_base = (pgd_t *) read_aux_reg(ARC_REG_SCRATCH_DATA0); \ |
---|
.. | .. |
---|
395 | 364 | #include <asm/hugepage.h> |
---|
396 | 365 | #endif |
---|
397 | 366 | |
---|
398 | | -#include <asm-generic/pgtable.h> |
---|
399 | | - |
---|
400 | 367 | /* to cope with aliasing VIPT cache */ |
---|
401 | 368 | #define HAVE_ARCH_UNMAPPED_AREA |
---|
402 | | - |
---|
403 | | -/* |
---|
404 | | - * No page table caches to initialise |
---|
405 | | - */ |
---|
406 | | -#define pgtable_cache_init() do { } while (0) |
---|
407 | 369 | |
---|
408 | 370 | #endif /* __ASSEMBLY__ */ |
---|
409 | 371 | |
---|