hugetlb.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * IBM System z Huge TLB Page Support for Kernel.
  4. *
  5. * Copyright IBM Corp. 2008
  6. * Author(s): Gerald Schaefer <gerald.schaefer@de.ibm.com>
  7. */
  8. #ifndef _ASM_S390_HUGETLB_H
  9. #define _ASM_S390_HUGETLB_H
  10. #include <asm/page.h>
  11. #include <asm/pgtable.h>
  12. #define is_hugepage_only_range(mm, addr, len) 0
  13. #define hugetlb_free_pgd_range free_pgd_range
  14. #define hugepages_supported() (MACHINE_HAS_EDAT1)
  15. void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
  16. pte_t *ptep, pte_t pte);
  17. pte_t huge_ptep_get(pte_t *ptep);
  18. pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
  19. unsigned long addr, pte_t *ptep);
  20. /*
  21. * If the arch doesn't supply something else, assume that hugepage
  22. * size aligned regions are ok without further preparation.
  23. */
  24. static inline int prepare_hugepage_range(struct file *file,
  25. unsigned long addr, unsigned long len)
  26. {
  27. if (len & ~HPAGE_MASK)
  28. return -EINVAL;
  29. if (addr & ~HPAGE_MASK)
  30. return -EINVAL;
  31. return 0;
  32. }
  33. static inline void arch_clear_hugepage_flags(struct page *page)
  34. {
  35. clear_bit(PG_arch_1, &page->flags);
  36. }
  37. static inline void huge_pte_clear(struct mm_struct *mm, unsigned long addr,
  38. pte_t *ptep, unsigned long sz)
  39. {
  40. if ((pte_val(*ptep) & _REGION_ENTRY_TYPE_MASK) == _REGION_ENTRY_TYPE_R3)
  41. pte_val(*ptep) = _REGION3_ENTRY_EMPTY;
  42. else
  43. pte_val(*ptep) = _SEGMENT_ENTRY_EMPTY;
  44. }
  45. static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
  46. unsigned long address, pte_t *ptep)
  47. {
  48. huge_ptep_get_and_clear(vma->vm_mm, address, ptep);
  49. }
  50. static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
  51. unsigned long addr, pte_t *ptep,
  52. pte_t pte, int dirty)
  53. {
  54. int changed = !pte_same(huge_ptep_get(ptep), pte);
  55. if (changed) {
  56. huge_ptep_get_and_clear(vma->vm_mm, addr, ptep);
  57. set_huge_pte_at(vma->vm_mm, addr, ptep, pte);
  58. }
  59. return changed;
  60. }
  61. static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
  62. unsigned long addr, pte_t *ptep)
  63. {
  64. pte_t pte = huge_ptep_get_and_clear(mm, addr, ptep);
  65. set_huge_pte_at(mm, addr, ptep, pte_wrprotect(pte));
  66. }
  67. static inline pte_t mk_huge_pte(struct page *page, pgprot_t pgprot)
  68. {
  69. return mk_pte(page, pgprot);
  70. }
  71. static inline int huge_pte_none(pte_t pte)
  72. {
  73. return pte_none(pte);
  74. }
  75. static inline int huge_pte_write(pte_t pte)
  76. {
  77. return pte_write(pte);
  78. }
  79. static inline int huge_pte_dirty(pte_t pte)
  80. {
  81. return pte_dirty(pte);
  82. }
  83. static inline pte_t huge_pte_mkwrite(pte_t pte)
  84. {
  85. return pte_mkwrite(pte);
  86. }
  87. static inline pte_t huge_pte_mkdirty(pte_t pte)
  88. {
  89. return pte_mkdirty(pte);
  90. }
  91. static inline pte_t huge_pte_wrprotect(pte_t pte)
  92. {
  93. return pte_wrprotect(pte);
  94. }
  95. static inline pte_t huge_pte_modify(pte_t pte, pgprot_t newprot)
  96. {
  97. return pte_modify(pte, newprot);
  98. }
  99. #ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE
  100. static inline bool gigantic_page_supported(void) { return true; }
  101. #endif
  102. #endif /* _ASM_S390_HUGETLB_H */