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
6 * Copyright (C) 2008, 2009 Cavium Networks, Inc.
9 #ifndef __ASM_HUGETLB_H
10 #define __ASM_HUGETLB_H
14 static inline int is_hugepage_only_range(struct mm_struct *mm,
21 static inline int prepare_hugepage_range(struct file *file,
25 unsigned long task_size = STACK_TOP;
26 struct hstate *h = hstate_file(file);
28 if (len & ~huge_page_mask(h))
30 if (addr & ~huge_page_mask(h))
34 if (task_size - len < addr)
39 static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
40 unsigned long addr, pte_t *ptep)
45 pte_val(clear) = (unsigned long)invalid_pte_table;
46 set_pte_at(mm, addr, ptep, clear);
50 static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
51 unsigned long addr, pte_t *ptep)
53 flush_tlb_page(vma, addr & huge_page_mask(hstate_vma(vma)));
56 static inline int huge_pte_none(pte_t pte)
58 unsigned long val = pte_val(pte) & ~_PAGE_GLOBAL;
59 return !val || (val == (unsigned long)invalid_pte_table);
62 static inline pte_t huge_pte_wrprotect(pte_t pte)
64 return pte_wrprotect(pte);
67 static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
68 unsigned long addr, pte_t *ptep)
70 ptep_set_wrprotect(mm, addr, ptep);
73 static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
75 pte_t *ptep, pte_t pte,
78 int changed = !pte_same(*ptep, pte);
81 set_pte_at(vma->vm_mm, addr, ptep, pte);
83 * There could be some standard sized pages in there,
86 flush_tlb_range(vma, addr, addr + HPAGE_SIZE);
91 static inline pte_t huge_ptep_get(pte_t *ptep)
96 static inline void arch_clear_hugepage_flags(struct page *page)
100 #include <asm-generic/hugetlb.h>
102 #endif /* __ASM_HUGETLB_H */