uvm_loanobj_read: try to avoid creating VAC aliases if PMAP_PREFER is available yamt-pagecache
authoryamt <yamt@NetBSD.org>
Wed, 28 Dec 2011 13:24:19 +0000
branchyamt-pagecache
changeset 280337 75c2af30ea41
parent 280336 438443aad835
child 280338 a7f0822afb90
uvm_loanobj_read: try to avoid creating VAC aliases if PMAP_PREFER is available
sys/uvm/uvm_loan.c
--- a/sys/uvm/uvm_loan.c	Wed Dec 28 13:22:47 2011 +0000
+++ b/sys/uvm/uvm_loan.c	Wed Dec 28 13:24:19 2011 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_loan.c,v 1.81.2.7 2011/12/28 13:21:27 yamt Exp $	*/
+/*	$NetBSD: uvm_loan.c,v 1.81.2.8 2011/12/28 13:24:19 yamt Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_loan.c,v 1.81.2.7 2011/12/28 13:21:27 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_loan.c,v 1.81.2.8 2011/12/28 13:24:19 yamt Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1394,6 +1394,23 @@
 	if (npages > MAXPAGES) {
 		return EINVAL;
 	}
+#if defined(PMAP_PREFER)
+	/*
+	 * avoid creating VAC aliases.
+	 */
+	{
+		const vaddr_t origva = va;
+
+		PMAP_PREFER(off, &va, len, 0);
+		if (va != origva) {
+			/*
+			 * pmap's suggestion was different from the requested
+			 * address.  punt.
+			 */
+			return EINVAL;
+		}
+	}
+#endif /* defined(PMAP_PREFER) */
 retry:
 	vm_map_lock_read(map);
 	if (!uvm_map_lookup_entry(map, va, &entry)) {