hugetlb.h 2.7 KB

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