hugetlb.h 3.5 KB

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