.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
---|
1 | 2 | /* |
---|
2 | 3 | * arch/arm/include/asm/pgalloc.h |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2000-2001 Russell King |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or modify |
---|
7 | | - * it under the terms of the GNU General Public License version 2 as |
---|
8 | | - * published by the Free Software Foundation. |
---|
9 | 6 | */ |
---|
10 | 7 | #ifndef _ASMARM_PGALLOC_H |
---|
11 | 8 | #define _ASMARM_PGALLOC_H |
---|
.. | .. |
---|
18 | 15 | #include <asm/cacheflush.h> |
---|
19 | 16 | #include <asm/tlbflush.h> |
---|
20 | 17 | |
---|
21 | | -#define check_pgt_cache() do { } while (0) |
---|
22 | | - |
---|
23 | 18 | #ifdef CONFIG_MMU |
---|
24 | 19 | |
---|
25 | 20 | #define _PAGE_USER_TABLE (PMD_TYPE_TABLE | PMD_BIT4 | PMD_DOMAIN(DOMAIN_USER)) |
---|
26 | 21 | #define _PAGE_KERNEL_TABLE (PMD_TYPE_TABLE | PMD_BIT4 | PMD_DOMAIN(DOMAIN_KERNEL)) |
---|
27 | 22 | |
---|
28 | 23 | #ifdef CONFIG_ARM_LPAE |
---|
29 | | - |
---|
30 | | -static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr) |
---|
31 | | -{ |
---|
32 | | - return (pmd_t *)get_zeroed_page(GFP_KERNEL); |
---|
33 | | -} |
---|
34 | | - |
---|
35 | | -static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd) |
---|
36 | | -{ |
---|
37 | | - BUG_ON((unsigned long)pmd & (PAGE_SIZE-1)); |
---|
38 | | - free_page((unsigned long)pmd); |
---|
39 | | -} |
---|
40 | 24 | |
---|
41 | 25 | static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd) |
---|
42 | 26 | { |
---|
.. | .. |
---|
56 | 40 | |
---|
57 | 41 | extern pgd_t *pgd_alloc(struct mm_struct *mm); |
---|
58 | 42 | extern void pgd_free(struct mm_struct *mm, pgd_t *pgd); |
---|
59 | | - |
---|
60 | | -#define PGALLOC_GFP (GFP_KERNEL | __GFP_ZERO) |
---|
61 | 43 | |
---|
62 | 44 | static inline void clean_pte_table(pte_t *pte) |
---|
63 | 45 | { |
---|
.. | .. |
---|
80 | 62 | * | h/w pt 1 | |
---|
81 | 63 | * +------------+ |
---|
82 | 64 | */ |
---|
83 | | -static inline pte_t * |
---|
84 | | -pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr) |
---|
85 | | -{ |
---|
86 | | - pte_t *pte; |
---|
87 | 65 | |
---|
88 | | - pte = (pte_t *)__get_free_page(PGALLOC_GFP); |
---|
| 66 | +#define __HAVE_ARCH_PTE_ALLOC_ONE_KERNEL |
---|
| 67 | +#define __HAVE_ARCH_PTE_ALLOC_ONE |
---|
| 68 | +#define __HAVE_ARCH_PGD_FREE |
---|
| 69 | +#include <asm-generic/pgalloc.h> |
---|
| 70 | + |
---|
| 71 | +static inline pte_t * |
---|
| 72 | +pte_alloc_one_kernel(struct mm_struct *mm) |
---|
| 73 | +{ |
---|
| 74 | + pte_t *pte = __pte_alloc_one_kernel(mm); |
---|
| 75 | + |
---|
89 | 76 | if (pte) |
---|
90 | 77 | clean_pte_table(pte); |
---|
91 | 78 | |
---|
92 | 79 | return pte; |
---|
93 | 80 | } |
---|
94 | 81 | |
---|
| 82 | +#ifdef CONFIG_HIGHPTE |
---|
| 83 | +#define PGTABLE_HIGHMEM __GFP_HIGHMEM |
---|
| 84 | +#else |
---|
| 85 | +#define PGTABLE_HIGHMEM 0 |
---|
| 86 | +#endif |
---|
| 87 | + |
---|
95 | 88 | static inline pgtable_t |
---|
96 | | -pte_alloc_one(struct mm_struct *mm, unsigned long addr) |
---|
| 89 | +pte_alloc_one(struct mm_struct *mm) |
---|
97 | 90 | { |
---|
98 | 91 | struct page *pte; |
---|
99 | 92 | |
---|
100 | | -#ifdef CONFIG_HIGHPTE |
---|
101 | | - pte = alloc_pages(PGALLOC_GFP | __GFP_HIGHMEM, 0); |
---|
102 | | -#else |
---|
103 | | - pte = alloc_pages(PGALLOC_GFP, 0); |
---|
104 | | -#endif |
---|
| 93 | + pte = __pte_alloc_one(mm, GFP_PGTABLE_USER | PGTABLE_HIGHMEM); |
---|
105 | 94 | if (!pte) |
---|
106 | 95 | return NULL; |
---|
107 | 96 | if (!PageHighMem(pte)) |
---|
108 | 97 | clean_pte_table(page_address(pte)); |
---|
109 | | - if (!pgtable_page_ctor(pte)) { |
---|
110 | | - __free_page(pte); |
---|
111 | | - return NULL; |
---|
112 | | - } |
---|
113 | 98 | return pte; |
---|
114 | | -} |
---|
115 | | - |
---|
116 | | -/* |
---|
117 | | - * Free one PTE table. |
---|
118 | | - */ |
---|
119 | | -static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) |
---|
120 | | -{ |
---|
121 | | - if (pte) |
---|
122 | | - free_page((unsigned long)pte); |
---|
123 | | -} |
---|
124 | | - |
---|
125 | | -static inline void pte_free(struct mm_struct *mm, pgtable_t pte) |
---|
126 | | -{ |
---|
127 | | - pgtable_page_dtor(pte); |
---|
128 | | - __free_page(pte); |
---|
129 | 99 | } |
---|
130 | 100 | |
---|
131 | 101 | static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte, |
---|