Merge branch 'akpm' (patches from Andrew)
[firefly-linux-kernel-4.4.55.git] / arch / s390 / include / asm / hugetlb.h
1 /*
2  *  IBM System z Huge TLB Page Support for Kernel.
3  *
4  *    Copyright IBM Corp. 2008
5  *    Author(s): Gerald Schaefer <gerald.schaefer@de.ibm.com>
6  */
7
8 #ifndef _ASM_S390_HUGETLB_H
9 #define _ASM_S390_HUGETLB_H
10
11 #include <asm/page.h>
12 #include <asm/pgtable.h>
13
14
15 #define is_hugepage_only_range(mm, addr, len)   0
16 #define hugetlb_free_pgd_range                  free_pgd_range
17
18 void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
19                      pte_t *ptep, pte_t pte);
20 pte_t huge_ptep_get(pte_t *ptep);
21 pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
22                               unsigned long addr, pte_t *ptep);
23
24 /*
25  * If the arch doesn't supply something else, assume that hugepage
26  * size aligned regions are ok without further preparation.
27  */
28 static inline int prepare_hugepage_range(struct file *file,
29                         unsigned long addr, unsigned long len)
30 {
31         if (len & ~HPAGE_MASK)
32                 return -EINVAL;
33         if (addr & ~HPAGE_MASK)
34                 return -EINVAL;
35         return 0;
36 }
37
38 #define arch_clear_hugepage_flags(page)         do { } while (0)
39
40 int arch_prepare_hugepage(struct page *page);
41 void arch_release_hugepage(struct page *page);
42
43 static inline void huge_pte_clear(struct mm_struct *mm, unsigned long addr,
44                                   pte_t *ptep)
45 {
46         pte_val(*ptep) = _SEGMENT_ENTRY_EMPTY;
47 }
48
49 static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
50                                          unsigned long address, pte_t *ptep)
51 {
52         huge_ptep_get_and_clear(vma->vm_mm, address, ptep);
53 }
54
55 static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
56                                              unsigned long addr, pte_t *ptep,
57                                              pte_t pte, int dirty)
58 {
59         int changed = !pte_same(huge_ptep_get(ptep), pte);
60         if (changed) {
61                 huge_ptep_get_and_clear(vma->vm_mm, addr, ptep);
62                 set_huge_pte_at(vma->vm_mm, addr, ptep, pte);
63         }
64         return changed;
65 }
66
67 static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
68                                            unsigned long addr, pte_t *ptep)
69 {
70         pte_t pte = huge_ptep_get_and_clear(mm, addr, ptep);
71         set_huge_pte_at(mm, addr, ptep, pte_wrprotect(pte));
72 }
73
74 static inline pte_t mk_huge_pte(struct page *page, pgprot_t pgprot)
75 {
76         return mk_pte(page, pgprot);
77 }
78
79 static inline int huge_pte_none(pte_t pte)
80 {
81         return pte_none(pte);
82 }
83
84 static inline int huge_pte_write(pte_t pte)
85 {
86         return pte_write(pte);
87 }
88
89 static inline int huge_pte_dirty(pte_t pte)
90 {
91         return pte_dirty(pte);
92 }
93
94 static inline pte_t huge_pte_mkwrite(pte_t pte)
95 {
96         return pte_mkwrite(pte);
97 }
98
99 static inline pte_t huge_pte_mkdirty(pte_t pte)
100 {
101         return pte_mkdirty(pte);
102 }
103
104 static inline pte_t huge_pte_wrprotect(pte_t pte)
105 {
106         return pte_wrprotect(pte);
107 }
108
109 static inline pte_t huge_pte_modify(pte_t pte, pgprot_t newprot)
110 {
111         return pte_modify(pte, newprot);
112 }
113
114 #endif /* _ASM_S390_HUGETLB_H */