diff --git a/arch/sh/include/asm/fixmap.h b/arch/sh/include/asm/fixmap.h index 76c5a3099cb8..5ac1e40a511c 100644 --- a/arch/sh/include/asm/fixmap.h +++ b/arch/sh/include/asm/fixmap.h @@ -46,9 +46,15 @@ * fix-mapped? */ enum fixed_addresses { + /* + * The FIX_CMAP entries are used by kmap_coherent() to get virtual + * addresses which are of a known color, and so their values are + * important. __fix_to_virt(FIX_CMAP_END - n) must give an address + * which is the same color as a page (n<flags)) { - vfrom = kmap_coherent(from, vaddr); + void *vto_coloured = kmap_coherent(to, vaddr); + copy_page(vto_coloured, vfrom); + kunmap_coherent(vto_coloured); + } else copy_page(vto, vfrom); - kunmap_coherent(vfrom); - } else { - vfrom = kmap_atomic(from, KM_USER0); - copy_page(vto, vfrom); - kunmap_atomic(vfrom, KM_USER0); - } - - if (pages_do_alias((unsigned long)vto, vaddr & PAGE_MASK)) - __flush_purge_region(vto, PAGE_SIZE); + kunmap_atomic(vfrom, KM_USER0); kunmap_atomic(vto, KM_USER1); + /* Make sure this page is cleared on other CPU's too before using it */ smp_wmb(); } @@ -112,10 +145,17 @@ void clear_user_highpage(struct page *page, unsigned long vaddr) { void *kaddr = kmap_atomic(page, KM_USER0); - clear_page(kaddr); + if (pages_do_alias((unsigned long)kaddr, vaddr & PAGE_MASK)) { + void *vto; - if (pages_do_alias((unsigned long)kaddr, vaddr & PAGE_MASK)) - __flush_purge_region(kaddr, PAGE_SIZE); + /* Kernel alias may have modified data in the cache. */ + __flush_invalidate_region(kaddr, PAGE_SIZE); + + vto = kmap_coherent(page, vaddr); + clear_page(vto); + kunmap_coherent(vto); + } else + clear_page(kaddr); kunmap_atomic(kaddr, KM_USER0); }