0001
0002 #ifndef _ASM_GENERIC_HUGETLB_H
0003 #define _ASM_GENERIC_HUGETLB_H
0004
0005 #include <linux/swap.h>
0006 #include <linux/swapops.h>
0007
0008 static inline pte_t mk_huge_pte(struct page *page, pgprot_t pgprot)
0009 {
0010 return mk_pte(page, pgprot);
0011 }
0012
0013 static inline unsigned long huge_pte_write(pte_t pte)
0014 {
0015 return pte_write(pte);
0016 }
0017
0018 static inline unsigned long huge_pte_dirty(pte_t pte)
0019 {
0020 return pte_dirty(pte);
0021 }
0022
0023 static inline pte_t huge_pte_mkwrite(pte_t pte)
0024 {
0025 return pte_mkwrite(pte);
0026 }
0027
0028 static inline pte_t huge_pte_mkdirty(pte_t pte)
0029 {
0030 return pte_mkdirty(pte);
0031 }
0032
0033 static inline pte_t huge_pte_modify(pte_t pte, pgprot_t newprot)
0034 {
0035 return pte_modify(pte, newprot);
0036 }
0037
0038 static inline pte_t huge_pte_mkuffd_wp(pte_t pte)
0039 {
0040 return pte_mkuffd_wp(pte);
0041 }
0042
0043 static inline pte_t huge_pte_clear_uffd_wp(pte_t pte)
0044 {
0045 return pte_clear_uffd_wp(pte);
0046 }
0047
0048 static inline int huge_pte_uffd_wp(pte_t pte)
0049 {
0050 return pte_uffd_wp(pte);
0051 }
0052
0053 #ifndef __HAVE_ARCH_HUGE_PTE_CLEAR
0054 static inline void huge_pte_clear(struct mm_struct *mm, unsigned long addr,
0055 pte_t *ptep, unsigned long sz)
0056 {
0057 pte_clear(mm, addr, ptep);
0058 }
0059 #endif
0060
0061 #ifndef __HAVE_ARCH_HUGETLB_FREE_PGD_RANGE
0062 static inline void hugetlb_free_pgd_range(struct mmu_gather *tlb,
0063 unsigned long addr, unsigned long end,
0064 unsigned long floor, unsigned long ceiling)
0065 {
0066 free_pgd_range(tlb, addr, end, floor, ceiling);
0067 }
0068 #endif
0069
0070 #ifndef __HAVE_ARCH_HUGE_SET_HUGE_PTE_AT
0071 static inline void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
0072 pte_t *ptep, pte_t pte)
0073 {
0074 set_pte_at(mm, addr, ptep, pte);
0075 }
0076 #endif
0077
0078 #ifndef __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEAR
0079 static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
0080 unsigned long addr, pte_t *ptep)
0081 {
0082 return ptep_get_and_clear(mm, addr, ptep);
0083 }
0084 #endif
0085
0086 #ifndef __HAVE_ARCH_HUGE_PTEP_CLEAR_FLUSH
0087 static inline pte_t huge_ptep_clear_flush(struct vm_area_struct *vma,
0088 unsigned long addr, pte_t *ptep)
0089 {
0090 return ptep_clear_flush(vma, addr, ptep);
0091 }
0092 #endif
0093
0094 #ifndef __HAVE_ARCH_HUGE_PTE_NONE
0095 static inline int huge_pte_none(pte_t pte)
0096 {
0097 return pte_none(pte);
0098 }
0099 #endif
0100
0101
0102 static inline int huge_pte_none_mostly(pte_t pte)
0103 {
0104 return huge_pte_none(pte) || is_pte_marker(pte);
0105 }
0106
0107 #ifndef __HAVE_ARCH_HUGE_PTE_WRPROTECT
0108 static inline pte_t huge_pte_wrprotect(pte_t pte)
0109 {
0110 return pte_wrprotect(pte);
0111 }
0112 #endif
0113
0114 #ifndef __HAVE_ARCH_PREPARE_HUGEPAGE_RANGE
0115 static inline int prepare_hugepage_range(struct file *file,
0116 unsigned long addr, unsigned long len)
0117 {
0118 struct hstate *h = hstate_file(file);
0119
0120 if (len & ~huge_page_mask(h))
0121 return -EINVAL;
0122 if (addr & ~huge_page_mask(h))
0123 return -EINVAL;
0124
0125 return 0;
0126 }
0127 #endif
0128
0129 #ifndef __HAVE_ARCH_HUGE_PTEP_SET_WRPROTECT
0130 static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
0131 unsigned long addr, pte_t *ptep)
0132 {
0133 ptep_set_wrprotect(mm, addr, ptep);
0134 }
0135 #endif
0136
0137 #ifndef __HAVE_ARCH_HUGE_PTEP_SET_ACCESS_FLAGS
0138 static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
0139 unsigned long addr, pte_t *ptep,
0140 pte_t pte, int dirty)
0141 {
0142 return ptep_set_access_flags(vma, addr, ptep, pte, dirty);
0143 }
0144 #endif
0145
0146 #ifndef __HAVE_ARCH_HUGE_PTEP_GET
0147 static inline pte_t huge_ptep_get(pte_t *ptep)
0148 {
0149 return ptep_get(ptep);
0150 }
0151 #endif
0152
0153 #ifndef __HAVE_ARCH_GIGANTIC_PAGE_RUNTIME_SUPPORTED
0154 static inline bool gigantic_page_runtime_supported(void)
0155 {
0156 return IS_ENABLED(CONFIG_ARCH_HAS_GIGANTIC_PAGE);
0157 }
0158 #endif
0159
0160 #endif