hugetlb.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. }
  62. static inline int huge_pte_none(pte_t pte)
  63. {
  64. unsigned long val = pte_val(pte) & ~_PAGE_GLOBAL;
  65. return !val || (val == (unsigned long)invalid_pte_table);
  66. }
  67. static inline pte_t huge_pte_wrprotect(pte_t pte)
  68. {
  69. return pte_wrprotect(pte);
  70. }
  71. static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
  72. unsigned long addr, pte_t *ptep)
  73. {
  74. ptep_set_wrprotect(mm, addr, ptep);
  75. }
  76. static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
  77. unsigned long addr,
  78. pte_t *ptep, pte_t pte,
  79. int dirty)
  80. {
  81. return ptep_set_access_flags(vma, addr, ptep, pte, dirty);
  82. }
  83. static inline pte_t huge_ptep_get(pte_t *ptep)
  84. {
  85. return *ptep;
  86. }
  87. static inline int arch_prepare_hugepage(struct page *page)
  88. {
  89. return 0;
  90. }
  91. static inline void arch_release_hugepage(struct page *page)
  92. {
  93. }
  94. #endif /* __ASM_HUGETLB_H */