Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | #ifndef __ASM_SH_PGALLOC_H |
| 3 | #define __ASM_SH_PGALLOC_H |
| 4 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 5 | #include <asm/page.h> |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 6 | |
| 7 | #define __HAVE_ARCH_PMD_ALLOC_ONE |
| 8 | #define __HAVE_ARCH_PMD_FREE |
| 9 | #define __HAVE_ARCH_PGD_FREE |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 10 | #include <asm-generic/pgalloc.h> |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 11 | |
| 12 | extern pgd_t *pgd_alloc(struct mm_struct *); |
| 13 | extern void pgd_free(struct mm_struct *mm, pgd_t *pgd); |
| 14 | |
| 15 | #if PAGETABLE_LEVELS > 2 |
| 16 | extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd); |
| 17 | extern pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address); |
| 18 | extern void pmd_free(struct mm_struct *mm, pmd_t *pmd); |
Olivier Deprez | 0e64123 | 2021-09-23 10:07:05 +0200 | [diff] [blame] | 19 | #define __pmd_free_tlb(tlb, pmdp, addr) pmd_free((tlb)->mm, (pmdp)) |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 20 | #endif |
| 21 | |
| 22 | static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, |
| 23 | pte_t *pte) |
| 24 | { |
| 25 | set_pmd(pmd, __pmd((unsigned long)pte)); |
| 26 | } |
| 27 | |
| 28 | static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, |
| 29 | pgtable_t pte) |
| 30 | { |
| 31 | set_pmd(pmd, __pmd((unsigned long)page_address(pte))); |
| 32 | } |
| 33 | #define pmd_pgtable(pmd) pmd_page(pmd) |
| 34 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 35 | #define __pte_free_tlb(tlb,pte,addr) \ |
| 36 | do { \ |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 37 | pgtable_pte_page_dtor(pte); \ |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 38 | tlb_remove_page((tlb), (pte)); \ |
| 39 | } while (0) |
| 40 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 41 | #endif /* __ASM_SH_PGALLOC_H */ |