hugetlb.h 3.0 KB

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