diff options
author | Atsushi Nemoto <anemo@mba.ocn.ne.jp> | 2006-12-12 12:14:56 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.osdl.org> | 2006-12-13 12:27:08 -0500 |
commit | bcd022801ee514e28c32837f0b3ce18c775f1a7b (patch) | |
tree | 6230fbec80e9f1c7580efa685ded26f638f81ef0 /arch/mips/mm/init.c | |
parent | 9de455b20705f36384a711d4a20bcf7ba1ab180b (diff) |
[PATCH] MIPS: Fix COW D-cache aliasing on fork
Provide a custom copy_user_highpage() to deal with aliasing issues on
MIPS. It uses kmap_coherent() to map an user page for kernel with same
color. Rewrite copy_to_user_page() and copy_from_user_page() with the
new interfaces to avoid extra cache flushing.
The main part of this patch was originally written by Ralf Baechle;
Atushi Nemoto did the the debugging.
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/mips/mm/init.c')
-rw-r--r-- | arch/mips/mm/init.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c index ea2d15370bb7..30245c09d025 100644 --- a/arch/mips/mm/init.c +++ b/arch/mips/mm/init.c | |||
@@ -203,6 +203,31 @@ static inline void kunmap_coherent(struct page *page) | |||
203 | preempt_check_resched(); | 203 | preempt_check_resched(); |
204 | } | 204 | } |
205 | 205 | ||
206 | void copy_user_highpage(struct page *to, struct page *from, | ||
207 | unsigned long vaddr, struct vm_area_struct *vma) | ||
208 | { | ||
209 | void *vfrom, *vto; | ||
210 | |||
211 | vto = kmap_atomic(to, KM_USER1); | ||
212 | if (cpu_has_dc_aliases) { | ||
213 | vfrom = kmap_coherent(from, vaddr); | ||
214 | copy_page(vto, vfrom); | ||
215 | kunmap_coherent(from); | ||
216 | } else { | ||
217 | vfrom = kmap_atomic(from, KM_USER0); | ||
218 | copy_page(vto, vfrom); | ||
219 | kunmap_atomic(vfrom, KM_USER0); | ||
220 | } | ||
221 | if (((vma->vm_flags & VM_EXEC) && !cpu_has_ic_fills_f_dc) || | ||
222 | pages_do_alias((unsigned long)vto, vaddr & PAGE_MASK)) | ||
223 | flush_data_cache_page((unsigned long)vto); | ||
224 | kunmap_atomic(vto, KM_USER1); | ||
225 | /* Make sure this page is cleared on other CPU's too before using it */ | ||
226 | smp_wmb(); | ||
227 | } | ||
228 | |||
229 | EXPORT_SYMBOL(copy_user_highpage); | ||
230 | |||
206 | void copy_to_user_page(struct vm_area_struct *vma, | 231 | void copy_to_user_page(struct vm_area_struct *vma, |
207 | struct page *page, unsigned long vaddr, void *dst, const void *src, | 232 | struct page *page, unsigned long vaddr, void *dst, const void *src, |
208 | unsigned long len) | 233 | unsigned long len) |