Gerald Schaefer | 6d77907 | 2008-04-28 02:13:27 -0700 | [diff] [blame] | 1 | #ifndef _ASM_POWERPC_HUGETLB_H |
| 2 | #define _ASM_POWERPC_HUGETLB_H |
| 3 | |
| 4 | #include <asm/page.h> |
| 5 | |
David Gibson | 883a3e5 | 2009-10-26 19:24:31 +0000 | [diff] [blame] | 6 | pte_t *huge_pte_offset_and_shift(struct mm_struct *mm, |
| 7 | unsigned long addr, unsigned *shift); |
| 8 | |
David Gibson | 0895ecd | 2009-10-26 19:24:31 +0000 | [diff] [blame] | 9 | void flush_dcache_icache_hugepage(struct page *page); |
| 10 | |
Gerald Schaefer | 6d77907 | 2008-04-28 02:13:27 -0700 | [diff] [blame] | 11 | int is_hugepage_only_range(struct mm_struct *mm, unsigned long addr, |
| 12 | unsigned long len); |
| 13 | |
Jan Beulich | 42b7772 | 2008-07-23 21:27:10 -0700 | [diff] [blame] | 14 | void hugetlb_free_pgd_range(struct mmu_gather *tlb, unsigned long addr, |
Gerald Schaefer | 6d77907 | 2008-04-28 02:13:27 -0700 | [diff] [blame] | 15 | unsigned long end, unsigned long floor, |
| 16 | unsigned long ceiling); |
| 17 | |
Gerald Schaefer | 6d77907 | 2008-04-28 02:13:27 -0700 | [diff] [blame] | 18 | /* |
Mel Gorman | 3340289 | 2009-01-06 14:38:54 -0800 | [diff] [blame] | 19 | * The version of vma_mmu_pagesize() in arch/powerpc/mm/hugetlbpage.c needs |
| 20 | * to override the version in mm/hugetlb.c |
| 21 | */ |
| 22 | #define vma_mmu_pagesize vma_mmu_pagesize |
| 23 | |
| 24 | /* |
Gerald Schaefer | 6d77907 | 2008-04-28 02:13:27 -0700 | [diff] [blame] | 25 | * If the arch doesn't supply something else, assume that hugepage |
| 26 | * size aligned regions are ok without further preparation. |
| 27 | */ |
Andi Kleen | a551643 | 2008-07-23 21:27:41 -0700 | [diff] [blame] | 28 | static inline int prepare_hugepage_range(struct file *file, |
| 29 | unsigned long addr, unsigned long len) |
Gerald Schaefer | 6d77907 | 2008-04-28 02:13:27 -0700 | [diff] [blame] | 30 | { |
Jon Tollefson | 0d9ea75 | 2008-07-23 21:27:56 -0700 | [diff] [blame] | 31 | struct hstate *h = hstate_file(file); |
| 32 | if (len & ~huge_page_mask(h)) |
Gerald Schaefer | 6d77907 | 2008-04-28 02:13:27 -0700 | [diff] [blame] | 33 | return -EINVAL; |
Jon Tollefson | 0d9ea75 | 2008-07-23 21:27:56 -0700 | [diff] [blame] | 34 | if (addr & ~huge_page_mask(h)) |
Gerald Schaefer | 6d77907 | 2008-04-28 02:13:27 -0700 | [diff] [blame] | 35 | return -EINVAL; |
| 36 | return 0; |
| 37 | } |
| 38 | |
| 39 | static inline void hugetlb_prefault_arch_hook(struct mm_struct *mm) |
| 40 | { |
| 41 | } |
| 42 | |
David Gibson | 0895ecd | 2009-10-26 19:24:31 +0000 | [diff] [blame] | 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 | |
| 50 | static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm, |
| 51 | unsigned long addr, pte_t *ptep) |
| 52 | { |
| 53 | unsigned long old = pte_update(mm, addr, ptep, ~0UL, 1); |
| 54 | return __pte(old); |
| 55 | } |
| 56 | |
Gerald Schaefer | 8fe627e | 2008-04-28 02:13:28 -0700 | [diff] [blame] | 57 | static inline void huge_ptep_clear_flush(struct vm_area_struct *vma, |
| 58 | unsigned long addr, pte_t *ptep) |
| 59 | { |
David Gibson | 0895ecd | 2009-10-26 19:24:31 +0000 | [diff] [blame] | 60 | pte_t pte; |
| 61 | pte = huge_ptep_get_and_clear(vma->vm_mm, addr, ptep); |
| 62 | flush_tlb_page(vma, addr); |
Gerald Schaefer | 8fe627e | 2008-04-28 02:13:28 -0700 | [diff] [blame] | 63 | } |
| 64 | |
Gerald Schaefer | 7f2e952 | 2008-04-28 02:13:29 -0700 | [diff] [blame] | 65 | static inline int huge_pte_none(pte_t pte) |
| 66 | { |
| 67 | return pte_none(pte); |
| 68 | } |
| 69 | |
| 70 | static inline pte_t huge_pte_wrprotect(pte_t pte) |
| 71 | { |
| 72 | return pte_wrprotect(pte); |
| 73 | } |
| 74 | |
Gerald Schaefer | 7f2e952 | 2008-04-28 02:13:29 -0700 | [diff] [blame] | 75 | static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma, |
| 76 | unsigned long addr, pte_t *ptep, |
| 77 | pte_t pte, int dirty) |
| 78 | { |
| 79 | return ptep_set_access_flags(vma, addr, ptep, pte, dirty); |
| 80 | } |
| 81 | |
| 82 | static inline pte_t huge_ptep_get(pte_t *ptep) |
| 83 | { |
| 84 | return *ptep; |
| 85 | } |
| 86 | |
| 87 | static inline int arch_prepare_hugepage(struct page *page) |
| 88 | { |
| 89 | return 0; |
| 90 | } |
| 91 | |
| 92 | static inline void arch_release_hugepage(struct page *page) |
| 93 | { |
| 94 | } |
| 95 | |
Gerald Schaefer | 6d77907 | 2008-04-28 02:13:27 -0700 | [diff] [blame] | 96 | #endif /* _ASM_POWERPC_HUGETLB_H */ |