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 void smp_ptlb_all(void);
33 * Flush all TLB entries on all CPUs.
35 static inline void __tlb_flush_global(void)
37 unsigned int dummy
= 0;
43 * Flush TLB entries for a specific mm on all CPUs (in case gmap is used
44 * this implicates multiple ASCEs!).
46 static inline void __tlb_flush_full(struct mm_struct
*mm
)
49 atomic_inc(&mm
->context
.flush_count
);
50 if (cpumask_equal(mm_cpumask(mm
), cpumask_of(smp_processor_id()))) {
54 /* Global TLB flush */
56 /* Reset TLB flush mask */
57 cpumask_copy(mm_cpumask(mm
), &mm
->context
.cpu_attach_mask
);
59 atomic_dec(&mm
->context
.flush_count
);
63 static inline void __tlb_flush_mm(struct mm_struct
*mm
)
65 unsigned long gmap_asce
;
68 * If the machine has IDTE we prefer to do a per mm flush
69 * on all cpus instead of doing a local flush if the mm
70 * only ran on the local cpu.
73 atomic_inc(&mm
->context
.flush_count
);
74 gmap_asce
= READ_ONCE(mm
->context
.gmap_asce
);
75 if (MACHINE_HAS_IDTE
&& gmap_asce
!= -1UL) {
77 __tlb_flush_idte(gmap_asce
);
78 __tlb_flush_idte(mm
->context
.asce
);
82 /* Reset TLB flush mask */
83 cpumask_copy(mm_cpumask(mm
), &mm
->context
.cpu_attach_mask
);
84 atomic_dec(&mm
->context
.flush_count
);
88 static inline void __tlb_flush_kernel(void)
91 __tlb_flush_idte(init_mm
.context
.asce
);
96 #define __tlb_flush_global() __tlb_flush_local()
97 #define __tlb_flush_full(mm) __tlb_flush_local()
100 * Flush TLB entries for a specific ASCE on all CPUs.
102 static inline void __tlb_flush_mm(struct mm_struct
*mm
)
107 static inline void __tlb_flush_kernel(void)
113 static inline void __tlb_flush_mm_lazy(struct mm_struct
* mm
)
115 if (mm
->context
.flush_mm
) {
117 mm
->context
.flush_mm
= 0;
123 * flush_tlb() - flushes the current mm struct TLBs
124 * flush_tlb_all() - flushes all processes TLBs
125 * flush_tlb_mm(mm) - flushes the specified mm context TLB's
126 * flush_tlb_page(vma, vmaddr) - flushes one page
127 * flush_tlb_range(vma, start, end) - flushes a range of pages
128 * flush_tlb_kernel_range(start, end) - flushes a range of kernel pages
132 * flush_tlb_mm goes together with ptep_set_wrprotect for the
133 * copy_page_range operation and flush_tlb_range is related to
134 * ptep_get_and_clear for change_protection. ptep_set_wrprotect and
135 * ptep_get_and_clear do not flush the TLBs directly if the mm has
136 * only one user. At the end of the update the flush_tlb_mm and
137 * flush_tlb_range functions need to do the flush.
139 #define flush_tlb() do { } while (0)
140 #define flush_tlb_all() do { } while (0)
141 #define flush_tlb_page(vma, addr) do { } while (0)
143 static inline void flush_tlb_mm(struct mm_struct
*mm
)
145 __tlb_flush_mm_lazy(mm
);
148 static inline void flush_tlb_range(struct vm_area_struct
*vma
,
149 unsigned long start
, unsigned long end
)
151 __tlb_flush_mm_lazy(vma
->vm_mm
);
154 static inline void flush_tlb_kernel_range(unsigned long start
,
157 __tlb_flush_kernel();
160 #endif /* _S390_TLBFLUSH_H */