hugetlb.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2008, 2009 Cavium Networks, Inc.
  7. */
  8. #ifndef __ASM_HUGETLB_H
  9. #define __ASM_HUGETLB_H
  10. #include <asm/page.h>
  11. #include <asm-generic/hugetlb.h>
  12. static inline int is_hugepage_only_range(struct mm_struct *mm,
  13. unsigned long addr,
  14. unsigned long len)
  15. {
  16. return 0;
  17. }
  18. static inline int prepare_hugepage_range(struct file *file,
  19. unsigned long addr,
  20. unsigned long len)
  21. {
  22. unsigned long task_size = STACK_TOP;
  23. struct hstate *h = hstate_file(file);
  24. if (len & ~huge_page_mask(h))
  25. return -EINVAL;
  26. if (addr & ~huge_page_mask(h))
  27. return -EINVAL;
  28. if (len > task_size)
  29. return -ENOMEM;
  30. if (task_size - len < addr)
  31. return -EINVAL;
  32. return 0;
  33. }
  34. static inline void hugetlb_free_pgd_range(struct mmu_gather *tlb,
  35. unsigned long addr,
  36. unsigned long end,
  37. unsigned long floor,
  38. unsigned long ceiling)
  39. {
  40. free_pgd_range(tlb, addr, end, floor, ceiling);
  41. }
  42. static inline void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
  43. pte_t *ptep, pte_t pte)
  44. {
  45. set_pte_at(mm, addr, ptep, pte);
  46. }
  47. static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
  48. unsigned long addr, pte_t *ptep)
  49. {
  50. pte_t clear;
  51. pte_t pte = *ptep;
  52. pte_val(clear) = (unsigned long)invalid_pte_table;
  53. set_pte_at(mm, addr, ptep, clear);
  54. return pte;
  55. }
  56. static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
  57. unsigned long addr, pte_t *ptep)
  58. {
  59. flush_tlb_page(vma, addr & huge_page_mask(hstate_vma(vma)));
  60. }
  61. static inline int huge_pte_none(pte_t pte)
  62. {
  63. unsigned long val = pte_val(pte) & ~_PAGE_GLOBAL;
  64. return !val || (val == (unsigned long)invalid_pte_table);
  65. }
  66. static inline pte_t huge_pte_wrprotect(pte_t pte)
  67. {
  68. return pte_wrprotect(pte);
  69. }
  70. static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
  71. unsigned long addr, pte_t *ptep)
  72. {
  73. ptep_set_wrprotect(mm, addr, ptep);
  74. }
  75. static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
  76. unsigned long addr,
  77. pte_t *ptep, pte_t pte,
  78. int dirty)
  79. {
  80. int changed = !pte_same(*ptep, pte);
  81. if (changed) {
  82. set_pte_at(vma->vm_mm, addr, ptep, pte);
  83. /*
  84. * There could be some standard sized pages in there,
  85. * get them all.
  86. */
  87. flush_tlb_range(vma, addr, addr + HPAGE_SIZE);
  88. }
  89. return changed;
  90. }
  91. static inline pte_t huge_ptep_get(pte_t *ptep)
  92. {
  93. return *ptep;
  94. }
  95. static inline void arch_clear_hugepage_flags(struct page *page)
  96. {
  97. }
  98. #endif /* __ASM_HUGETLB_H */