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