hugetlb.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_X86_HUGETLB_H
  3. #define _ASM_X86_HUGETLB_H
  4. #include <asm/page.h>
  5. #include <asm-generic/hugetlb.h>
  6. #define hugepages_supported() boot_cpu_has(X86_FEATURE_PSE)
  7. static inline int is_hugepage_only_range(struct mm_struct *mm,
  8. unsigned long addr,
  9. unsigned long len) {
  10. return 0;
  11. }
  12. /*
  13. * If the arch doesn't supply something else, assume that hugepage
  14. * size aligned regions are ok without further preparation.
  15. */
  16. static inline int prepare_hugepage_range(struct file *file,
  17. unsigned long addr, unsigned long len)
  18. {
  19. struct hstate *h = hstate_file(file);
  20. if (len & ~huge_page_mask(h))
  21. return -EINVAL;
  22. if (addr & ~huge_page_mask(h))
  23. return -EINVAL;
  24. return 0;
  25. }
  26. static inline void hugetlb_free_pgd_range(struct mmu_gather *tlb,
  27. unsigned long addr, unsigned long end,
  28. unsigned long floor,
  29. unsigned long ceiling)
  30. {
  31. free_pgd_range(tlb, addr, end, floor, ceiling);
  32. }
  33. static inline void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
  34. pte_t *ptep, pte_t pte)
  35. {
  36. set_pte_at(mm, addr, ptep, pte);
  37. }
  38. static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
  39. unsigned long addr, pte_t *ptep)
  40. {
  41. return ptep_get_and_clear(mm, addr, ptep);
  42. }
  43. static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
  44. unsigned long addr, pte_t *ptep)
  45. {
  46. ptep_clear_flush(vma, addr, ptep);
  47. }
  48. static inline int huge_pte_none(pte_t pte)
  49. {
  50. return pte_none(pte);
  51. }
  52. static inline pte_t huge_pte_wrprotect(pte_t pte)
  53. {
  54. return pte_wrprotect(pte);
  55. }
  56. static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
  57. unsigned long addr, pte_t *ptep)
  58. {
  59. ptep_set_wrprotect(mm, addr, ptep);
  60. }
  61. static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
  62. unsigned long addr, pte_t *ptep,
  63. pte_t pte, int dirty)
  64. {
  65. return ptep_set_access_flags(vma, addr, ptep, pte, dirty);
  66. }
  67. static inline pte_t huge_ptep_get(pte_t *ptep)
  68. {
  69. return *ptep;
  70. }
  71. static inline void arch_clear_hugepage_flags(struct page *page)
  72. {
  73. }
  74. #ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE
  75. static inline bool gigantic_page_supported(void) { return true; }
  76. #endif
  77. #endif /* _ASM_X86_HUGETLB_H */