hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/arch/xtensa/include/asm/pgalloc.h
....@@ -1,9 +1,6 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * include/asm-xtensa/pgalloc.h
3
- *
4
- * This program is free software; you can redistribute it and/or modify
5
- * it under the terms of the GNU General Public License version 2 as
6
- * published by the Free Software Foundation.
74 *
85 * Copyright (C) 2001-2007 Tensilica Inc.
96 */
....@@ -11,10 +8,13 @@
118 #ifndef _XTENSA_PGALLOC_H
129 #define _XTENSA_PGALLOC_H
1310
14
-#ifdef __KERNEL__
15
-
11
+#ifdef CONFIG_MMU
1612 #include <linux/highmem.h>
1713 #include <linux/slab.h>
14
+
15
+#define __HAVE_ARCH_PTE_ALLOC_ONE_KERNEL
16
+#define __HAVE_ARCH_PTE_ALLOC_ONE
17
+#include <asm-generic/pgalloc.h>
1818
1919 /*
2020 * Allocating and freeing a pmd is trivial: the 1-entry pmd is
....@@ -33,53 +33,37 @@
3333 return (pgd_t*) __get_free_pages(GFP_KERNEL | __GFP_ZERO, PGD_ORDER);
3434 }
3535
36
-static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
36
+static inline void ptes_clear(pte_t *ptep)
3737 {
38
- free_page((unsigned long)pgd);
39
-}
40
-
41
-static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
42
- unsigned long address)
43
-{
44
- pte_t *ptep;
4538 int i;
4639
47
- ptep = (pte_t *)__get_free_page(GFP_KERNEL);
40
+ for (i = 0; i < PTRS_PER_PTE; i++)
41
+ pte_clear(NULL, 0, ptep + i);
42
+}
43
+
44
+static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
45
+{
46
+ pte_t *ptep;
47
+
48
+ ptep = (pte_t *)__pte_alloc_one_kernel(mm);
4849 if (!ptep)
4950 return NULL;
50
- for (i = 0; i < 1024; i++)
51
- pte_clear(NULL, 0, ptep + i);
51
+ ptes_clear(ptep);
5252 return ptep;
5353 }
5454
55
-static inline pgtable_t pte_alloc_one(struct mm_struct *mm,
56
- unsigned long addr)
55
+static inline pgtable_t pte_alloc_one(struct mm_struct *mm)
5756 {
58
- pte_t *pte;
5957 struct page *page;
6058
61
- pte = pte_alloc_one_kernel(mm, addr);
62
- if (!pte)
59
+ page = __pte_alloc_one(mm, GFP_PGTABLE_USER);
60
+ if (!page)
6361 return NULL;
64
- page = virt_to_page(pte);
65
- if (!pgtable_page_ctor(page)) {
66
- __free_page(page);
67
- return NULL;
68
- }
62
+ ptes_clear(page_address(page));
6963 return page;
7064 }
7165
72
-static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
73
-{
74
- free_page((unsigned long)pte);
75
-}
76
-
77
-static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
78
-{
79
- pgtable_page_dtor(pte);
80
- __free_page(pte);
81
-}
8266 #define pmd_pgtable(pmd) pmd_page(pmd)
67
+#endif /* CONFIG_MMU */
8368
84
-#endif /* __KERNEL__ */
8569 #endif /* _XTENSA_PGALLOC_H */