xref: /linux/arch/arm64/include/asm/hugetlb.h (revision fdfc374af5dc345fbb9686921fa60176c1c41da0)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * arch/arm64/include/asm/hugetlb.h
4  *
5  * Copyright (C) 2013 Linaro Ltd.
6  *
7  * Based on arch/x86/include/asm/hugetlb.h
8  */
9 
10 #ifndef __ASM_HUGETLB_H
11 #define __ASM_HUGETLB_H
12 
13 #include <asm/cacheflush.h>
14 #include <asm/page.h>
15 
16 #ifdef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION
17 #define arch_hugetlb_migration_supported arch_hugetlb_migration_supported
18 extern bool arch_hugetlb_migration_supported(struct hstate *h);
19 #endif
20 
21 static inline void arch_clear_hugepage_flags(struct page *page)
22 {
23 	clear_bit(PG_dcache_clean, &page->flags);
24 }
25 #define arch_clear_hugepage_flags arch_clear_hugepage_flags
26 
27 pte_t arch_make_huge_pte(pte_t entry, unsigned int shift, vm_flags_t flags);
28 #define arch_make_huge_pte arch_make_huge_pte
29 #define __HAVE_ARCH_HUGE_SET_HUGE_PTE_AT
30 extern void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
31 			    pte_t *ptep, pte_t pte);
32 #define __HAVE_ARCH_HUGE_PTEP_SET_ACCESS_FLAGS
33 extern int huge_ptep_set_access_flags(struct vm_area_struct *vma,
34 				      unsigned long addr, pte_t *ptep,
35 				      pte_t pte, int dirty);
36 #define __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEAR
37 extern pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
38 				     unsigned long addr, pte_t *ptep);
39 #define __HAVE_ARCH_HUGE_PTEP_SET_WRPROTECT
40 extern void huge_ptep_set_wrprotect(struct mm_struct *mm,
41 				    unsigned long addr, pte_t *ptep);
42 #define __HAVE_ARCH_HUGE_PTEP_CLEAR_FLUSH
43 extern pte_t huge_ptep_clear_flush(struct vm_area_struct *vma,
44 				   unsigned long addr, pte_t *ptep);
45 #define __HAVE_ARCH_HUGE_PTE_CLEAR
46 extern void huge_pte_clear(struct mm_struct *mm, unsigned long addr,
47 			   pte_t *ptep, unsigned long sz);
48 #define __HAVE_ARCH_HUGE_PTEP_GET
49 extern pte_t huge_ptep_get(pte_t *ptep);
50 
51 void __init arm64_hugetlb_cma_reserve(void);
52 
53 #define huge_ptep_modify_prot_start huge_ptep_modify_prot_start
54 extern pte_t huge_ptep_modify_prot_start(struct vm_area_struct *vma,
55 					 unsigned long addr, pte_t *ptep);
56 
57 #define huge_ptep_modify_prot_commit huge_ptep_modify_prot_commit
58 extern void huge_ptep_modify_prot_commit(struct vm_area_struct *vma,
59 					 unsigned long addr, pte_t *ptep,
60 					 pte_t old_pte, pte_t new_pte);
61 
62 #include <asm-generic/hugetlb.h>
63 
64 #define __HAVE_ARCH_FLUSH_HUGETLB_TLB_RANGE
65 static inline void flush_hugetlb_tlb_range(struct vm_area_struct *vma,
66 					   unsigned long start,
67 					   unsigned long end)
68 {
69 	unsigned long stride = huge_page_size(hstate_vma(vma));
70 
71 	if (stride == PMD_SIZE)
72 		__flush_tlb_range(vma, start, end, stride, false, 2);
73 	else if (stride == PUD_SIZE)
74 		__flush_tlb_range(vma, start, end, stride, false, 1);
75 	else
76 		__flush_tlb_range(vma, start, end, PAGE_SIZE, false, 0);
77 }
78 
79 #endif /* __ASM_HUGETLB_H */
80