1
2#ifndef _S390_TLBFLUSH_H
3#define _S390_TLBFLUSH_H
4
5#include <linux/mm.h>
6#include <linux/sched.h>
7#include <asm/processor.h>
8#include <asm/pgalloc.h>
9#include <asm/pgtable.h>
10
11
12
13
14static inline void __tlb_flush_local(void)
15{
16 asm volatile("ptlb" : : : "memory");
17}
18
19
20
21
22static inline void __tlb_flush_idte(unsigned long asce)
23{
24 unsigned long opt;
25
26 opt = IDTE_PTOA;
27 if (MACHINE_HAS_TLB_GUEST)
28 opt |= IDTE_GUEST_ASCE;
29
30 asm volatile(
31 " .insn rrf,0xb98e0000,0,%0,%1,0"
32 : : "a" (opt), "a" (asce) : "cc");
33}
34
35#ifdef CONFIG_SMP
36void smp_ptlb_all(void);
37
38
39
40
41static inline void __tlb_flush_global(void)
42{
43 unsigned int dummy = 0;
44
45 csp(&dummy, 0, 0);
46}
47
48
49
50
51
52static inline void __tlb_flush_mm(struct mm_struct *mm)
53{
54 unsigned long gmap_asce;
55
56
57
58
59
60
61 preempt_disable();
62 atomic_inc(&mm->context.flush_count);
63
64 cpumask_copy(mm_cpumask(mm), &mm->context.cpu_attach_mask);
65 barrier();
66 gmap_asce = READ_ONCE(mm->context.gmap_asce);
67 if (MACHINE_HAS_IDTE && gmap_asce != -1UL) {
68 if (gmap_asce)
69 __tlb_flush_idte(gmap_asce);
70 __tlb_flush_idte(mm->context.asce);
71 } else {
72
73 __tlb_flush_global();
74 }
75 atomic_dec(&mm->context.flush_count);
76 preempt_enable();
77}
78
79static inline void __tlb_flush_kernel(void)
80{
81 if (MACHINE_HAS_IDTE)
82 __tlb_flush_idte(init_mm.context.asce);
83 else
84 __tlb_flush_global();
85}
86#else
87#define __tlb_flush_global() __tlb_flush_local()
88
89
90
91
92static inline void __tlb_flush_mm(struct mm_struct *mm)
93{
94 __tlb_flush_local();
95}
96
97static inline void __tlb_flush_kernel(void)
98{
99 __tlb_flush_local();
100}
101#endif
102
103static inline void __tlb_flush_mm_lazy(struct mm_struct * mm)
104{
105 spin_lock(&mm->context.lock);
106 if (mm->context.flush_mm) {
107 mm->context.flush_mm = 0;
108 __tlb_flush_mm(mm);
109 }
110 spin_unlock(&mm->context.lock);
111}
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131#define flush_tlb() do { } while (0)
132#define flush_tlb_all() do { } while (0)
133#define flush_tlb_page(vma, addr) do { } while (0)
134
135static inline void flush_tlb_mm(struct mm_struct *mm)
136{
137 __tlb_flush_mm_lazy(mm);
138}
139
140static inline void flush_tlb_range(struct vm_area_struct *vma,
141 unsigned long start, unsigned long end)
142{
143 __tlb_flush_mm_lazy(vma->vm_mm);
144}
145
146static inline void flush_tlb_kernel_range(unsigned long start,
147 unsigned long end)
148{
149 __tlb_flush_kernel();
150}
151
152#endif
153