Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
106c992a GS |
2 | #ifndef _ASM_GENERIC_HUGETLB_H |
3 | #define _ASM_GENERIC_HUGETLB_H | |
4 | ||
679d1033 PX |
5 | #include <linux/swap.h> |
6 | #include <linux/swapops.h> | |
7 | ||
106c992a GS |
8 | static inline pte_t mk_huge_pte(struct page *page, pgprot_t pgprot) |
9 | { | |
10 | return mk_pte(page, pgprot); | |
11 | } | |
12 | ||
26794942 | 13 | static inline unsigned long huge_pte_write(pte_t pte) |
106c992a GS |
14 | { |
15 | return pte_write(pte); | |
16 | } | |
17 | ||
26794942 | 18 | static inline unsigned long huge_pte_dirty(pte_t pte) |
106c992a GS |
19 | { |
20 | return pte_dirty(pte); | |
21 | } | |
22 | ||
23 | static inline pte_t huge_pte_mkwrite(pte_t pte) | |
24 | { | |
25 | return pte_mkwrite(pte); | |
26 | } | |
27 | ||
28 | static inline pte_t huge_pte_mkdirty(pte_t pte) | |
29 | { | |
30 | return pte_mkdirty(pte); | |
31 | } | |
32 | ||
33 | static inline pte_t huge_pte_modify(pte_t pte, pgprot_t newprot) | |
34 | { | |
35 | return pte_modify(pte, newprot); | |
36 | } | |
37 | ||
229f3fa7 PX |
38 | static inline pte_t huge_pte_mkuffd_wp(pte_t pte) |
39 | { | |
40 | return pte_mkuffd_wp(pte); | |
41 | } | |
42 | ||
43 | static inline pte_t huge_pte_clear_uffd_wp(pte_t pte) | |
44 | { | |
45 | return pte_clear_uffd_wp(pte); | |
46 | } | |
47 | ||
48 | static inline int huge_pte_uffd_wp(pte_t pte) | |
49 | { | |
50 | return pte_uffd_wp(pte); | |
51 | } | |
52 | ||
d018498c | 53 | #ifndef __HAVE_ARCH_HUGE_PTE_CLEAR |
106c992a | 54 | static inline void huge_pte_clear(struct mm_struct *mm, unsigned long addr, |
9386fac3 | 55 | pte_t *ptep, unsigned long sz) |
106c992a GS |
56 | { |
57 | pte_clear(mm, addr, ptep); | |
58 | } | |
9386fac3 | 59 | #endif |
106c992a | 60 | |
1e5f50fc AG |
61 | #ifndef __HAVE_ARCH_HUGETLB_FREE_PGD_RANGE |
62 | static inline void hugetlb_free_pgd_range(struct mmu_gather *tlb, | |
63 | unsigned long addr, unsigned long end, | |
64 | unsigned long floor, unsigned long ceiling) | |
65 | { | |
66 | free_pgd_range(tlb, addr, end, floor, ceiling); | |
67 | } | |
cea685d5 | 68 | #endif |
1e5f50fc | 69 | |
cea685d5 AG |
70 | #ifndef __HAVE_ARCH_HUGE_SET_HUGE_PTE_AT |
71 | static inline void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, | |
72 | pte_t *ptep, pte_t pte) | |
73 | { | |
74 | set_pte_at(mm, addr, ptep, pte); | |
75 | } | |
1e5f50fc AG |
76 | #endif |
77 | ||
a4d83853 AG |
78 | #ifndef __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEAR |
79 | static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm, | |
80 | unsigned long addr, pte_t *ptep) | |
81 | { | |
82 | return ptep_get_and_clear(mm, addr, ptep); | |
83 | } | |
84 | #endif | |
85 | ||
fe632225 | 86 | #ifndef __HAVE_ARCH_HUGE_PTEP_CLEAR_FLUSH |
ae075629 | 87 | static inline pte_t huge_ptep_clear_flush(struct vm_area_struct *vma, |
fe632225 AG |
88 | unsigned long addr, pte_t *ptep) |
89 | { | |
ae075629 | 90 | return ptep_clear_flush(vma, addr, ptep); |
fe632225 AG |
91 | } |
92 | #endif | |
93 | ||
cae72abc AG |
94 | #ifndef __HAVE_ARCH_HUGE_PTE_NONE |
95 | static inline int huge_pte_none(pte_t pte) | |
96 | { | |
97 | return pte_none(pte); | |
98 | } | |
99 | #endif | |
100 | ||
679d1033 PX |
101 | /* Please refer to comments above pte_none_mostly() for the usage */ |
102 | static inline int huge_pte_none_mostly(pte_t pte) | |
103 | { | |
104 | return huge_pte_none(pte) || is_pte_marker(pte); | |
105 | } | |
106 | ||
c4916a00 AG |
107 | #ifndef __HAVE_ARCH_HUGE_PTE_WRPROTECT |
108 | static inline pte_t huge_pte_wrprotect(pte_t pte) | |
109 | { | |
110 | return pte_wrprotect(pte); | |
111 | } | |
112 | #endif | |
113 | ||
78d6e4e8 AG |
114 | #ifndef __HAVE_ARCH_PREPARE_HUGEPAGE_RANGE |
115 | static inline int prepare_hugepage_range(struct file *file, | |
116 | unsigned long addr, unsigned long len) | |
117 | { | |
118 | struct hstate *h = hstate_file(file); | |
119 | ||
120 | if (len & ~huge_page_mask(h)) | |
121 | return -EINVAL; | |
122 | if (addr & ~huge_page_mask(h)) | |
123 | return -EINVAL; | |
124 | ||
125 | return 0; | |
126 | } | |
127 | #endif | |
128 | ||
8e581d43 AG |
129 | #ifndef __HAVE_ARCH_HUGE_PTEP_SET_WRPROTECT |
130 | static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, | |
131 | unsigned long addr, pte_t *ptep) | |
132 | { | |
133 | ptep_set_wrprotect(mm, addr, ptep); | |
134 | } | |
135 | #endif | |
136 | ||
facf6d5b AG |
137 | #ifndef __HAVE_ARCH_HUGE_PTEP_SET_ACCESS_FLAGS |
138 | static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma, | |
139 | unsigned long addr, pte_t *ptep, | |
140 | pte_t pte, int dirty) | |
141 | { | |
142 | return ptep_set_access_flags(vma, addr, ptep, pte, dirty); | |
143 | } | |
144 | #endif | |
145 | ||
544db759 AG |
146 | #ifndef __HAVE_ARCH_HUGE_PTEP_GET |
147 | static inline pte_t huge_ptep_get(pte_t *ptep) | |
148 | { | |
481e980a | 149 | return ptep_get(ptep); |
544db759 AG |
150 | } |
151 | #endif | |
152 | ||
4eb0716e AG |
153 | #ifndef __HAVE_ARCH_GIGANTIC_PAGE_RUNTIME_SUPPORTED |
154 | static inline bool gigantic_page_runtime_supported(void) | |
155 | { | |
156 | return IS_ENABLED(CONFIG_ARCH_HAS_GIGANTIC_PAGE); | |
157 | } | |
158 | #endif /* __HAVE_ARCH_GIGANTIC_PAGE_RUNTIME_SUPPORTED */ | |
159 | ||
106c992a | 160 | #endif /* _ASM_GENERIC_HUGETLB_H */ |