hugetlb.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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 unsigned long huge_pte_write(pte_t pte)
  7. {
  8. return pte_write(pte);
  9. }
  10. static inline unsigned long huge_pte_dirty(pte_t pte)
  11. {
  12. return pte_dirty(pte);
  13. }
  14. static inline pte_t huge_pte_mkwrite(pte_t pte)
  15. {
  16. return pte_mkwrite_novma(pte);
  17. }
  18. #ifndef __HAVE_ARCH_HUGE_PTE_WRPROTECT
  19. static inline pte_t huge_pte_wrprotect(pte_t pte)
  20. {
  21. return pte_wrprotect(pte);
  22. }
  23. #endif
  24. static inline pte_t huge_pte_mkdirty(pte_t pte)
  25. {
  26. return pte_mkdirty(pte);
  27. }
  28. static inline pte_t huge_pte_modify(pte_t pte, pgprot_t newprot)
  29. {
  30. return pte_modify(pte, newprot);
  31. }
  32. #ifndef __HAVE_ARCH_HUGE_PTE_MKUFFD_WP
  33. static inline pte_t huge_pte_mkuffd_wp(pte_t pte)
  34. {
  35. return huge_pte_wrprotect(pte_mkuffd_wp(pte));
  36. }
  37. #endif
  38. #ifndef __HAVE_ARCH_HUGE_PTE_CLEAR_UFFD_WP
  39. static inline pte_t huge_pte_clear_uffd_wp(pte_t pte)
  40. {
  41. return pte_clear_uffd_wp(pte);
  42. }
  43. #endif
  44. #ifndef __HAVE_ARCH_HUGE_PTE_UFFD_WP
  45. static inline int huge_pte_uffd_wp(pte_t pte)
  46. {
  47. return pte_uffd_wp(pte);
  48. }
  49. #endif
  50. #ifndef __HAVE_ARCH_HUGE_PTE_CLEAR
  51. static inline void huge_pte_clear(struct mm_struct *mm, unsigned long addr,
  52. pte_t *ptep, unsigned long sz)
  53. {
  54. pte_clear(mm, addr, ptep);
  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, unsigned long sz)
  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, unsigned long sz)
  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. #ifndef __HAVE_ARCH_HUGE_PTEP_SET_WRPROTECT
  85. static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
  86. unsigned long addr, pte_t *ptep)
  87. {
  88. ptep_set_wrprotect(mm, addr, ptep);
  89. }
  90. #endif
  91. #ifndef __HAVE_ARCH_HUGE_PTEP_SET_ACCESS_FLAGS
  92. static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
  93. unsigned long addr, pte_t *ptep,
  94. pte_t pte, int dirty)
  95. {
  96. return ptep_set_access_flags(vma, addr, ptep, pte, dirty);
  97. }
  98. #endif
  99. #ifndef __HAVE_ARCH_HUGE_PTEP_GET
  100. static inline pte_t huge_ptep_get(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
  101. {
  102. return ptep_get(ptep);
  103. }
  104. #endif
  105. #ifndef __HAVE_ARCH_GIGANTIC_PAGE_RUNTIME_SUPPORTED
  106. static inline bool gigantic_page_runtime_supported(void)
  107. {
  108. return IS_ENABLED(CONFIG_ARCH_HAS_GIGANTIC_PAGE);
  109. }
  110. #endif /* __HAVE_ARCH_GIGANTIC_PAGE_RUNTIME_SUPPORTED */
  111. #endif /* _ASM_GENERIC_HUGETLB_H */