1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_POWERPC_BOOK3S_64_TLBFLUSH_H
3 #define _ASM_POWERPC_BOOK3S_64_TLBFLUSH_H
5 #define MMU_NO_CONTEXT ~0UL
7 #include <linux/mm_types.h>
8 #include <asm/book3s/64/tlbflush-hash.h>
9 #include <asm/book3s/64/tlbflush-radix.h>
11 /* TLB flush actions. Used as argument to tlbiel_all() */
13 TLB_INVAL_SCOPE_GLOBAL
= 0, /* invalidate all TLBs */
14 TLB_INVAL_SCOPE_LPID
= 1, /* invalidate TLBs for current LPID */
17 #ifdef CONFIG_PPC_NATIVE
18 static inline void tlbiel_all(void)
21 * This is used for host machine check and bootup.
23 * This uses early_radix_enabled and implementations use
24 * early_cpu_has_feature etc because that works early in boot
25 * and this is the machine check path which is not performance
28 if (early_radix_enabled())
29 radix__tlbiel_all(TLB_INVAL_SCOPE_GLOBAL
);
31 hash__tlbiel_all(TLB_INVAL_SCOPE_GLOBAL
);
34 static inline void tlbiel_all(void) { BUG(); };
37 static inline void tlbiel_all_lpid(bool radix
)
40 * This is used for guest machine check.
43 radix__tlbiel_all(TLB_INVAL_SCOPE_LPID
);
45 hash__tlbiel_all(TLB_INVAL_SCOPE_LPID
);
49 #define __HAVE_ARCH_FLUSH_PMD_TLB_RANGE
50 static inline void flush_pmd_tlb_range(struct vm_area_struct
*vma
,
51 unsigned long start
, unsigned long end
)
54 return radix__flush_pmd_tlb_range(vma
, start
, end
);
55 return hash__flush_tlb_range(vma
, start
, end
);
58 #define __HAVE_ARCH_FLUSH_HUGETLB_TLB_RANGE
59 static inline void flush_hugetlb_tlb_range(struct vm_area_struct
*vma
,
64 return radix__flush_hugetlb_tlb_range(vma
, start
, end
);
65 return hash__flush_tlb_range(vma
, start
, end
);
68 static inline void flush_tlb_range(struct vm_area_struct
*vma
,
69 unsigned long start
, unsigned long end
)
72 return radix__flush_tlb_range(vma
, start
, end
);
73 return hash__flush_tlb_range(vma
, start
, end
);
76 static inline void flush_tlb_kernel_range(unsigned long start
,
80 return radix__flush_tlb_kernel_range(start
, end
);
81 return hash__flush_tlb_kernel_range(start
, end
);
84 static inline void local_flush_tlb_mm(struct mm_struct
*mm
)
87 return radix__local_flush_tlb_mm(mm
);
88 return hash__local_flush_tlb_mm(mm
);
91 static inline void local_flush_tlb_page(struct vm_area_struct
*vma
,
95 return radix__local_flush_tlb_page(vma
, vmaddr
);
96 return hash__local_flush_tlb_page(vma
, vmaddr
);
99 static inline void local_flush_all_mm(struct mm_struct
*mm
)
102 return radix__local_flush_all_mm(mm
);
103 return hash__local_flush_all_mm(mm
);
106 static inline void tlb_flush(struct mmu_gather
*tlb
)
109 return radix__tlb_flush(tlb
);
110 return hash__tlb_flush(tlb
);
114 static inline void flush_tlb_mm(struct mm_struct
*mm
)
117 return radix__flush_tlb_mm(mm
);
118 return hash__flush_tlb_mm(mm
);
121 static inline void flush_tlb_page(struct vm_area_struct
*vma
,
122 unsigned long vmaddr
)
125 return radix__flush_tlb_page(vma
, vmaddr
);
126 return hash__flush_tlb_page(vma
, vmaddr
);
129 static inline void flush_all_mm(struct mm_struct
*mm
)
132 return radix__flush_all_mm(mm
);
133 return hash__flush_all_mm(mm
);
136 #define flush_tlb_mm(mm) local_flush_tlb_mm(mm)
137 #define flush_tlb_page(vma, addr) local_flush_tlb_page(vma, addr)
138 #define flush_all_mm(mm) local_flush_all_mm(mm)
139 #endif /* CONFIG_SMP */
141 #define flush_tlb_fix_spurious_fault flush_tlb_fix_spurious_fault
142 static inline void flush_tlb_fix_spurious_fault(struct vm_area_struct
*vma
,
143 unsigned long address
)
145 /* See ptep_set_access_flags comment */
146 if (atomic_read(&vma
->vm_mm
->context
.copros
) > 0)
147 flush_tlb_page(vma
, address
);
150 extern bool tlbie_capable
;
151 extern bool tlbie_enabled
;
153 static inline bool cputlb_use_tlbie(void)
155 return tlbie_enabled
;
158 #endif /* _ASM_POWERPC_BOOK3S_64_TLBFLUSH_H */