hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/arch/sh/include/asm/pgtable.h
....@@ -1,13 +1,10 @@
1
-/*
1
+/* SPDX-License-Identifier: GPL-2.0
2
+ *
23 * This file contains the functions and defines necessary to modify and
34 * use the SuperH page table tree.
45 *
56 * Copyright (C) 1999 Niibe Yutaka
67 * 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.
118 */
129 #ifndef __ASM_SH_PGTABLE_H
1310 #define __ASM_SH_PGTABLE_H
....@@ -79,18 +76,10 @@
7976 #define PTE_PHYS_MASK (phys_addr_mask() & PAGE_MASK)
8077 #define PTE_FLAGS_MASK (~(PTE_PHYS_MASK) << PAGE_SHIFT)
8178
82
-#ifdef CONFIG_SUPERH32
8379 #define VMALLOC_START (P3SEG)
84
-#else
85
-#define VMALLOC_START (0xf0000000)
86
-#endif
8780 #define VMALLOC_END (FIXADDR_START-2*PAGE_SIZE)
8881
89
-#if defined(CONFIG_SUPERH32)
9082 #include <asm/pgtable_32.h>
91
-#else
92
-#include <asm/pgtable_64.h>
93
-#endif
9483
9584 /*
9685 * SH-X and lower (legacy) SuperH parts (SH-3, SH-4, some SH-4A) can't do page
....@@ -126,11 +115,6 @@
126115
127116 #define pte_pfn(x) ((unsigned long)(((x).pte_low >> PAGE_SHIFT)))
128117
129
-/*
130
- * Initialise the page table caches
131
- */
132
-extern void pgtable_cache_init(void);
133
-
134118 struct vm_area_struct;
135119 struct mm_struct;
136120
....@@ -152,10 +136,36 @@
152136 extern void page_table_range_init(unsigned long start, unsigned long end,
153137 pgd_t *pgd);
154138
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
+
155167 /* arch/sh/mm/mmap.c */
156168 #define HAVE_ARCH_UNMAPPED_AREA
157169 #define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
158
-
159
-#include <asm-generic/pgtable.h>
160170
161171 #endif /* __ASM_SH_PGTABLE_H */