1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#include <linux/kernel.h>
21#include <linux/mm.h>
22#include <linux/init.h>
23#include <linux/highmem.h>
24#include <linux/pagemap.h>
25#include <linux/export.h>
26
27#include <asm/tlbflush.h>
28#include <asm/tlb.h>
29
30#include <mm/mmu_decl.h>
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50void hash__flush_range(struct mm_struct *mm, unsigned long start, unsigned long end)
51{
52 pmd_t *pmd;
53 unsigned long pmd_end;
54 int count;
55 unsigned int ctx = mm->context.id;
56
57 start &= PAGE_MASK;
58 if (start >= end)
59 return;
60 end = (end - 1) | ~PAGE_MASK;
61 pmd = pmd_off(mm, start);
62 for (;;) {
63 pmd_end = ((start + PGDIR_SIZE) & PGDIR_MASK) - 1;
64 if (pmd_end > end)
65 pmd_end = end;
66 if (!pmd_none(*pmd)) {
67 count = ((pmd_end - start) >> PAGE_SHIFT) + 1;
68 flush_hash_pages(ctx, start, pmd_val(*pmd), count);
69 }
70 if (pmd_end == end)
71 break;
72 start = pmd_end + 1;
73 ++pmd;
74 }
75}
76EXPORT_SYMBOL(hash__flush_range);
77
78
79
80
81void hash__flush_tlb_mm(struct mm_struct *mm)
82{
83 struct vm_area_struct *mp;
84
85
86
87
88
89
90
91 for (mp = mm->mmap; mp != NULL; mp = mp->vm_next)
92 hash__flush_range(mp->vm_mm, mp->vm_start, mp->vm_end);
93}
94EXPORT_SYMBOL(hash__flush_tlb_mm);
95
96void hash__flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr)
97{
98 struct mm_struct *mm;
99 pmd_t *pmd;
100
101 mm = (vmaddr < TASK_SIZE)? vma->vm_mm: &init_mm;
102 pmd = pmd_off(mm, vmaddr);
103 if (!pmd_none(*pmd))
104 flush_hash_pages(mm->context.id, vmaddr, pmd_val(*pmd), 1);
105}
106EXPORT_SYMBOL(hash__flush_tlb_page);
107