2 #include <linux/highmem.h>
3 #include <linux/sched.h>
5 static int walk_pte_range(pmd_t
*pmd
, unsigned long addr
, unsigned long end
,
11 pte
= pte_offset_map(pmd
, addr
);
13 err
= walk
->pte_entry(pte
, addr
, addr
+ PAGE_SIZE
, walk
);
26 static int walk_pmd_range(pud_t
*pud
, unsigned long addr
, unsigned long end
,
33 pmd
= pmd_offset(pud
, addr
);
35 next
= pmd_addr_end(addr
, end
);
36 if (pmd_none_or_clear_bad(pmd
)) {
38 err
= walk
->pte_hole(addr
, next
, walk
);
44 err
= walk
->pmd_entry(pmd
, addr
, next
, walk
);
45 if (!err
&& walk
->pte_entry
)
46 err
= walk_pte_range(pmd
, addr
, next
, walk
);
49 } while (pmd
++, addr
= next
, addr
!= end
);
54 static int walk_pud_range(pgd_t
*pgd
, unsigned long addr
, unsigned long end
,
61 pud
= pud_offset(pgd
, addr
);
63 next
= pud_addr_end(addr
, end
);
64 if (pud_none_or_clear_bad(pud
)) {
66 err
= walk
->pte_hole(addr
, next
, walk
);
72 err
= walk
->pud_entry(pud
, addr
, next
, walk
);
73 if (!err
&& (walk
->pmd_entry
|| walk
->pte_entry
))
74 err
= walk_pmd_range(pud
, addr
, next
, walk
);
77 } while (pud
++, addr
= next
, addr
!= end
);
83 * walk_page_range - walk a memory map's page tables with a callback
84 * @mm: memory map to walk
85 * @addr: starting address
86 * @end: ending address
87 * @walk: set of callbacks to invoke for each level of the tree
89 * Recursively walk the page table for the memory area in a VMA,
90 * calling supplied callbacks. Callbacks are called in-order (first
91 * PGD, first PUD, first PMD, first PTE, second PTE... second PMD,
92 * etc.). If lower-level callbacks are omitted, walking depth is reduced.
94 * Each callback receives an entry pointer and the start and end of the
95 * associated range, and a copy of the original mm_walk for access to
96 * the ->private or ->mm fields.
98 * No locks are taken, but the bottom level iterator will map PTE
99 * directories from highmem if necessary.
101 * If any callback returns a non-zero value, the walk is aborted and
102 * the return value is propagated back to the caller. Otherwise 0 is returned.
104 int walk_page_range(unsigned long addr
, unsigned long end
,
105 struct mm_walk
*walk
)
117 pgd
= pgd_offset(walk
->mm
, addr
);
119 next
= pgd_addr_end(addr
, end
);
120 if (pgd_none_or_clear_bad(pgd
)) {
122 err
= walk
->pte_hole(addr
, next
, walk
);
128 err
= walk
->pgd_entry(pgd
, addr
, next
, walk
);
130 (walk
->pud_entry
|| walk
->pmd_entry
|| walk
->pte_entry
))
131 err
= walk_pud_range(pgd
, addr
, next
, walk
);
134 } while (pgd
++, addr
= next
, addr
!= end
);
This page took 0.033008 seconds and 5 git commands to generate.