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.
79 static inline void __tlb_flush_asce(struct mm_struct *mm, unsigned long asce)
82 atomic_inc(&mm->context.flush_count);
83 if (MACHINE_HAS_TLB_LC &&
84 cpumask_equal(mm_cpumask(mm), cpumask_of(smp_processor_id()))) {
85 __tlb_flush_idte_local(asce);
88 __tlb_flush_idte(asce);
91 /* Reset TLB flush mask */
92 if (MACHINE_HAS_TLB_LC)
93 cpumask_copy(mm_cpumask(mm),
94 &mm->context.cpu_attach_mask);
96 atomic_dec(&mm->context.flush_count);
100 static inline void __tlb_flush_kernel(void)
102 if (MACHINE_HAS_IDTE)
103 __tlb_flush_idte(init_mm.context.asce);
105 __tlb_flush_global();
108 #define __tlb_flush_global() __tlb_flush_local()
109 #define __tlb_flush_full(mm) __tlb_flush_local()
112 * Flush TLB entries for a specific ASCE on all CPUs.
114 static inline void __tlb_flush_asce(struct mm_struct *mm, unsigned long asce)
116 if (MACHINE_HAS_TLB_LC)
117 __tlb_flush_idte_local(asce);
122 static inline void __tlb_flush_kernel(void)
124 if (MACHINE_HAS_TLB_LC)
125 __tlb_flush_idte_local(init_mm.context.asce);
131 static inline void __tlb_flush_mm(struct mm_struct * mm)
134 * If the machine has IDTE we prefer to do a per mm flush
135 * on all cpus instead of doing a local flush if the mm
136 * only ran on the local cpu.
138 if (MACHINE_HAS_IDTE && list_empty(&mm->context.gmap_list))
139 __tlb_flush_asce(mm, mm->context.asce);
141 __tlb_flush_full(mm);
144 static inline void __tlb_flush_mm_lazy(struct mm_struct * mm)
146 if (mm->context.flush_mm) {
148 mm->context.flush_mm = 0;
154 * flush_tlb() - flushes the current mm struct TLBs
155 * flush_tlb_all() - flushes all processes TLBs
156 * flush_tlb_mm(mm) - flushes the specified mm context TLB's
157 * flush_tlb_page(vma, vmaddr) - flushes one page
158 * flush_tlb_range(vma, start, end) - flushes a range of pages
159 * flush_tlb_kernel_range(start, end) - flushes a range of kernel pages
163 * flush_tlb_mm goes together with ptep_set_wrprotect for the
164 * copy_page_range operation and flush_tlb_range is related to
165 * ptep_get_and_clear for change_protection. ptep_set_wrprotect and
166 * ptep_get_and_clear do not flush the TLBs directly if the mm has
167 * only one user. At the end of the update the flush_tlb_mm and
168 * flush_tlb_range functions need to do the flush.
170 #define flush_tlb() do { } while (0)
171 #define flush_tlb_all() do { } while (0)
172 #define flush_tlb_page(vma, addr) do { } while (0)
174 static inline void flush_tlb_mm(struct mm_struct *mm)
176 __tlb_flush_mm_lazy(mm);
179 static inline void flush_tlb_range(struct vm_area_struct *vma,
180 unsigned long start, unsigned long end)
182 __tlb_flush_mm_lazy(vma->vm_mm);
185 static inline void flush_tlb_kernel_range(unsigned long start,
188 __tlb_flush_kernel();
191 #endif /* _S390_TLBFLUSH_H */