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