hugetlb: introduce generic version of set_huge_pte_at()
[muen/linux.git] / arch / sh / include / asm / hugetlb.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_SH_HUGETLB_H
3 #define _ASM_SH_HUGETLB_H
4
5 #include <asm/cacheflush.h>
6 #include <asm/page.h>
7
8 static inline int is_hugepage_only_range(struct mm_struct *mm,
9                                          unsigned long addr,
10                                          unsigned long len) {
11         return 0;
12 }
13
14 /*
15  * If the arch doesn't supply something else, assume that hugepage
16  * size aligned regions are ok without further preparation.
17  */
18 static inline int prepare_hugepage_range(struct file *file,
19                         unsigned long addr, unsigned long len)
20 {
21         if (len & ~HPAGE_MASK)
22                 return -EINVAL;
23         if (addr & ~HPAGE_MASK)
24                 return -EINVAL;
25         return 0;
26 }
27
28 static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
29                                             unsigned long addr, pte_t *ptep)
30 {
31         return ptep_get_and_clear(mm, addr, ptep);
32 }
33
34 static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
35                                          unsigned long addr, pte_t *ptep)
36 {
37 }
38
39 static inline int huge_pte_none(pte_t pte)
40 {
41         return pte_none(pte);
42 }
43
44 static inline pte_t huge_pte_wrprotect(pte_t pte)
45 {
46         return pte_wrprotect(pte);
47 }
48
49 static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
50                                            unsigned long addr, pte_t *ptep)
51 {
52         ptep_set_wrprotect(mm, addr, 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         return ptep_set_access_flags(vma, addr, ptep, pte, dirty);
60 }
61
62 static inline pte_t huge_ptep_get(pte_t *ptep)
63 {
64         return *ptep;
65 }
66
67 static inline void arch_clear_hugepage_flags(struct page *page)
68 {
69         clear_bit(PG_dcache_clean, &page->flags);
70 }
71
72 #include <asm-generic/hugetlb.h>
73
74 #endif /* _ASM_SH_HUGETLB_H */