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