1 #ifndef _S390_TLBFLUSH_H
2 #define _S390_TLBFLUSH_H
5 #include <linux/sched.h>
6 #include <asm/processor.h>
7 #include <asm/pgalloc.h>
8 #include <asm/pgtable.h>
11 * Flush all TLB entries on the local CPU.
13 static inline void __tlb_flush_local(void)
15 asm volatile("ptlb" : : : "memory");
19 * Flush TLB entries for a specific ASCE on all CPUs
21 static inline void __tlb_flush_idte(unsigned long asce)
23 /* Global TLB flush for the mm */
25 " .insn rrf,0xb98e0000,0,%0,%1,0"
26 : : "a" (2048), "a" (asce) : "cc");
30 * Flush TLB entries for a specific ASCE on the local CPU
32 static inline void __tlb_flush_idte_local(unsigned long asce)
34 /* Local TLB flush for the mm */
36 " .insn rrf,0xb98e0000,0,%0,%1,1"
37 : : "a" (2048), "a" (asce) : "cc");
41 void smp_ptlb_all(void);
44 * Flush all TLB entries on all CPUs.
46 static inline void __tlb_flush_global(void)
48 unsigned int dummy = 0;
54 * Flush TLB entries for a specific mm on all CPUs (in case gmap is used
55 * this implicates multiple ASCEs!).
57 static inline void __tlb_flush_full(struct mm_struct *mm)
60 atomic_inc(&mm->context.flush_count);
61 if (cpumask_equal(mm_cpumask(mm), cpumask_of(smp_processor_id()))) {
65 /* Global TLB flush */
67 /* Reset TLB flush mask */
68 if (MACHINE_HAS_TLB_LC)
69 cpumask_copy(mm_cpumask(mm),
70 &mm->context.cpu_attach_mask);
72 atomic_dec(&mm->context.flush_count);
77 * Flush TLB entries for a specific ASCE on all CPUs. Should never be used
78 * when more than one asce (e.g. gmap) ran on this mm.
80 static inline void __tlb_flush_asce(struct mm_struct *mm, unsigned long asce)
83 atomic_inc(&mm->context.flush_count);
84 if (MACHINE_HAS_TLB_LC &&
85 cpumask_equal(mm_cpumask(mm), cpumask_of(smp_processor_id()))) {
86 __tlb_flush_idte_local(asce);
89 __tlb_flush_idte(asce);
92 /* Reset TLB flush mask */
93 if (MACHINE_HAS_TLB_LC)
94 cpumask_copy(mm_cpumask(mm),
95 &mm->context.cpu_attach_mask);
97 atomic_dec(&mm->context.flush_count);
101 static inline void __tlb_flush_kernel(void)
103 if (MACHINE_HAS_IDTE)
104 __tlb_flush_idte(init_mm.context.asce);
106 __tlb_flush_global();
109 #define __tlb_flush_global() __tlb_flush_local()
110 #define __tlb_flush_full(mm) __tlb_flush_local()
113 * Flush TLB entries for a specific ASCE on all CPUs.
115 static inline void __tlb_flush_asce(struct mm_struct *mm, unsigned long asce)
117 if (MACHINE_HAS_TLB_LC)
118 __tlb_flush_idte_local(asce);
123 static inline void __tlb_flush_kernel(void)
125 if (MACHINE_HAS_TLB_LC)
126 __tlb_flush_idte_local(init_mm.context.asce);
132 static inline void __tlb_flush_mm(struct mm_struct * mm)
135 * If the machine has IDTE we prefer to do a per mm flush
136 * on all cpus instead of doing a local flush if the mm
137 * only ran on the local cpu.
139 if (MACHINE_HAS_IDTE && list_empty(&mm->context.gmap_list))
140 __tlb_flush_asce(mm, mm->context.asce);
142 __tlb_flush_full(mm);
145 static inline void __tlb_flush_mm_lazy(struct mm_struct * mm)
147 if (mm->context.flush_mm) {
149 mm->context.flush_mm = 0;
155 * flush_tlb() - flushes the current mm struct TLBs
156 * flush_tlb_all() - flushes all processes TLBs
157 * flush_tlb_mm(mm) - flushes the specified mm context TLB's
158 * flush_tlb_page(vma, vmaddr) - flushes one page
159 * flush_tlb_range(vma, start, end) - flushes a range of pages
160 * flush_tlb_kernel_range(start, end) - flushes a range of kernel pages
164 * flush_tlb_mm goes together with ptep_set_wrprotect for the
165 * copy_page_range operation and flush_tlb_range is related to
166 * ptep_get_and_clear for change_protection. ptep_set_wrprotect and
167 * ptep_get_and_clear do not flush the TLBs directly if the mm has
168 * only one user. At the end of the update the flush_tlb_mm and
169 * flush_tlb_range functions need to do the flush.
171 #define flush_tlb() do { } while (0)
172 #define flush_tlb_all() do { } while (0)
173 #define flush_tlb_page(vma, addr) do { } while (0)
175 static inline void flush_tlb_mm(struct mm_struct *mm)
177 __tlb_flush_mm_lazy(mm);
180 static inline void flush_tlb_range(struct vm_area_struct *vma,
181 unsigned long start, unsigned long end)
183 __tlb_flush_mm_lazy(vma->vm_mm);
186 static inline void flush_tlb_kernel_range(unsigned long start,
189 __tlb_flush_kernel();
192 #endif /* _S390_TLBFLUSH_H */