1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19#ifndef __ASM_PGALLOC_H
20#define __ASM_PGALLOC_H
21
22#include <asm/pgtable-hwdef.h>
23#include <asm/processor.h>
24#include <asm/cacheflush.h>
25#include <asm/tlbflush.h>
26
27#define check_pgt_cache() do { } while (0)
28
29#ifndef CONFIG_ARM64_64K_PAGES
30
31static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
32{
33 return (pmd_t *)get_zeroed_page(GFP_KERNEL | __GFP_REPEAT);
34}
35
36static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
37{
38 BUG_ON((unsigned long)pmd & (PAGE_SIZE-1));
39 free_page((unsigned long)pmd);
40}
41
42static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
43{
44 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
45}
46
47#endif
48
49extern pgd_t *pgd_alloc(struct mm_struct *mm);
50extern void pgd_free(struct mm_struct *mm, pgd_t *pgd);
51
52#define PGALLOC_GFP (GFP_KERNEL | __GFP_NOTRACK | __GFP_REPEAT | __GFP_ZERO)
53
54static inline pte_t *
55pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr)
56{
57 return (pte_t *)__get_free_page(PGALLOC_GFP);
58}
59
60static inline pgtable_t
61pte_alloc_one(struct mm_struct *mm, unsigned long addr)
62{
63 struct page *pte;
64
65 pte = alloc_pages(PGALLOC_GFP, 0);
66 if (pte)
67 pgtable_page_ctor(pte);
68
69 return pte;
70}
71
72
73
74
75static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
76{
77 if (pte)
78 free_page((unsigned long)pte);
79}
80
81static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
82{
83 pgtable_page_dtor(pte);
84 __free_page(pte);
85}
86
87static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
88 pmdval_t prot)
89{
90 set_pmd(pmdp, __pmd(pte | prot));
91}
92
93
94
95
96
97static inline void
98pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
99{
100
101
102
103 __pmd_populate(pmdp, __pa(ptep), PMD_TYPE_TABLE);
104}
105
106static inline void
107pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
108{
109 __pmd_populate(pmdp, page_to_phys(ptep), PMD_TYPE_TABLE);
110}
111#define pmd_pgtable(pmd) pmd_page(pmd)
112
113#endif
114