Module Name:    src
Committed By:   skrll
Date:           Wed Apr 23 20:57:15 UTC 2014

Modified Files:
        src/sys/arch/mips/mips: pmap.c vm_machdep.c

Log Message:
Fix a logic inversion introduced with the matt-nb5-mips64 for
pmap_{zero,copy}_page cache alias handing. The check previously used
PG_MD_UNCACHED_P, where it now uses PG_MD_CACHED_P, when considering if
a cache invalidation is required.

Additionally flush the cache for the uarea va to avoid potential (future)
cache aliases in cpu_uarea_free when handing pages back to uvm for later
use.

ok matt@

Hopefully this addresses the instability reported in the following PRs:

PR/44900 - R5000/Rm5200 mips ports are broken
PR/46170 - NetBSD/cobalt 6.0_BETA does not boot
PR/46890 - upcoming NetBSD 6.0 release is very unstable / unusable on cobalt 
qube 2
PR/48628 - cobalt and hpcmips ports are dead


To generate a diff of this commit:
cvs rdiff -u -r1.209 -r1.210 src/sys/arch/mips/mips/pmap.c
cvs rdiff -u -r1.142 -r1.143 src/sys/arch/mips/mips/vm_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/mips/mips/pmap.c
diff -u src/sys/arch/mips/mips/pmap.c:1.209 src/sys/arch/mips/mips/pmap.c:1.210
--- src/sys/arch/mips/mips/pmap.c:1.209	Sun Nov 10 18:27:15 2013
+++ src/sys/arch/mips/mips/pmap.c	Wed Apr 23 20:57:15 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.209 2013/11/10 18:27:15 christos Exp $	*/
+/*	$NetBSD: pmap.c,v 1.210 2014/04/23 20:57:15 skrll Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.209 2013/11/10 18:27:15 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.210 2014/04/23 20:57:15 skrll Exp $");
 
 /*
  *	Manages physical address maps.
@@ -454,16 +454,18 @@ pmap_unmap_ephemeral_page(struct vm_page
 	pv_entry_t pv = &md->pvh_first;
 	
 	(void)PG_MD_PVLIST_LOCK(md, false);
-	if (MIPS_CACHE_VIRTUAL_ALIAS
-	    && (PG_MD_UNCACHED_P(md)
-		|| (pv->pv_pmap != NULL
-		    && mips_cache_badalias(pv->pv_va, va)))) {
-		/*
-		 * If this page was previously uncached or we had to use an
-		 * incompatible alias and it has a valid mapping, flush it
-		 * from the cache.
-		 */
-		mips_dcache_wbinv_range(va, PAGE_SIZE);
+	if (MIPS_CACHE_VIRTUAL_ALIAS) {
+		if (PG_MD_CACHED_P(md)
+		    || (pv->pv_pmap != NULL
+			&& mips_cache_badalias(pv->pv_va, va))) {
+
+			/*
+			 * If this page was previously cached or we had to use an
+			 * incompatible alias and it has a valid mapping, flush it
+			 * from the cache.
+			 */
+			mips_dcache_wbinv_range(va, PAGE_SIZE);
+		}
 	}
 	PG_MD_PVLIST_UNLOCK(md);
 #ifndef _LP64

Index: src/sys/arch/mips/mips/vm_machdep.c
diff -u src/sys/arch/mips/mips/vm_machdep.c:1.142 src/sys/arch/mips/mips/vm_machdep.c:1.143
--- src/sys/arch/mips/mips/vm_machdep.c:1.142	Sun Feb 19 21:06:20 2012
+++ src/sys/arch/mips/mips/vm_machdep.c	Wed Apr 23 20:57:15 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: vm_machdep.c,v 1.142 2012/02/19 21:06:20 rmind Exp $	*/
+/*	$NetBSD: vm_machdep.c,v 1.143 2014/04/23 20:57:15 skrll Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.142 2012/02/19 21:06:20 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.143 2014/04/23 20:57:15 skrll Exp $");
 
 #include "opt_ddb.h"
 #include "opt_coredump.h"
@@ -230,6 +230,11 @@ cpu_uarea_free(void *va)
 	paddr_t pa = MIPS_KSEG0_TO_PHYS(va);
 #endif
 
+#ifdef MIPS3_PLUS
+	if (MIPS_CACHE_VIRTUAL_ALIAS)
+		mips_dcache_inv_range((vaddr_t)va, USPACE);
+#endif
+
 	for (const paddr_t epa = pa + USPACE; pa < epa; pa += PAGE_SIZE) {
 		struct vm_page * const pg = PHYS_TO_VM_PAGE(pa);
 		KASSERT(pg != NULL);

Reply via email to