| .. | .. |
|---|
| 1 | | -/* |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0 |
|---|
| 2 | + * |
|---|
| 2 | 3 | * This file contains the functions and defines necessary to modify and |
|---|
| 3 | 4 | * use the SuperH page table tree. |
|---|
| 4 | 5 | * |
|---|
| 5 | 6 | * Copyright (C) 1999 Niibe Yutaka |
|---|
| 6 | 7 | * Copyright (C) 2002 - 2007 Paul Mundt |
|---|
| 7 | | - * |
|---|
| 8 | | - * This file is subject to the terms and conditions of the GNU General |
|---|
| 9 | | - * Public License. See the file "COPYING" in the main directory of this |
|---|
| 10 | | - * archive for more details. |
|---|
| 11 | 8 | */ |
|---|
| 12 | 9 | #ifndef __ASM_SH_PGTABLE_H |
|---|
| 13 | 10 | #define __ASM_SH_PGTABLE_H |
|---|
| .. | .. |
|---|
| 79 | 76 | #define PTE_PHYS_MASK (phys_addr_mask() & PAGE_MASK) |
|---|
| 80 | 77 | #define PTE_FLAGS_MASK (~(PTE_PHYS_MASK) << PAGE_SHIFT) |
|---|
| 81 | 78 | |
|---|
| 82 | | -#ifdef CONFIG_SUPERH32 |
|---|
| 83 | 79 | #define VMALLOC_START (P3SEG) |
|---|
| 84 | | -#else |
|---|
| 85 | | -#define VMALLOC_START (0xf0000000) |
|---|
| 86 | | -#endif |
|---|
| 87 | 80 | #define VMALLOC_END (FIXADDR_START-2*PAGE_SIZE) |
|---|
| 88 | 81 | |
|---|
| 89 | | -#if defined(CONFIG_SUPERH32) |
|---|
| 90 | 82 | #include <asm/pgtable_32.h> |
|---|
| 91 | | -#else |
|---|
| 92 | | -#include <asm/pgtable_64.h> |
|---|
| 93 | | -#endif |
|---|
| 94 | 83 | |
|---|
| 95 | 84 | /* |
|---|
| 96 | 85 | * SH-X and lower (legacy) SuperH parts (SH-3, SH-4, some SH-4A) can't do page |
|---|
| .. | .. |
|---|
| 126 | 115 | |
|---|
| 127 | 116 | #define pte_pfn(x) ((unsigned long)(((x).pte_low >> PAGE_SHIFT))) |
|---|
| 128 | 117 | |
|---|
| 129 | | -/* |
|---|
| 130 | | - * Initialise the page table caches |
|---|
| 131 | | - */ |
|---|
| 132 | | -extern void pgtable_cache_init(void); |
|---|
| 133 | | - |
|---|
| 134 | 118 | struct vm_area_struct; |
|---|
| 135 | 119 | struct mm_struct; |
|---|
| 136 | 120 | |
|---|
| .. | .. |
|---|
| 152 | 136 | extern void page_table_range_init(unsigned long start, unsigned long end, |
|---|
| 153 | 137 | pgd_t *pgd); |
|---|
| 154 | 138 | |
|---|
| 139 | +static inline bool __pte_access_permitted(pte_t pte, u64 prot) |
|---|
| 140 | +{ |
|---|
| 141 | + return (pte_val(pte) & (prot | _PAGE_SPECIAL)) == prot; |
|---|
| 142 | +} |
|---|
| 143 | + |
|---|
| 144 | +#ifdef CONFIG_X2TLB |
|---|
| 145 | +static inline bool pte_access_permitted(pte_t pte, bool write) |
|---|
| 146 | +{ |
|---|
| 147 | + u64 prot = _PAGE_PRESENT; |
|---|
| 148 | + |
|---|
| 149 | + prot |= _PAGE_EXT(_PAGE_EXT_KERN_READ | _PAGE_EXT_USER_READ); |
|---|
| 150 | + if (write) |
|---|
| 151 | + prot |= _PAGE_EXT(_PAGE_EXT_KERN_WRITE | _PAGE_EXT_USER_WRITE); |
|---|
| 152 | + return __pte_access_permitted(pte, prot); |
|---|
| 153 | +} |
|---|
| 154 | +#else |
|---|
| 155 | +static inline bool pte_access_permitted(pte_t pte, bool write) |
|---|
| 156 | +{ |
|---|
| 157 | + u64 prot = _PAGE_PRESENT | _PAGE_USER; |
|---|
| 158 | + |
|---|
| 159 | + if (write) |
|---|
| 160 | + prot |= _PAGE_RW; |
|---|
| 161 | + return __pte_access_permitted(pte, prot); |
|---|
| 162 | +} |
|---|
| 163 | +#endif |
|---|
| 164 | + |
|---|
| 165 | +#define pte_access_permitted pte_access_permitted |
|---|
| 166 | + |
|---|
| 155 | 167 | /* arch/sh/mm/mmap.c */ |
|---|
| 156 | 168 | #define HAVE_ARCH_UNMAPPED_AREA |
|---|
| 157 | 169 | #define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN |
|---|
| 158 | | - |
|---|
| 159 | | -#include <asm-generic/pgtable.h> |
|---|
| 160 | 170 | |
|---|
| 161 | 171 | #endif /* __ASM_SH_PGTABLE_H */ |
|---|