1#ifndef _S390_TLB_H
2#define _S390_TLB_H
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include <linux/mm.h>
25#include <linux/pagemap.h>
26#include <linux/swap.h>
27#include <asm/processor.h>
28#include <asm/pgalloc.h>
29#include <asm/tlbflush.h>
30
31struct mmu_gather {
32 struct mm_struct *mm;
33#ifdef CONFIG_HAVE_RCU_TABLE_FREE
34 struct mmu_table_batch *batch;
35#endif
36 unsigned int fullmm;
37 unsigned int need_flush;
38};
39
40#ifdef CONFIG_HAVE_RCU_TABLE_FREE
41struct mmu_table_batch {
42 struct rcu_head rcu;
43 unsigned int nr;
44 void *tables[0];
45};
46
47#define MAX_TABLE_BATCH \
48 ((PAGE_SIZE - sizeof(struct mmu_table_batch)) / sizeof(void *))
49
50extern void tlb_table_flush(struct mmu_gather *tlb);
51extern void tlb_remove_table(struct mmu_gather *tlb, void *table);
52#endif
53
54static inline void tlb_gather_mmu(struct mmu_gather *tlb,
55 struct mm_struct *mm,
56 unsigned int full_mm_flush)
57{
58 tlb->mm = mm;
59 tlb->fullmm = full_mm_flush;
60 tlb->need_flush = 0;
61#ifdef CONFIG_HAVE_RCU_TABLE_FREE
62 tlb->batch = NULL;
63#endif
64 if (tlb->fullmm)
65 __tlb_flush_mm(mm);
66}
67
68static inline void tlb_flush_mmu(struct mmu_gather *tlb)
69{
70 if (!tlb->need_flush)
71 return;
72 tlb->need_flush = 0;
73 __tlb_flush_mm(tlb->mm);
74#ifdef CONFIG_HAVE_RCU_TABLE_FREE
75 tlb_table_flush(tlb);
76#endif
77}
78
79static inline void tlb_finish_mmu(struct mmu_gather *tlb,
80 unsigned long start, unsigned long end)
81{
82 tlb_flush_mmu(tlb);
83}
84
85
86
87
88
89
90static inline int __tlb_remove_page(struct mmu_gather *tlb, struct page *page)
91{
92 free_page_and_swap_cache(page);
93 return 1;
94}
95
96static inline void tlb_remove_page(struct mmu_gather *tlb, struct page *page)
97{
98 free_page_and_swap_cache(page);
99}
100
101
102
103
104
105static inline void pte_free_tlb(struct mmu_gather *tlb, pgtable_t pte,
106 unsigned long address)
107{
108#ifdef CONFIG_HAVE_RCU_TABLE_FREE
109 if (!tlb->fullmm)
110 return page_table_free_rcu(tlb, (unsigned long *) pte);
111#endif
112 page_table_free(tlb->mm, (unsigned long *) pte);
113}
114
115
116
117
118
119
120
121
122static inline void pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
123 unsigned long address)
124{
125#ifdef __s390x__
126 if (tlb->mm->context.asce_limit <= (1UL << 31))
127 return;
128#ifdef CONFIG_HAVE_RCU_TABLE_FREE
129 if (!tlb->fullmm)
130 return tlb_remove_table(tlb, pmd);
131#endif
132 crst_table_free(tlb->mm, (unsigned long *) pmd);
133#endif
134}
135
136
137
138
139
140
141
142
143static inline void pud_free_tlb(struct mmu_gather *tlb, pud_t *pud,
144 unsigned long address)
145{
146#ifdef __s390x__
147 if (tlb->mm->context.asce_limit <= (1UL << 42))
148 return;
149#ifdef CONFIG_HAVE_RCU_TABLE_FREE
150 if (!tlb->fullmm)
151 return tlb_remove_table(tlb, pud);
152#endif
153 crst_table_free(tlb->mm, (unsigned long *) pud);
154#endif
155}
156
157#define tlb_start_vma(tlb, vma) do { } while (0)
158#define tlb_end_vma(tlb, vma) do { } while (0)
159#define tlb_remove_tlb_entry(tlb, ptep, addr) do { } while (0)
160#define tlb_migrate_finish(mm) do { } while (0)
161
162#endif
163