Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
tlbflush.h
Go to the documentation of this file.
1 #ifndef _S390_TLBFLUSH_H
2 #define _S390_TLBFLUSH_H
3 
4 #include <linux/mm.h>
5 #include <linux/sched.h>
6 #include <asm/processor.h>
7 #include <asm/pgalloc.h>
8 
9 /*
10  * Flush all tlb entries on the local cpu.
11  */
12 static inline void __tlb_flush_local(void)
13 {
14  asm volatile("ptlb" : : : "memory");
15 }
16 
17 #ifdef CONFIG_SMP
18 /*
19  * Flush all tlb entries on all cpus.
20  */
21 void smp_ptlb_all(void);
22 
23 static inline void __tlb_flush_global(void)
24 {
25  register unsigned long reg2 asm("2");
26  register unsigned long reg3 asm("3");
27  register unsigned long reg4 asm("4");
28  long dummy;
29 
30 #ifndef CONFIG_64BIT
31  if (!MACHINE_HAS_CSP) {
32  smp_ptlb_all();
33  return;
34  }
35 #endif /* CONFIG_64BIT */
36 
37  dummy = 0;
38  reg2 = reg3 = 0;
39  reg4 = ((unsigned long) &dummy) + 1;
40  asm volatile(
41  " csp %0,%2"
42  : : "d" (reg2), "d" (reg3), "d" (reg4), "m" (dummy) : "cc" );
43 }
44 
45 static inline void __tlb_flush_full(struct mm_struct *mm)
46 {
47  cpumask_t local_cpumask;
48 
50  /*
51  * If the process only ran on the local cpu, do a local flush.
52  */
53  cpumask_copy(&local_cpumask, cpumask_of(smp_processor_id()));
54  if (cpumask_equal(mm_cpumask(mm), &local_cpumask))
55  __tlb_flush_local();
56  else
59 }
60 #else
61 #define __tlb_flush_full(mm) __tlb_flush_local()
62 #define __tlb_flush_global() __tlb_flush_local()
63 #endif
64 
65 /*
66  * Flush all tlb entries of a page table on all cpus.
67  */
68 static inline void __tlb_flush_idte(unsigned long asce)
69 {
70  asm volatile(
71  " .insn rrf,0xb98e0000,0,%0,%1,0"
72  : : "a" (2048), "a" (asce) : "cc" );
73 }
74 
75 static inline void __tlb_flush_mm(struct mm_struct * mm)
76 {
77  if (unlikely(cpumask_empty(mm_cpumask(mm))))
78  return;
79  /*
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.
83  */
84  if (MACHINE_HAS_IDTE && list_empty(&mm->context.gmap_list))
85  __tlb_flush_idte((unsigned long) mm->pgd |
86  mm->context.asce_bits);
87  else
88  __tlb_flush_full(mm);
89 }
90 
91 static inline void __tlb_flush_mm_cond(struct mm_struct * mm)
92 {
93  if (mm->context.flush_mm) {
94  __tlb_flush_mm(mm);
95  mm->context.flush_mm = 0;
96  }
97 }
98 
99 /*
100  * TLB flushing:
101  * flush_tlb() - flushes the current mm struct TLBs
102  * flush_tlb_all() - flushes all processes TLBs
103  * flush_tlb_mm(mm) - flushes the specified mm context TLB's
104  * flush_tlb_page(vma, vmaddr) - flushes one page
105  * flush_tlb_range(vma, start, end) - flushes a range of pages
106  * flush_tlb_kernel_range(start, end) - flushes a range of kernel pages
107  */
108 
109 /*
110  * flush_tlb_mm goes together with ptep_set_wrprotect for the
111  * copy_page_range operation and flush_tlb_range is related to
112  * ptep_get_and_clear for change_protection. ptep_set_wrprotect and
113  * ptep_get_and_clear do not flush the TLBs directly if the mm has
114  * only one user. At the end of the update the flush_tlb_mm and
115  * flush_tlb_range functions need to do the flush.
116  */
117 #define flush_tlb() do { } while (0)
118 #define flush_tlb_all() do { } while (0)
119 #define flush_tlb_page(vma, addr) do { } while (0)
120 
121 static inline void flush_tlb_mm(struct mm_struct *mm)
122 {
123  __tlb_flush_mm_cond(mm);
124 }
125 
126 static inline void flush_tlb_range(struct vm_area_struct *vma,
127  unsigned long start, unsigned long end)
128 {
129  __tlb_flush_mm_cond(vma->vm_mm);
130 }
131 
132 static inline void flush_tlb_kernel_range(unsigned long start,
133  unsigned long end)
134 {
135  __tlb_flush_mm(&init_mm);
136 }
137 
138 #endif /* _S390_TLBFLUSH_H */