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
huge_pte_write(pte_t pte)8 static inline unsigned long huge_pte_write(pte_t pte)
9 {
10 return pte_write(pte);
11 }
12
huge_pte_dirty(pte_t pte)13 static inline unsigned long huge_pte_dirty(pte_t pte)
14 {
15 return pte_dirty(pte);
16 }
17
huge_pte_mkwrite(pte_t pte)18 static inline pte_t huge_pte_mkwrite(pte_t pte)
19 {
20 return pte_mkwrite_novma(pte);
21 }
22
23 #ifndef __HAVE_ARCH_HUGE_PTE_WRPROTECT
huge_pte_wrprotect(pte_t pte)24 static inline pte_t huge_pte_wrprotect(pte_t pte)
25 {
26 return pte_wrprotect(pte);
27 }
28 #endif
29
huge_pte_mkdirty(pte_t pte)30 static inline pte_t huge_pte_mkdirty(pte_t pte)
31 {
32 return pte_mkdirty(pte);
33 }
34
huge_pte_modify(pte_t pte,pgprot_t newprot)35 static inline pte_t huge_pte_modify(pte_t pte, pgprot_t newprot)
36 {
37 return pte_modify(pte, newprot);
38 }
39
40 #ifndef __HAVE_ARCH_HUGE_PTE_MKUFFD_WP
huge_pte_mkuffd_wp(pte_t pte)41 static inline pte_t huge_pte_mkuffd_wp(pte_t pte)
42 {
43 return huge_pte_wrprotect(pte_mkuffd_wp(pte));
44 }
45 #endif
46
47 #ifndef __HAVE_ARCH_HUGE_PTE_CLEAR_UFFD_WP
huge_pte_clear_uffd_wp(pte_t pte)48 static inline pte_t huge_pte_clear_uffd_wp(pte_t pte)
49 {
50 return pte_clear_uffd_wp(pte);
51 }
52 #endif
53
54 #ifndef __HAVE_ARCH_HUGE_PTE_UFFD_WP
huge_pte_uffd_wp(pte_t pte)55 static inline int huge_pte_uffd_wp(pte_t pte)
56 {
57 return pte_uffd_wp(pte);
58 }
59 #endif
60
61 #ifndef __HAVE_ARCH_HUGE_PTE_CLEAR
huge_pte_clear(struct mm_struct * mm,unsigned long addr,pte_t * ptep,unsigned long sz)62 static inline void huge_pte_clear(struct mm_struct *mm, unsigned long addr,
63 pte_t *ptep, unsigned long sz)
64 {
65 pte_clear(mm, addr, ptep);
66 }
67 #endif
68
69 #ifndef __HAVE_ARCH_HUGE_SET_HUGE_PTE_AT
set_huge_pte_at(struct mm_struct * mm,unsigned long addr,pte_t * ptep,pte_t pte,unsigned long sz)70 static inline void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
71 pte_t *ptep, pte_t pte, unsigned long sz)
72 {
73 set_pte_at(mm, addr, ptep, pte);
74 }
75 #endif
76
77 #ifndef __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEAR
huge_ptep_get_and_clear(struct mm_struct * mm,unsigned long addr,pte_t * ptep,unsigned long sz)78 static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
79 unsigned long addr, pte_t *ptep, unsigned long sz)
80 {
81 return ptep_get_and_clear(mm, addr, ptep);
82 }
83 #endif
84
85 #ifndef __HAVE_ARCH_HUGE_PTEP_CLEAR_FLUSH
huge_ptep_clear_flush(struct vm_area_struct * vma,unsigned long addr,pte_t * ptep)86 static inline pte_t huge_ptep_clear_flush(struct vm_area_struct *vma,
87 unsigned long addr, pte_t *ptep)
88 {
89 return ptep_clear_flush(vma, addr, ptep);
90 }
91 #endif
92
93 #ifndef __HAVE_ARCH_HUGE_PTE_NONE
huge_pte_none(pte_t pte)94 static inline int huge_pte_none(pte_t pte)
95 {
96 return pte_none(pte);
97 }
98 #endif
99
100 /* Please refer to comments above pte_none_mostly() for the usage */
101 #ifndef __HAVE_ARCH_HUGE_PTE_NONE_MOSTLY
huge_pte_none_mostly(pte_t pte)102 static inline int huge_pte_none_mostly(pte_t pte)
103 {
104 return huge_pte_none(pte) || is_pte_marker(pte);
105 }
106 #endif
107
108 #ifndef __HAVE_ARCH_HUGE_PTEP_SET_WRPROTECT
huge_ptep_set_wrprotect(struct mm_struct * mm,unsigned long addr,pte_t * ptep)109 static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
110 unsigned long addr, pte_t *ptep)
111 {
112 ptep_set_wrprotect(mm, addr, ptep);
113 }
114 #endif
115
116 #ifndef __HAVE_ARCH_HUGE_PTEP_SET_ACCESS_FLAGS
huge_ptep_set_access_flags(struct vm_area_struct * vma,unsigned long addr,pte_t * ptep,pte_t pte,int dirty)117 static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
118 unsigned long addr, pte_t *ptep,
119 pte_t pte, int dirty)
120 {
121 return ptep_set_access_flags(vma, addr, ptep, pte, dirty);
122 }
123 #endif
124
125 #ifndef __HAVE_ARCH_HUGE_PTEP_GET
huge_ptep_get(struct mm_struct * mm,unsigned long addr,pte_t * ptep)126 static inline pte_t huge_ptep_get(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
127 {
128 return ptep_get(ptep);
129 }
130 #endif
131
132 #ifndef __HAVE_ARCH_GIGANTIC_PAGE_RUNTIME_SUPPORTED
gigantic_page_runtime_supported(void)133 static inline bool gigantic_page_runtime_supported(void)
134 {
135 return IS_ENABLED(CONFIG_ARCH_HAS_GIGANTIC_PAGE);
136 }
137 #endif /* __HAVE_ARCH_GIGANTIC_PAGE_RUNTIME_SUPPORTED */
138
139 #endif /* _ASM_GENERIC_HUGETLB_H */
140