1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_POWERPC_TLBFLUSH_RADIX_H
3 #define _ASM_POWERPC_TLBFLUSH_RADIX_H
4 
5 #include <asm/hvcall.h>
6 
7 struct vm_area_struct;
8 struct mm_struct;
9 struct mmu_gather;
10 
11 static inline u64 psize_to_rpti_pgsize(unsigned long psize)
12 {
13 	if (psize == MMU_PAGE_4K)
14 		return H_RPTI_PAGE_4K;
15 	if (psize == MMU_PAGE_64K)
16 		return H_RPTI_PAGE_64K;
17 	if (psize == MMU_PAGE_2M)
18 		return H_RPTI_PAGE_2M;
19 	if (psize == MMU_PAGE_1G)
20 		return H_RPTI_PAGE_1G;
21 	return H_RPTI_PAGE_ALL;
22 }
23 
24 static inline int mmu_get_ap(int psize)
25 {
26 	return mmu_psize_defs[psize].ap;
27 }
28 
29 #ifdef CONFIG_PPC_RADIX_MMU
30 extern void radix__tlbiel_all(unsigned int action);
31 extern void radix__flush_tlb_lpid_page(unsigned int lpid,
32 					unsigned long addr,
33 					unsigned long page_size);
34 extern void radix__flush_pwc_lpid(unsigned int lpid);
35 extern void radix__flush_all_lpid(unsigned int lpid);
36 extern void radix__flush_all_lpid_guest(unsigned int lpid);
37 #else
38 static inline void radix__tlbiel_all(unsigned int action) { WARN_ON(1); }
39 static inline void radix__flush_tlb_lpid_page(unsigned int lpid,
40 					unsigned long addr,
41 					unsigned long page_size)
42 {
43 	WARN_ON(1);
44 }
45 static inline void radix__flush_pwc_lpid(unsigned int lpid)
46 {
47 	WARN_ON(1);
48 }
49 static inline void radix__flush_all_lpid(unsigned int lpid)
50 {
51 	WARN_ON(1);
52 }
53 static inline void radix__flush_all_lpid_guest(unsigned int lpid)
54 {
55 	WARN_ON(1);
56 }
57 #endif
58 
59 extern void radix__flush_hugetlb_tlb_range(struct vm_area_struct *vma,
60 					   unsigned long start, unsigned long end);
61 extern void radix__flush_tlb_range_psize(struct mm_struct *mm, unsigned long start,
62 					 unsigned long end, int psize);
63 extern void radix__flush_pmd_tlb_range(struct vm_area_struct *vma,
64 				       unsigned long start, unsigned long end);
65 extern void radix__flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
66 			    unsigned long end);
67 extern void radix__flush_tlb_kernel_range(unsigned long start, unsigned long end);
68 
69 extern void radix__local_flush_tlb_mm(struct mm_struct *mm);
70 extern void radix__local_flush_all_mm(struct mm_struct *mm);
71 extern void radix__local_flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
72 extern void radix__local_flush_tlb_page_psize(struct mm_struct *mm, unsigned long vmaddr,
73 					      int psize);
74 extern void radix__tlb_flush(struct mmu_gather *tlb);
75 #ifdef CONFIG_SMP
76 extern void radix__flush_tlb_mm(struct mm_struct *mm);
77 extern void radix__flush_all_mm(struct mm_struct *mm);
78 extern void radix__flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
79 extern void radix__flush_tlb_page_psize(struct mm_struct *mm, unsigned long vmaddr,
80 					int psize);
81 #else
82 #define radix__flush_tlb_mm(mm)		radix__local_flush_tlb_mm(mm)
83 #define radix__flush_all_mm(mm)		radix__local_flush_all_mm(mm)
84 #define radix__flush_tlb_page(vma,addr)	radix__local_flush_tlb_page(vma,addr)
85 #define radix__flush_tlb_page_psize(mm,addr,p) radix__local_flush_tlb_page_psize(mm,addr,p)
86 #endif
87 extern void radix__flush_tlb_pwc(struct mmu_gather *tlb, unsigned long addr);
88 extern void radix__flush_tlb_collapsed_pmd(struct mm_struct *mm, unsigned long addr);
89 extern void radix__flush_tlb_all(void);
90 
91 #endif
92