hugetlb.h 3.4 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(pte);
  21. }
  22. static inline pte_t huge_pte_mkdirty(pte_t pte)
  23. {
  24. return pte_mkdirty(pte);
  25. }
  26. static inline pte_t huge_pte_modify(pte_t pte, pgprot_t newprot)
  27. {
  28. return pte_modify(pte, newprot);
  29. }
  30. static inline pte_t huge_pte_mkuffd_wp(pte_t pte)
  31. {
  32. return pte_mkuffd_wp(pte);
  33. }
  34. static inline pte_t huge_pte_clear_uffd_wp(pte_t pte)
  35. {
  36. return pte_clear_uffd_wp(pte);
  37. }
  38. static inline int huge_pte_uffd_wp(pte_t pte)
  39. {
  40. return pte_uffd_wp(pte);
  41. }
  42. #ifndef __HAVE_ARCH_HUGE_PTE_CLEAR
  43. static inline void huge_pte_clear(struct mm_struct *mm, unsigned long addr,
  44. pte_t *ptep, unsigned long sz)
  45. {
  46. pte_clear(mm, addr, ptep);
  47. }
  48. #endif
  49. #ifndef __HAVE_ARCH_HUGETLB_FREE_PGD_RANGE
  50. static inline void hugetlb_free_pgd_range(struct mmu_gather *tlb,
  51. unsigned long addr, unsigned long end,
  52. unsigned long floor, unsigned long ceiling)
  53. {
  54. free_pgd_range(tlb, addr, end, floor, ceiling);
  55. }
  56. #endif
  57. #ifndef __HAVE_ARCH_HUGE_SET_HUGE_PTE_AT
  58. static inline void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
  59. pte_t *ptep, pte_t pte)
  60. {
  61. set_pte_at(mm, addr, ptep, pte);
  62. }
  63. #endif
  64. #ifndef __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEAR
  65. static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
  66. unsigned long addr, pte_t *ptep)
  67. {
  68. return ptep_get_and_clear(mm, addr, ptep);
  69. }
  70. #endif
  71. #ifndef __HAVE_ARCH_HUGE_PTEP_CLEAR_FLUSH
  72. static inline pte_t huge_ptep_clear_flush(struct vm_area_struct *vma,
  73. unsigned long addr, pte_t *ptep)
  74. {
  75. return ptep_clear_flush(vma, addr, ptep);
  76. }
  77. #endif
  78. #ifndef __HAVE_ARCH_HUGE_PTE_NONE
  79. static inline int huge_pte_none(pte_t pte)
  80. {
  81. return pte_none(pte);
  82. }
  83. #endif
  84. /* Please refer to comments above pte_none_mostly() for the usage */
  85. static inline int huge_pte_none_mostly(pte_t pte)
  86. {
  87. return huge_pte_none(pte) || is_pte_marker(pte);
  88. }
  89. #ifndef __HAVE_ARCH_HUGE_PTE_WRPROTECT
  90. static inline pte_t huge_pte_wrprotect(pte_t pte)
  91. {
  92. return pte_wrprotect(pte);
  93. }
  94. #endif
  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(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 */