Skip to content

Commit b868868

Browse files
committed
[MIPS] Fix aliasing bug in copy_user_highpage.
Copy_user_highpage was written assuming it was only being called for breaking COW pages in which case the source page isn't cached as in marked cachable under it kernel virtual address. If it is called anyway the aliasing avoidance strategy implemented by kmap_coherent will fail. Avoid the use of kmap_coherent for pages marked dirty and to avoid another instance of this sort of bug, place a BUG_ON in kmap_coherent. Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
1 parent 01e9943 commit b868868

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎arch/mips/mm/init.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* Kevin D. Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com
99
* Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
1010
*/
11+
#include <linux/bug.h>
1112
#include <linux/init.h>
1213
#include <linux/module.h>
1314
#include <linux/signal.h>
@@ -132,6 +133,8 @@ void *kmap_coherent(struct page *page, unsigned long addr)
132133
pte_t pte;
133134
int tlbidx;
134135

136+
BUG_ON(Page_dcache_dirty(page));
137+
135138
inc_preempt_count();
136139
idx = (addr >> PAGE_SHIFT) & (FIX_N_COLOURS - 1);
137140
#ifdef CONFIG_MIPS_MT_SMTC
@@ -208,7 +211,7 @@ void copy_user_highpage(struct page *to, struct page *from,
208211
void *vfrom, *vto;
209212

210213
vto = kmap_atomic(to, KM_USER1);
211-
if (cpu_has_dc_aliases) {
214+
if (cpu_has_dc_aliases && !Page_dcache_dirty(from)) {
212215
vfrom = kmap_coherent(from, vaddr);
213216
copy_page(vto, vfrom);
214217
kunmap_coherent();

0 commit comments

Comments
 (0)