Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _ASM_SCORE_PGALLOC_H
3#define _ASM_SCORE_PGALLOC_H
4
5#include <linux/mm.h>
6#include <linux/highmem.h>
7static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
8 pte_t *pte)
9{
10 set_pmd(pmd, __pmd((unsigned long)pte));
11}
12
13static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
14 pgtable_t pte)
15{
16 set_pmd(pmd, __pmd((unsigned long)page_address(pte)));
17}
18
19#define pmd_pgtable(pmd) pmd_page(pmd)
20
21static inline pgd_t *pgd_alloc(struct mm_struct *mm)
22{
23 pgd_t *ret, *init;
24
25 ret = (pgd_t *) __get_free_pages(GFP_KERNEL, PGD_ORDER);
26 if (ret) {
27 init = pgd_offset(&init_mm, 0UL);
28 pgd_init((unsigned long)ret);
29 memcpy(ret + USER_PTRS_PER_PGD, init + USER_PTRS_PER_PGD,
30 (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
31 }
32
33 return ret;
34}
35
36static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
37{
38 free_pages((unsigned long)pgd, PGD_ORDER);
39}
40
41static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
42 unsigned long address)
43{
44 pte_t *pte;
45
46 pte = (pte_t *) __get_free_pages(GFP_KERNEL|__GFP_ZERO, PTE_ORDER);
47
48 return pte;
49}
50
51static inline struct page *pte_alloc_one(struct mm_struct *mm,
52 unsigned long address)
53{
54 struct page *pte;
55
56 pte = alloc_pages(GFP_KERNEL, PTE_ORDER);
57 if (!pte)
58 return NULL;
59 clear_highpage(pte);
60 if (!pgtable_page_ctor(pte)) {
61 __free_page(pte);
62 return NULL;
63 }
64 return pte;
65}
66
67static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
68{
69 free_pages((unsigned long)pte, PTE_ORDER);
70}
71
72static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
73{
74 pgtable_page_dtor(pte);
75 __free_pages(pte, PTE_ORDER);
76}
77
78#define __pte_free_tlb(tlb, pte, buf) \
79do { \
80 pgtable_page_dtor(pte); \
81 tlb_remove_page((tlb), pte); \
82} while (0)
83
84#define check_pgt_cache() do {} while (0)
85
86#endif /* _ASM_SCORE_PGALLOC_H */