hugetlb.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. static inline int is_hugepage_only_range(struct mm_struct *mm,
  12. unsigned long addr,
  13. unsigned long len)
  14. {
  15. return 0;
  16. }
  17. static inline int prepare_hugepage_range(struct file *file,
  18. unsigned long addr,
  19. unsigned long len)
  20. {
  21. unsigned long task_size = STACK_TOP;
  22. struct hstate *h = hstate_file(file);
  23. if (len & ~huge_page_mask(h))
  24. return -EINVAL;
  25. if (addr & ~huge_page_mask(h))
  26. return -EINVAL;
  27. if (len > task_size)
  28. return -ENOMEM;
  29. if (task_size - len < addr)
  30. return -EINVAL;
  31. return 0;
  32. }
  33. static inline void hugetlb_prefault_arch_hook(struct mm_struct *mm)
  34. {
  35. }
  36. static inline void hugetlb_free_pgd_range(struct mmu_gather *tlb,
  37. unsigned long addr,
  38. unsigned long end,
  39. unsigned long floor,
  40. unsigned long ceiling)
  41. {
  42. free_pgd_range(tlb, addr, end, floor, ceiling);
  43. }
  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. static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
  50. unsigned long addr, pte_t *ptep)
  51. {
  52. pte_t clear;
  53. pte_t pte = *ptep;
  54. pte_val(clear) = (unsigned long)invalid_pte_table;
  55. set_pte_at(mm, addr, ptep, clear);
  56. return pte;
  57. }
  58. static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
  59. unsigned long addr, pte_t *ptep)
  60. {
  61. flush_tlb_page(vma, addr & huge_page_mask(hstate_vma(vma)));
  62. }
  63. static inline int huge_pte_none(pte_t pte)
  64. {
  65. unsigned long val = pte_val(pte) & ~_PAGE_GLOBAL;
  66. return !val || (val == (unsigned long)invalid_pte_table);
  67. }
  68. static inline pte_t huge_pte_wrprotect(pte_t pte)
  69. {
  70. return pte_wrprotect(pte);
  71. }
  72. static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
  73. unsigned long addr, pte_t *ptep)
  74. {
  75. ptep_set_wrprotect(mm, addr, ptep);
  76. }
  77. static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
  78. unsigned long addr,
  79. pte_t *ptep, pte_t pte,
  80. int dirty)
  81. {
  82. return ptep_set_access_flags(vma, addr, ptep, pte, dirty);
  83. }
  84. static inline pte_t huge_ptep_get(pte_t *ptep)
  85. {
  86. return *ptep;
  87. }
  88. static inline int arch_prepare_hugepage(struct page *page)
  89. {
  90. return 0;
  91. }
  92. static inline void arch_release_hugepage(struct page *page)
  93. {
  94. }
  95. #endif /* __ASM_HUGETLB_H */