1 #ifndef _S390_TLBFLUSH_H
2 #define _S390_TLBFLUSH_H
5 #include <asm/processor.h>
6 #include <asm/pgalloc.h>
9 * Flush all tlb entries on the local cpu.
11 static inline void __tlb_flush_local(void)
13 asm volatile("ptlb" : : : "memory");
17 * Flush all tlb entries on all cpus.
19 static inline void __tlb_flush_global(void)
21 extern void smp_ptlb_all(void);
22 register unsigned long reg2
asm("2");
23 register unsigned long reg3
asm("3");
24 register unsigned long reg4
asm("4");
28 if (!MACHINE_HAS_CSP
) {
32 #endif /* __s390x__ */
36 reg4
= ((unsigned long) &dummy
) + 1;
39 : : "d" (reg2
), "d" (reg3
), "d" (reg4
), "m" (dummy
) : "cc" );
43 * Flush all tlb entries of a page table on all cpus.
45 static inline void __tlb_flush_idte(unsigned long asce
)
48 " .insn rrf,0xb98e0000,0,%0,%1,0"
49 : : "a" (2048), "a" (asce
) : "cc" );
52 static inline void __tlb_flush_mm(struct mm_struct
* mm
)
54 cpumask_t local_cpumask
;
56 if (unlikely(cpus_empty(mm
->cpu_vm_mask
)))
59 * If the machine has IDTE we prefer to do a per mm flush
60 * on all cpus instead of doing a local flush if the mm
61 * only ran on the local cpu.
63 if (MACHINE_HAS_IDTE
) {
64 pgd_t
*shadow
= get_shadow_table(mm
->pgd
);
67 __tlb_flush_idte((unsigned long) shadow
| mm
->context
);
68 __tlb_flush_idte((unsigned long) mm
->pgd
| mm
->context
);
73 * If the process only ran on the local cpu, do a local flush.
75 local_cpumask
= cpumask_of_cpu(smp_processor_id());
76 if (cpus_equal(mm
->cpu_vm_mask
, local_cpumask
))
83 static inline void __tlb_flush_mm_cond(struct mm_struct
* mm
)
85 if (atomic_read(&mm
->mm_users
) <= 1 && mm
== current
->active_mm
)
91 * flush_tlb() - flushes the current mm struct TLBs
92 * flush_tlb_all() - flushes all processes TLBs
93 * flush_tlb_mm(mm) - flushes the specified mm context TLB's
94 * flush_tlb_page(vma, vmaddr) - flushes one page
95 * flush_tlb_range(vma, start, end) - flushes a range of pages
96 * flush_tlb_kernel_range(start, end) - flushes a range of kernel pages
100 * flush_tlb_mm goes together with ptep_set_wrprotect for the
101 * copy_page_range operation and flush_tlb_range is related to
102 * ptep_get_and_clear for change_protection. ptep_set_wrprotect and
103 * ptep_get_and_clear do not flush the TLBs directly if the mm has
104 * only one user. At the end of the update the flush_tlb_mm and
105 * flush_tlb_range functions need to do the flush.
107 #define flush_tlb() do { } while (0)
108 #define flush_tlb_all() do { } while (0)
109 #define flush_tlb_page(vma, addr) do { } while (0)
111 static inline void flush_tlb_mm(struct mm_struct
*mm
)
113 __tlb_flush_mm_cond(mm
);
116 static inline void flush_tlb_range(struct vm_area_struct
*vma
,
117 unsigned long start
, unsigned long end
)
119 __tlb_flush_mm_cond(vma
->vm_mm
);
122 static inline void flush_tlb_kernel_range(unsigned long start
,
125 __tlb_flush_mm(&init_mm
);
128 #endif /* _S390_TLBFLUSH_H */