.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
---|
1 | 2 | /* |
---|
2 | 3 | * 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. |
---|
7 | 4 | * |
---|
8 | 5 | * Copyright (C) 2001-2007 Tensilica Inc. |
---|
9 | 6 | */ |
---|
.. | .. |
---|
11 | 8 | #ifndef _XTENSA_PGALLOC_H |
---|
12 | 9 | #define _XTENSA_PGALLOC_H |
---|
13 | 10 | |
---|
14 | | -#ifdef __KERNEL__ |
---|
15 | | - |
---|
| 11 | +#ifdef CONFIG_MMU |
---|
16 | 12 | #include <linux/highmem.h> |
---|
17 | 13 | #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> |
---|
18 | 18 | |
---|
19 | 19 | /* |
---|
20 | 20 | * Allocating and freeing a pmd is trivial: the 1-entry pmd is |
---|
.. | .. |
---|
33 | 33 | return (pgd_t*) __get_free_pages(GFP_KERNEL | __GFP_ZERO, PGD_ORDER); |
---|
34 | 34 | } |
---|
35 | 35 | |
---|
36 | | -static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd) |
---|
| 36 | +static inline void ptes_clear(pte_t *ptep) |
---|
37 | 37 | { |
---|
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; |
---|
45 | 38 | int i; |
---|
46 | 39 | |
---|
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); |
---|
48 | 49 | if (!ptep) |
---|
49 | 50 | return NULL; |
---|
50 | | - for (i = 0; i < 1024; i++) |
---|
51 | | - pte_clear(NULL, 0, ptep + i); |
---|
| 51 | + ptes_clear(ptep); |
---|
52 | 52 | return ptep; |
---|
53 | 53 | } |
---|
54 | 54 | |
---|
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) |
---|
57 | 56 | { |
---|
58 | | - pte_t *pte; |
---|
59 | 57 | struct page *page; |
---|
60 | 58 | |
---|
61 | | - pte = pte_alloc_one_kernel(mm, addr); |
---|
62 | | - if (!pte) |
---|
| 59 | + page = __pte_alloc_one(mm, GFP_PGTABLE_USER); |
---|
| 60 | + if (!page) |
---|
63 | 61 | 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)); |
---|
69 | 63 | return page; |
---|
70 | 64 | } |
---|
71 | 65 | |
---|
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 | | -} |
---|
82 | 66 | #define pmd_pgtable(pmd) pmd_page(pmd) |
---|
| 67 | +#endif /* CONFIG_MMU */ |
---|
83 | 68 | |
---|
84 | | -#endif /* __KERNEL__ */ |
---|
85 | 69 | #endif /* _XTENSA_PGALLOC_H */ |
---|