diff options
Diffstat (limited to 'arch/riscv/include/asm/pgtable.h')
-rw-r--r-- | arch/riscv/include/asm/pgtable.h | 58 |
1 files changed, 32 insertions, 26 deletions
diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index 3399257780b2..2cbd92ed1629 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h | |||
@@ -178,28 +178,6 @@ static inline pte_t *pte_offset_kernel(pmd_t *pmd, unsigned long addr) | |||
178 | #define pte_offset_map(dir, addr) pte_offset_kernel((dir), (addr)) | 178 | #define pte_offset_map(dir, addr) pte_offset_kernel((dir), (addr)) |
179 | #define pte_unmap(pte) ((void)(pte)) | 179 | #define pte_unmap(pte) ((void)(pte)) |
180 | 180 | ||
181 | /* | ||
182 | * Certain architectures need to do special things when PTEs within | ||
183 | * a page table are directly modified. Thus, the following hook is | ||
184 | * made available. | ||
185 | */ | ||
186 | static inline void set_pte(pte_t *ptep, pte_t pteval) | ||
187 | { | ||
188 | *ptep = pteval; | ||
189 | } | ||
190 | |||
191 | static inline void set_pte_at(struct mm_struct *mm, | ||
192 | unsigned long addr, pte_t *ptep, pte_t pteval) | ||
193 | { | ||
194 | set_pte(ptep, pteval); | ||
195 | } | ||
196 | |||
197 | static inline void pte_clear(struct mm_struct *mm, | ||
198 | unsigned long addr, pte_t *ptep) | ||
199 | { | ||
200 | set_pte_at(mm, addr, ptep, __pte(0)); | ||
201 | } | ||
202 | |||
203 | static inline int pte_present(pte_t pte) | 181 | static inline int pte_present(pte_t pte) |
204 | { | 182 | { |
205 | return (pte_val(pte) & _PAGE_PRESENT); | 183 | return (pte_val(pte) & _PAGE_PRESENT); |
@@ -210,21 +188,22 @@ static inline int pte_none(pte_t pte) | |||
210 | return (pte_val(pte) == 0); | 188 | return (pte_val(pte) == 0); |
211 | } | 189 | } |
212 | 190 | ||
213 | /* static inline int pte_read(pte_t pte) */ | ||
214 | |||
215 | static inline int pte_write(pte_t pte) | 191 | static inline int pte_write(pte_t pte) |
216 | { | 192 | { |
217 | return pte_val(pte) & _PAGE_WRITE; | 193 | return pte_val(pte) & _PAGE_WRITE; |
218 | } | 194 | } |
219 | 195 | ||
196 | static inline int pte_exec(pte_t pte) | ||
197 | { | ||
198 | return pte_val(pte) & _PAGE_EXEC; | ||
199 | } | ||
200 | |||
220 | static inline int pte_huge(pte_t pte) | 201 | static inline int pte_huge(pte_t pte) |
221 | { | 202 | { |
222 | return pte_present(pte) | 203 | return pte_present(pte) |
223 | && (pte_val(pte) & (_PAGE_READ | _PAGE_WRITE | _PAGE_EXEC)); | 204 | && (pte_val(pte) & (_PAGE_READ | _PAGE_WRITE | _PAGE_EXEC)); |
224 | } | 205 | } |
225 | 206 | ||
226 | /* static inline int pte_exec(pte_t pte) */ | ||
227 | |||
228 | static inline int pte_dirty(pte_t pte) | 207 | static inline int pte_dirty(pte_t pte) |
229 | { | 208 | { |
230 | return pte_val(pte) & _PAGE_DIRTY; | 209 | return pte_val(pte) & _PAGE_DIRTY; |
@@ -311,6 +290,33 @@ static inline int pte_same(pte_t pte_a, pte_t pte_b) | |||
311 | return pte_val(pte_a) == pte_val(pte_b); | 290 | return pte_val(pte_a) == pte_val(pte_b); |
312 | } | 291 | } |
313 | 292 | ||
293 | /* | ||
294 | * Certain architectures need to do special things when PTEs within | ||
295 | * a page table are directly modified. Thus, the following hook is | ||
296 | * made available. | ||
297 | */ | ||
298 | static inline void set_pte(pte_t *ptep, pte_t pteval) | ||
299 | { | ||
300 | *ptep = pteval; | ||
301 | } | ||
302 | |||
303 | void flush_icache_pte(pte_t pte); | ||
304 | |||
305 | static inline void set_pte_at(struct mm_struct *mm, | ||
306 | unsigned long addr, pte_t *ptep, pte_t pteval) | ||
307 | { | ||
308 | if (pte_present(pteval) && pte_exec(pteval)) | ||
309 | flush_icache_pte(pteval); | ||
310 | |||
311 | set_pte(ptep, pteval); | ||
312 | } | ||
313 | |||
314 | static inline void pte_clear(struct mm_struct *mm, | ||
315 | unsigned long addr, pte_t *ptep) | ||
316 | { | ||
317 | set_pte_at(mm, addr, ptep, __pte(0)); | ||
318 | } | ||
319 | |||
314 | #define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS | 320 | #define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS |
315 | static inline int ptep_set_access_flags(struct vm_area_struct *vma, | 321 | static inline int ptep_set_access_flags(struct vm_area_struct *vma, |
316 | unsigned long address, pte_t *ptep, | 322 | unsigned long address, pte_t *ptep, |