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>
10 * Flush all TLB entries on the local CPU.
12 static inline void __tlb_flush_local(void)
14 asm volatile("ptlb" : : : "memory");
18 * Flush TLB entries for a specific ASCE on all CPUs
20 static inline void __tlb_flush_idte(unsigned long asce
)
22 /* Global TLB flush for the mm */
24 " .insn rrf,0xb98e0000,0,%0,%1,0"
25 : : "a" (2048), "a" (asce
) : "cc");
29 * Flush TLB entries for a specific ASCE on the local CPU
31 static inline void __tlb_flush_idte_local(unsigned long asce
)
33 /* Local TLB flush for the mm */
35 " .insn rrf,0xb98e0000,0,%0,%1,1"
36 : : "a" (2048), "a" (asce
) : "cc");
40 void smp_ptlb_all(void);
43 * Flush all TLB entries on all CPUs.
45 static inline void __tlb_flush_global(void)
47 register unsigned long reg2
asm("2");
48 register unsigned long reg3
asm("3");
49 register unsigned long reg4
asm("4");
53 if (!MACHINE_HAS_CSP
) {
57 #endif /* CONFIG_64BIT */
61 reg4
= ((unsigned long) &dummy
) + 1;
64 : : "d" (reg2
), "d" (reg3
), "d" (reg4
), "m" (dummy
) : "cc" );
68 * Flush TLB entries for a specific mm on all CPUs (in case gmap is used
69 * this implicates multiple ASCEs!).
71 static inline void __tlb_flush_full(struct mm_struct
*mm
)
74 atomic_add(0x10000, &mm
->context
.attach_count
);
75 if (cpumask_equal(mm_cpumask(mm
), cpumask_of(smp_processor_id()))) {
79 /* Global TLB flush */
81 /* Reset TLB flush mask */
82 if (MACHINE_HAS_TLB_LC
)
83 cpumask_copy(mm_cpumask(mm
),
84 &mm
->context
.cpu_attach_mask
);
86 atomic_sub(0x10000, &mm
->context
.attach_count
);
91 * Flush TLB entries for a specific ASCE on all CPUs.
93 static inline void __tlb_flush_asce(struct mm_struct
*mm
, unsigned long asce
)
98 active
= (mm
== current
->active_mm
) ? 1 : 0;
99 count
= atomic_add_return(0x10000, &mm
->context
.attach_count
);
100 if (MACHINE_HAS_TLB_LC
&& (count
& 0xffff) <= active
&&
101 cpumask_equal(mm_cpumask(mm
), cpumask_of(smp_processor_id()))) {
102 __tlb_flush_idte_local(asce
);
104 if (MACHINE_HAS_IDTE
)
105 __tlb_flush_idte(asce
);
107 __tlb_flush_global();
108 /* Reset TLB flush mask */
109 if (MACHINE_HAS_TLB_LC
)
110 cpumask_copy(mm_cpumask(mm
),
111 &mm
->context
.cpu_attach_mask
);
113 atomic_sub(0x10000, &mm
->context
.attach_count
);
117 static inline void __tlb_flush_kernel(void)
119 if (MACHINE_HAS_IDTE
)
120 __tlb_flush_idte((unsigned long) init_mm
.pgd
|
121 init_mm
.context
.asce_bits
);
123 __tlb_flush_global();
126 #define __tlb_flush_global() __tlb_flush_local()
127 #define __tlb_flush_full(mm) __tlb_flush_local()
130 * Flush TLB entries for a specific ASCE on all CPUs.
132 static inline void __tlb_flush_asce(struct mm_struct
*mm
, unsigned long asce
)
134 if (MACHINE_HAS_TLB_LC
)
135 __tlb_flush_idte_local(asce
);
140 static inline void __tlb_flush_kernel(void)
142 if (MACHINE_HAS_TLB_LC
)
143 __tlb_flush_idte_local((unsigned long) init_mm
.pgd
|
144 init_mm
.context
.asce_bits
);
150 static inline void __tlb_flush_mm(struct mm_struct
* mm
)
153 * If the machine has IDTE we prefer to do a per mm flush
154 * on all cpus instead of doing a local flush if the mm
155 * only ran on the local cpu.
157 if (MACHINE_HAS_IDTE
&& list_empty(&mm
->context
.gmap_list
))
158 __tlb_flush_asce(mm
, (unsigned long) mm
->pgd
|
159 mm
->context
.asce_bits
);
161 __tlb_flush_full(mm
);
164 static inline void __tlb_flush_mm_lazy(struct mm_struct
* mm
)
166 if (mm
->context
.flush_mm
) {
168 mm
->context
.flush_mm
= 0;
174 * flush_tlb() - flushes the current mm struct TLBs
175 * flush_tlb_all() - flushes all processes TLBs
176 * flush_tlb_mm(mm) - flushes the specified mm context TLB's
177 * flush_tlb_page(vma, vmaddr) - flushes one page
178 * flush_tlb_range(vma, start, end) - flushes a range of pages
179 * flush_tlb_kernel_range(start, end) - flushes a range of kernel pages
183 * flush_tlb_mm goes together with ptep_set_wrprotect for the
184 * copy_page_range operation and flush_tlb_range is related to
185 * ptep_get_and_clear for change_protection. ptep_set_wrprotect and
186 * ptep_get_and_clear do not flush the TLBs directly if the mm has
187 * only one user. At the end of the update the flush_tlb_mm and
188 * flush_tlb_range functions need to do the flush.
190 #define flush_tlb() do { } while (0)
191 #define flush_tlb_all() do { } while (0)
192 #define flush_tlb_page(vma, addr) do { } while (0)
194 static inline void flush_tlb_mm(struct mm_struct
*mm
)
196 __tlb_flush_mm_lazy(mm
);
199 static inline void flush_tlb_range(struct vm_area_struct
*vma
,
200 unsigned long start
, unsigned long end
)
202 __tlb_flush_mm_lazy(vma
->vm_mm
);
205 static inline void flush_tlb_kernel_range(unsigned long start
,
208 __tlb_flush_kernel();
211 #endif /* _S390_TLBFLUSH_H */