blob: c8672c366f675094f4083d9f99c6f8d32f935cad [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Andrea Arcangelicddb8a52008-07-28 15:46:29 -07002#ifndef _LINUX_MMU_NOTIFIER_H
3#define _LINUX_MMU_NOTIFIER_H
4
5#include <linux/list.h>
6#include <linux/spinlock.h>
7#include <linux/mm_types.h>
Sagi Grimberg21a92732012-10-08 16:29:24 -07008#include <linux/srcu.h>
Andrea Arcangelicddb8a52008-07-28 15:46:29 -07009
10struct mmu_notifier;
11struct mmu_notifier_ops;
12
13#ifdef CONFIG_MMU_NOTIFIER
14
15/*
16 * The mmu notifier_mm structure is allocated and installed in
17 * mm->mmu_notifier_mm inside the mm_take_all_locks() protected
18 * critical section and it's released only when mm_count reaches zero
19 * in mmdrop().
20 */
21struct mmu_notifier_mm {
22 /* all mmu notifiers registerd in this mm are queued in this list */
23 struct hlist_head list;
24 /* to serialize the list modifications and hlist_unhashed */
25 spinlock_t lock;
26};
27
Jérôme Glisse27560ee2019-05-13 17:20:42 -070028#define MMU_NOTIFIER_RANGE_BLOCKABLE (1 << 0)
29
Jérôme Glisse5d6527a2018-12-28 00:38:05 -080030struct mmu_notifier_range {
31 struct mm_struct *mm;
32 unsigned long start;
33 unsigned long end;
Jérôme Glisse27560ee2019-05-13 17:20:42 -070034 unsigned flags;
Jérôme Glisse5d6527a2018-12-28 00:38:05 -080035};
36
Andrea Arcangelicddb8a52008-07-28 15:46:29 -070037struct mmu_notifier_ops {
38 /*
39 * Called either by mmu_notifier_unregister or when the mm is
40 * being destroyed by exit_mmap, always before all pages are
41 * freed. This can run concurrently with other mmu notifier
42 * methods (the ones invoked outside the mm context) and it
43 * should tear down all secondary mmu mappings and freeze the
44 * secondary mmu. If this method isn't implemented you've to
45 * be sure that nothing could possibly write to the pages
46 * through the secondary mmu by the time the last thread with
47 * tsk->mm == mm exits.
48 *
49 * As side note: the pages freed after ->release returns could
50 * be immediately reallocated by the gart at an alias physical
51 * address with a different cache model, so if ->release isn't
52 * implemented because all _software_ driven memory accesses
53 * through the secondary mmu are terminated by the time the
54 * last thread of this mm quits, you've also to be sure that
55 * speculative _hardware_ operations can't allocate dirty
56 * cachelines in the cpu that could not be snooped and made
57 * coherent with the other read and write operations happening
58 * through the gart alias address, so leading to memory
59 * corruption.
60 */
61 void (*release)(struct mmu_notifier *mn,
62 struct mm_struct *mm);
63
64 /*
65 * clear_flush_young is called after the VM is
66 * test-and-clearing the young/accessed bitflag in the
67 * pte. This way the VM will provide proper aging to the
68 * accesses to the page through the secondary MMUs and not
69 * only to the ones through the Linux pte.
Andres Lagar-Cavilla57128462014-09-22 14:54:42 -070070 * Start-end is necessary in case the secondary MMU is mapping the page
71 * at a smaller granularity than the primary MMU.
Andrea Arcangelicddb8a52008-07-28 15:46:29 -070072 */
73 int (*clear_flush_young)(struct mmu_notifier *mn,
74 struct mm_struct *mm,
Andres Lagar-Cavilla57128462014-09-22 14:54:42 -070075 unsigned long start,
76 unsigned long end);
Andrea Arcangelicddb8a52008-07-28 15:46:29 -070077
78 /*
Vladimir Davydov1d7715c2015-09-09 15:35:41 -070079 * clear_young is a lightweight version of clear_flush_young. Like the
80 * latter, it is supposed to test-and-clear the young/accessed bitflag
81 * in the secondary pte, but it may omit flushing the secondary tlb.
82 */
83 int (*clear_young)(struct mmu_notifier *mn,
84 struct mm_struct *mm,
85 unsigned long start,
86 unsigned long end);
87
88 /*
Andrea Arcangeli8ee53822011-01-13 15:47:10 -080089 * test_young is called to check the young/accessed bitflag in
90 * the secondary pte. This is used to know if the page is
91 * frequently used without actually clearing the flag or tearing
92 * down the secondary mapping on the page.
93 */
94 int (*test_young)(struct mmu_notifier *mn,
95 struct mm_struct *mm,
96 unsigned long address);
97
98 /*
Izik Eidus828502d2009-09-21 17:01:51 -070099 * change_pte is called in cases that pte mapping to page is changed:
100 * for example, when ksm remaps pte to point to a new shared page.
101 */
102 void (*change_pte)(struct mmu_notifier *mn,
103 struct mm_struct *mm,
104 unsigned long address,
105 pte_t pte);
106
107 /*
Andrea Arcangelicddb8a52008-07-28 15:46:29 -0700108 * invalidate_range_start() and invalidate_range_end() must be
109 * paired and are called only when the mmap_sem and/or the
Joerg Roedel0f0a3272014-11-13 13:46:09 +1100110 * locks protecting the reverse maps are held. If the subsystem
111 * can't guarantee that no additional references are taken to
112 * the pages in the range, it has to implement the
113 * invalidate_range() notifier to remove any references taken
114 * after invalidate_range_start().
Andrea Arcangelicddb8a52008-07-28 15:46:29 -0700115 *
116 * Invalidation of multiple concurrent ranges may be
117 * optionally permitted by the driver. Either way the
118 * establishment of sptes is forbidden in the range passed to
119 * invalidate_range_begin/end for the whole duration of the
120 * invalidate_range_begin/end critical section.
121 *
122 * invalidate_range_start() is called when all pages in the
123 * range are still mapped and have at least a refcount of one.
124 *
125 * invalidate_range_end() is called when all pages in the
126 * range have been unmapped and the pages have been freed by
127 * the VM.
128 *
129 * The VM will remove the page table entries and potentially
130 * the page between invalidate_range_start() and
131 * invalidate_range_end(). If the page must not be freed
132 * because of pending I/O or other circumstances then the
133 * invalidate_range_start() callback (or the initial mapping
134 * by the driver) must make sure that the refcount is kept
135 * elevated.
136 *
137 * If the driver increases the refcount when the pages are
138 * initially mapped into an address space then either
139 * invalidate_range_start() or invalidate_range_end() may
140 * decrease the refcount. If the refcount is decreased on
141 * invalidate_range_start() then the VM can free pages as page
142 * table entries are removed. If the refcount is only
143 * droppped on invalidate_range_end() then the driver itself
144 * will drop the last refcount but it must take care to flush
145 * any secondary tlb before doing the final free on the
146 * page. Pages will no longer be referenced by the linux
147 * address space but may still be referenced by sptes until
148 * the last refcount is dropped.
David Rientjes5ff70912018-01-31 16:18:32 -0800149 *
Michal Hocko93065ac2018-08-21 21:52:33 -0700150 * If blockable argument is set to false then the callback cannot
151 * sleep and has to return with -EAGAIN. 0 should be returned
Michal Hocko33490af2018-10-26 15:03:35 -0700152 * otherwise. Please note that if invalidate_range_start approves
153 * a non-blocking behavior then the same applies to
154 * invalidate_range_end.
Michal Hocko93065ac2018-08-21 21:52:33 -0700155 *
Andrea Arcangelicddb8a52008-07-28 15:46:29 -0700156 */
Michal Hocko93065ac2018-08-21 21:52:33 -0700157 int (*invalidate_range_start)(struct mmu_notifier *mn,
Jérôme Glisse5d6527a2018-12-28 00:38:05 -0800158 const struct mmu_notifier_range *range);
Andrea Arcangelicddb8a52008-07-28 15:46:29 -0700159 void (*invalidate_range_end)(struct mmu_notifier *mn,
Jérôme Glisse5d6527a2018-12-28 00:38:05 -0800160 const struct mmu_notifier_range *range);
Joerg Roedel0f0a3272014-11-13 13:46:09 +1100161
162 /*
163 * invalidate_range() is either called between
164 * invalidate_range_start() and invalidate_range_end() when the
165 * VM has to free pages that where unmapped, but before the
166 * pages are actually freed, or outside of _start()/_end() when
167 * a (remote) TLB is necessary.
168 *
169 * If invalidate_range() is used to manage a non-CPU TLB with
170 * shared page-tables, it not necessary to implement the
171 * invalidate_range_start()/end() notifiers, as
172 * invalidate_range() alread catches the points in time when an
Jérôme Glisse0f108512017-11-15 17:34:07 -0800173 * external TLB range needs to be flushed. For more in depth
Mike Rapoportad56b732018-03-21 21:22:47 +0200174 * discussion on this see Documentation/vm/mmu_notifier.rst
Joerg Roedel0f0a3272014-11-13 13:46:09 +1100175 *
Joerg Roedel0f0a3272014-11-13 13:46:09 +1100176 * Note that this function might be called with just a sub-range
177 * of what was passed to invalidate_range_start()/end(), if
178 * called between those functions.
179 */
180 void (*invalidate_range)(struct mmu_notifier *mn, struct mm_struct *mm,
181 unsigned long start, unsigned long end);
Andrea Arcangelicddb8a52008-07-28 15:46:29 -0700182};
183
184/*
185 * The notifier chains are protected by mmap_sem and/or the reverse map
186 * semaphores. Notifier chains are only changed when all reverse maps and
187 * the mmap_sem locks are taken.
188 *
189 * Therefore notifier chains can only be traversed when either
190 *
191 * 1. mmap_sem is held.
Davidlohr Buesoc8c06ef2014-12-12 16:54:24 -0800192 * 2. One of the reverse map locks is held (i_mmap_rwsem or anon_vma->rwsem).
Andrea Arcangelicddb8a52008-07-28 15:46:29 -0700193 * 3. No other concurrent thread can access the list (release)
194 */
195struct mmu_notifier {
196 struct hlist_node hlist;
197 const struct mmu_notifier_ops *ops;
198};
199
200static inline int mm_has_notifiers(struct mm_struct *mm)
201{
202 return unlikely(mm->mmu_notifier_mm);
203}
204
205extern int mmu_notifier_register(struct mmu_notifier *mn,
206 struct mm_struct *mm);
207extern int __mmu_notifier_register(struct mmu_notifier *mn,
208 struct mm_struct *mm);
209extern void mmu_notifier_unregister(struct mmu_notifier *mn,
210 struct mm_struct *mm);
Peter Zijlstrab9722162014-08-06 16:08:20 -0700211extern void mmu_notifier_unregister_no_release(struct mmu_notifier *mn,
212 struct mm_struct *mm);
Andrea Arcangelicddb8a52008-07-28 15:46:29 -0700213extern void __mmu_notifier_mm_destroy(struct mm_struct *mm);
214extern void __mmu_notifier_release(struct mm_struct *mm);
215extern int __mmu_notifier_clear_flush_young(struct mm_struct *mm,
Andres Lagar-Cavilla57128462014-09-22 14:54:42 -0700216 unsigned long start,
217 unsigned long end);
Vladimir Davydov1d7715c2015-09-09 15:35:41 -0700218extern int __mmu_notifier_clear_young(struct mm_struct *mm,
219 unsigned long start,
220 unsigned long end);
Andrea Arcangeli8ee53822011-01-13 15:47:10 -0800221extern int __mmu_notifier_test_young(struct mm_struct *mm,
222 unsigned long address);
Izik Eidus828502d2009-09-21 17:01:51 -0700223extern void __mmu_notifier_change_pte(struct mm_struct *mm,
224 unsigned long address, pte_t pte);
Jérôme Glisseac46d4f2018-12-28 00:38:09 -0800225extern int __mmu_notifier_invalidate_range_start(struct mmu_notifier_range *r);
226extern void __mmu_notifier_invalidate_range_end(struct mmu_notifier_range *r,
Jérôme Glisse4645b9f2017-11-15 17:34:11 -0800227 bool only_end);
Joerg Roedel0f0a3272014-11-13 13:46:09 +1100228extern void __mmu_notifier_invalidate_range(struct mm_struct *mm,
229 unsigned long start, unsigned long end);
Andrea Arcangelicddb8a52008-07-28 15:46:29 -0700230
Jérôme Glisse4a83bfe2019-05-13 17:20:34 -0700231static inline bool
232mmu_notifier_range_blockable(const struct mmu_notifier_range *range)
233{
Jérôme Glisse27560ee2019-05-13 17:20:42 -0700234 return (range->flags & MMU_NOTIFIER_RANGE_BLOCKABLE);
Jérôme Glisse4a83bfe2019-05-13 17:20:34 -0700235}
236
Andrea Arcangelicddb8a52008-07-28 15:46:29 -0700237static inline void mmu_notifier_release(struct mm_struct *mm)
238{
239 if (mm_has_notifiers(mm))
240 __mmu_notifier_release(mm);
241}
242
243static inline int mmu_notifier_clear_flush_young(struct mm_struct *mm,
Andres Lagar-Cavilla57128462014-09-22 14:54:42 -0700244 unsigned long start,
245 unsigned long end)
Andrea Arcangelicddb8a52008-07-28 15:46:29 -0700246{
247 if (mm_has_notifiers(mm))
Andres Lagar-Cavilla57128462014-09-22 14:54:42 -0700248 return __mmu_notifier_clear_flush_young(mm, start, end);
Andrea Arcangelicddb8a52008-07-28 15:46:29 -0700249 return 0;
250}
251
Vladimir Davydov1d7715c2015-09-09 15:35:41 -0700252static inline int mmu_notifier_clear_young(struct mm_struct *mm,
253 unsigned long start,
254 unsigned long end)
255{
256 if (mm_has_notifiers(mm))
257 return __mmu_notifier_clear_young(mm, start, end);
258 return 0;
259}
260
Andrea Arcangeli8ee53822011-01-13 15:47:10 -0800261static inline int mmu_notifier_test_young(struct mm_struct *mm,
262 unsigned long address)
263{
264 if (mm_has_notifiers(mm))
265 return __mmu_notifier_test_young(mm, address);
266 return 0;
267}
268
Izik Eidus828502d2009-09-21 17:01:51 -0700269static inline void mmu_notifier_change_pte(struct mm_struct *mm,
270 unsigned long address, pte_t pte)
271{
272 if (mm_has_notifiers(mm))
273 __mmu_notifier_change_pte(mm, address, pte);
274}
275
Jérôme Glisseac46d4f2018-12-28 00:38:09 -0800276static inline void
277mmu_notifier_invalidate_range_start(struct mmu_notifier_range *range)
Andrea Arcangelicddb8a52008-07-28 15:46:29 -0700278{
Jérôme Glisseac46d4f2018-12-28 00:38:09 -0800279 if (mm_has_notifiers(range->mm)) {
Jérôme Glisse27560ee2019-05-13 17:20:42 -0700280 range->flags |= MMU_NOTIFIER_RANGE_BLOCKABLE;
Jérôme Glisseac46d4f2018-12-28 00:38:09 -0800281 __mmu_notifier_invalidate_range_start(range);
282 }
Michal Hocko93065ac2018-08-21 21:52:33 -0700283}
284
Jérôme Glisseac46d4f2018-12-28 00:38:09 -0800285static inline int
286mmu_notifier_invalidate_range_start_nonblock(struct mmu_notifier_range *range)
Michal Hocko93065ac2018-08-21 21:52:33 -0700287{
Jérôme Glisseac46d4f2018-12-28 00:38:09 -0800288 if (mm_has_notifiers(range->mm)) {
Jérôme Glisse27560ee2019-05-13 17:20:42 -0700289 range->flags &= ~MMU_NOTIFIER_RANGE_BLOCKABLE;
Jérôme Glisseac46d4f2018-12-28 00:38:09 -0800290 return __mmu_notifier_invalidate_range_start(range);
291 }
Michal Hocko93065ac2018-08-21 21:52:33 -0700292 return 0;
Andrea Arcangelicddb8a52008-07-28 15:46:29 -0700293}
294
Jérôme Glisseac46d4f2018-12-28 00:38:09 -0800295static inline void
296mmu_notifier_invalidate_range_end(struct mmu_notifier_range *range)
Andrea Arcangelicddb8a52008-07-28 15:46:29 -0700297{
Jérôme Glisseac46d4f2018-12-28 00:38:09 -0800298 if (mm_has_notifiers(range->mm))
299 __mmu_notifier_invalidate_range_end(range, false);
Jérôme Glisse4645b9f2017-11-15 17:34:11 -0800300}
301
Jérôme Glisseac46d4f2018-12-28 00:38:09 -0800302static inline void
303mmu_notifier_invalidate_range_only_end(struct mmu_notifier_range *range)
Jérôme Glisse4645b9f2017-11-15 17:34:11 -0800304{
Jérôme Glisseac46d4f2018-12-28 00:38:09 -0800305 if (mm_has_notifiers(range->mm))
306 __mmu_notifier_invalidate_range_end(range, true);
Andrea Arcangelicddb8a52008-07-28 15:46:29 -0700307}
308
Joerg Roedel1897bdc2014-11-13 13:46:09 +1100309static inline void mmu_notifier_invalidate_range(struct mm_struct *mm,
310 unsigned long start, unsigned long end)
311{
Joerg Roedel0f0a3272014-11-13 13:46:09 +1100312 if (mm_has_notifiers(mm))
313 __mmu_notifier_invalidate_range(mm, start, end);
Joerg Roedel1897bdc2014-11-13 13:46:09 +1100314}
315
Andrea Arcangelicddb8a52008-07-28 15:46:29 -0700316static inline void mmu_notifier_mm_init(struct mm_struct *mm)
317{
318 mm->mmu_notifier_mm = NULL;
319}
320
321static inline void mmu_notifier_mm_destroy(struct mm_struct *mm)
322{
323 if (mm_has_notifiers(mm))
324 __mmu_notifier_mm_destroy(mm);
325}
326
Jérôme Glisseac46d4f2018-12-28 00:38:09 -0800327
328static inline void mmu_notifier_range_init(struct mmu_notifier_range *range,
329 struct mm_struct *mm,
330 unsigned long start,
331 unsigned long end)
332{
333 range->mm = mm;
334 range->start = start;
335 range->end = end;
Jérôme Glisse27560ee2019-05-13 17:20:42 -0700336 range->flags = 0;
Jérôme Glisseac46d4f2018-12-28 00:38:09 -0800337}
338
Andrea Arcangelicddb8a52008-07-28 15:46:29 -0700339#define ptep_clear_flush_young_notify(__vma, __address, __ptep) \
340({ \
341 int __young; \
342 struct vm_area_struct *___vma = __vma; \
343 unsigned long ___address = __address; \
344 __young = ptep_clear_flush_young(___vma, ___address, __ptep); \
345 __young |= mmu_notifier_clear_flush_young(___vma->vm_mm, \
Andres Lagar-Cavilla57128462014-09-22 14:54:42 -0700346 ___address, \
347 ___address + \
348 PAGE_SIZE); \
Andrea Arcangelicddb8a52008-07-28 15:46:29 -0700349 __young; \
350})
351
Andrea Arcangeli91a4ee22011-01-13 15:46:44 -0800352#define pmdp_clear_flush_young_notify(__vma, __address, __pmdp) \
353({ \
354 int __young; \
355 struct vm_area_struct *___vma = __vma; \
356 unsigned long ___address = __address; \
357 __young = pmdp_clear_flush_young(___vma, ___address, __pmdp); \
358 __young |= mmu_notifier_clear_flush_young(___vma->vm_mm, \
Andres Lagar-Cavilla57128462014-09-22 14:54:42 -0700359 ___address, \
360 ___address + \
361 PMD_SIZE); \
Andrea Arcangeli91a4ee22011-01-13 15:46:44 -0800362 __young; \
363})
364
Vladimir Davydov1d7715c2015-09-09 15:35:41 -0700365#define ptep_clear_young_notify(__vma, __address, __ptep) \
366({ \
367 int __young; \
368 struct vm_area_struct *___vma = __vma; \
369 unsigned long ___address = __address; \
370 __young = ptep_test_and_clear_young(___vma, ___address, __ptep);\
371 __young |= mmu_notifier_clear_young(___vma->vm_mm, ___address, \
372 ___address + PAGE_SIZE); \
373 __young; \
374})
375
376#define pmdp_clear_young_notify(__vma, __address, __pmdp) \
377({ \
378 int __young; \
379 struct vm_area_struct *___vma = __vma; \
380 unsigned long ___address = __address; \
381 __young = pmdp_test_and_clear_young(___vma, ___address, __pmdp);\
382 __young |= mmu_notifier_clear_young(___vma->vm_mm, ___address, \
383 ___address + PMD_SIZE); \
384 __young; \
385})
386
Joerg Roedel34ee6452014-11-13 13:46:09 +1100387#define ptep_clear_flush_notify(__vma, __address, __ptep) \
388({ \
389 unsigned long ___addr = __address & PAGE_MASK; \
390 struct mm_struct *___mm = (__vma)->vm_mm; \
391 pte_t ___pte; \
392 \
393 ___pte = ptep_clear_flush(__vma, __address, __ptep); \
394 mmu_notifier_invalidate_range(___mm, ___addr, \
395 ___addr + PAGE_SIZE); \
396 \
397 ___pte; \
398})
399
Aneesh Kumar K.V8809aa22015-06-24 16:57:44 -0700400#define pmdp_huge_clear_flush_notify(__vma, __haddr, __pmd) \
Joerg Roedel34ee6452014-11-13 13:46:09 +1100401({ \
402 unsigned long ___haddr = __haddr & HPAGE_PMD_MASK; \
403 struct mm_struct *___mm = (__vma)->vm_mm; \
404 pmd_t ___pmd; \
405 \
Aneesh Kumar K.V8809aa22015-06-24 16:57:44 -0700406 ___pmd = pmdp_huge_clear_flush(__vma, __haddr, __pmd); \
Joerg Roedel34ee6452014-11-13 13:46:09 +1100407 mmu_notifier_invalidate_range(___mm, ___haddr, \
408 ___haddr + HPAGE_PMD_SIZE); \
409 \
410 ___pmd; \
411})
412
Matthew Wilcoxa00cc7d2017-02-24 14:57:02 -0800413#define pudp_huge_clear_flush_notify(__vma, __haddr, __pud) \
414({ \
415 unsigned long ___haddr = __haddr & HPAGE_PUD_MASK; \
416 struct mm_struct *___mm = (__vma)->vm_mm; \
417 pud_t ___pud; \
418 \
419 ___pud = pudp_huge_clear_flush(__vma, __haddr, __pud); \
420 mmu_notifier_invalidate_range(___mm, ___haddr, \
421 ___haddr + HPAGE_PUD_SIZE); \
422 \
423 ___pud; \
424})
425
Xiao Guangrong48af0d72012-10-08 16:29:23 -0700426/*
427 * set_pte_at_notify() sets the pte _after_ running the notifier.
428 * This is safe to start by updating the secondary MMUs, because the primary MMU
429 * pte invalidate must have already happened with a ptep_clear_flush() before
430 * set_pte_at_notify() has been invoked. Updating the secondary MMUs first is
431 * required when we change both the protection of the mapping from read-only to
432 * read-write and the pfn (like during copy on write page faults). Otherwise the
433 * old page would remain mapped readonly in the secondary MMUs after the new
434 * page is already writable by some CPU through the primary MMU.
435 */
Izik Eidus828502d2009-09-21 17:01:51 -0700436#define set_pte_at_notify(__mm, __address, __ptep, __pte) \
437({ \
438 struct mm_struct *___mm = __mm; \
439 unsigned long ___address = __address; \
440 pte_t ___pte = __pte; \
441 \
Izik Eidus828502d2009-09-21 17:01:51 -0700442 mmu_notifier_change_pte(___mm, ___address, ___pte); \
Xiao Guangrong48af0d72012-10-08 16:29:23 -0700443 set_pte_at(___mm, ___address, __ptep, ___pte); \
Izik Eidus828502d2009-09-21 17:01:51 -0700444})
445
Peter Zijlstrab9722162014-08-06 16:08:20 -0700446extern void mmu_notifier_call_srcu(struct rcu_head *rcu,
447 void (*func)(struct rcu_head *rcu));
Peter Zijlstrab9722162014-08-06 16:08:20 -0700448
Andrea Arcangelicddb8a52008-07-28 15:46:29 -0700449#else /* CONFIG_MMU_NOTIFIER */
450
Jérôme Glisseac46d4f2018-12-28 00:38:09 -0800451struct mmu_notifier_range {
452 unsigned long start;
453 unsigned long end;
454};
455
456static inline void _mmu_notifier_range_init(struct mmu_notifier_range *range,
457 unsigned long start,
458 unsigned long end)
459{
460 range->start = start;
461 range->end = end;
462}
463
464#define mmu_notifier_range_init(range, mm, start, end) \
465 _mmu_notifier_range_init(range, start, end)
466
Jérôme Glisse4a83bfe2019-05-13 17:20:34 -0700467static inline bool
468mmu_notifier_range_blockable(const struct mmu_notifier_range *range)
469{
470 return true;
471}
Jérôme Glisseac46d4f2018-12-28 00:38:09 -0800472
Michal Hocko4d4bbd82017-10-03 16:14:50 -0700473static inline int mm_has_notifiers(struct mm_struct *mm)
474{
475 return 0;
476}
477
Andrea Arcangelicddb8a52008-07-28 15:46:29 -0700478static inline void mmu_notifier_release(struct mm_struct *mm)
479{
480}
481
482static inline int mmu_notifier_clear_flush_young(struct mm_struct *mm,
Andres Lagar-Cavilla57128462014-09-22 14:54:42 -0700483 unsigned long start,
484 unsigned long end)
Andrea Arcangelicddb8a52008-07-28 15:46:29 -0700485{
486 return 0;
487}
488
Andrea Arcangeli8ee53822011-01-13 15:47:10 -0800489static inline int mmu_notifier_test_young(struct mm_struct *mm,
490 unsigned long address)
491{
492 return 0;
493}
494
Izik Eidus828502d2009-09-21 17:01:51 -0700495static inline void mmu_notifier_change_pte(struct mm_struct *mm,
496 unsigned long address, pte_t pte)
497{
498}
499
Jérôme Glisseac46d4f2018-12-28 00:38:09 -0800500static inline void
501mmu_notifier_invalidate_range_start(struct mmu_notifier_range *range)
Andrea Arcangelicddb8a52008-07-28 15:46:29 -0700502{
503}
504
Jérôme Glisseac46d4f2018-12-28 00:38:09 -0800505static inline int
506mmu_notifier_invalidate_range_start_nonblock(struct mmu_notifier_range *range)
Michal Hocko93065ac2018-08-21 21:52:33 -0700507{
508 return 0;
509}
510
Jérôme Glisseac46d4f2018-12-28 00:38:09 -0800511static inline
512void mmu_notifier_invalidate_range_end(struct mmu_notifier_range *range)
Andrea Arcangelicddb8a52008-07-28 15:46:29 -0700513{
514}
515
Jérôme Glisseac46d4f2018-12-28 00:38:09 -0800516static inline void
517mmu_notifier_invalidate_range_only_end(struct mmu_notifier_range *range)
Jérôme Glisse4645b9f2017-11-15 17:34:11 -0800518{
519}
520
Joerg Roedel1897bdc2014-11-13 13:46:09 +1100521static inline void mmu_notifier_invalidate_range(struct mm_struct *mm,
522 unsigned long start, unsigned long end)
523{
524}
525
Andrea Arcangelicddb8a52008-07-28 15:46:29 -0700526static inline void mmu_notifier_mm_init(struct mm_struct *mm)
527{
528}
529
530static inline void mmu_notifier_mm_destroy(struct mm_struct *mm)
531{
532}
533
534#define ptep_clear_flush_young_notify ptep_clear_flush_young
Andrea Arcangeli91a4ee22011-01-13 15:46:44 -0800535#define pmdp_clear_flush_young_notify pmdp_clear_flush_young
Vladimir Davydov33c3fc72015-09-09 15:35:45 -0700536#define ptep_clear_young_notify ptep_test_and_clear_young
537#define pmdp_clear_young_notify pmdp_test_and_clear_young
Joerg Roedel34ee6452014-11-13 13:46:09 +1100538#define ptep_clear_flush_notify ptep_clear_flush
Aneesh Kumar K.V8809aa22015-06-24 16:57:44 -0700539#define pmdp_huge_clear_flush_notify pmdp_huge_clear_flush
Matthew Wilcoxa00cc7d2017-02-24 14:57:02 -0800540#define pudp_huge_clear_flush_notify pudp_huge_clear_flush
Izik Eidus828502d2009-09-21 17:01:51 -0700541#define set_pte_at_notify set_pte_at
Andrea Arcangelicddb8a52008-07-28 15:46:29 -0700542
543#endif /* CONFIG_MMU_NOTIFIER */
544
545#endif /* _LINUX_MMU_NOTIFIER_H */