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");
19 * Flush all tlb entries on all cpus.
21 void smp_ptlb_all(void);
23 static inline void __tlb_flush_global(void)
25 register unsigned long reg2
asm("2");
26 register unsigned long reg3
asm("3");
27 register unsigned long reg4
asm("4");
31 if (!MACHINE_HAS_CSP
) {
35 #endif /* __s390x__ */
39 reg4
= ((unsigned long) &dummy
) + 1;
42 : : "d" (reg2
), "d" (reg3
), "d" (reg4
), "m" (dummy
) : "cc" );
45 static inline void __tlb_flush_full(struct mm_struct
*mm
)
47 cpumask_t local_cpumask
;
51 * If the process only ran on the local cpu, do a local flush.
53 cpumask_copy(&local_cpumask
, cpumask_of(smp_processor_id()));
54 if (cpumask_equal(mm_cpumask(mm
), &local_cpumask
))
61 #define __tlb_flush_full(mm) __tlb_flush_local()
62 #define __tlb_flush_global() __tlb_flush_local()
66 * Flush all tlb entries of a page table on all cpus.
68 static inline void __tlb_flush_idte(unsigned long asce
)
71 " .insn rrf,0xb98e0000,0,%0,%1,0"
72 : : "a" (2048), "a" (asce
) : "cc" );
75 static inline void __tlb_flush_mm(struct mm_struct
* mm
)
77 if (unlikely(cpumask_empty(mm_cpumask(mm
))))
80 * If the machine has IDTE we prefer to do a per mm flush
81 * on all cpus instead of doing a local flush if the mm
82 * only ran on the local cpu.
84 if (MACHINE_HAS_IDTE
&& list_empty(&mm
->context
.gmap_list
))
85 __tlb_flush_idte((unsigned long) mm
->pgd
|
86 mm
->context
.asce_bits
);
91 static inline void __tlb_flush_mm_cond(struct mm_struct
* mm
)
93 spin_lock(&mm
->page_table_lock
);
94 if (mm
->context
.flush_mm
) {
96 mm
->context
.flush_mm
= 0;
98 spin_unlock(&mm
->page_table_lock
);
103 * flush_tlb() - flushes the current mm struct TLBs
104 * flush_tlb_all() - flushes all processes TLBs
105 * flush_tlb_mm(mm) - flushes the specified mm context TLB's
106 * flush_tlb_page(vma, vmaddr) - flushes one page
107 * flush_tlb_range(vma, start, end) - flushes a range of pages
108 * flush_tlb_kernel_range(start, end) - flushes a range of kernel pages
112 * flush_tlb_mm goes together with ptep_set_wrprotect for the
113 * copy_page_range operation and flush_tlb_range is related to
114 * ptep_get_and_clear for change_protection. ptep_set_wrprotect and
115 * ptep_get_and_clear do not flush the TLBs directly if the mm has
116 * only one user. At the end of the update the flush_tlb_mm and
117 * flush_tlb_range functions need to do the flush.
119 #define flush_tlb() do { } while (0)
120 #define flush_tlb_all() do { } while (0)
121 #define flush_tlb_page(vma, addr) do { } while (0)
123 static inline void flush_tlb_mm(struct mm_struct
*mm
)
125 __tlb_flush_mm_cond(mm
);
128 static inline void flush_tlb_range(struct vm_area_struct
*vma
,
129 unsigned long start
, unsigned long end
)
131 __tlb_flush_mm_cond(vma
->vm_mm
);
134 static inline void flush_tlb_kernel_range(unsigned long start
,
137 __tlb_flush_mm(&init_mm
);
140 #endif /* _S390_TLBFLUSH_H */