Module Name: src Committed By: matt Date: Wed Feb 1 02:27:24 UTC 2012
Modified Files: src/sys/kern: uipc_socket.c src/sys/nfs: nfs_serv.c src/sys/sys: socketvar.h Log Message: When using socket loaning, make sure the KVA used for the loan has the same color as the UVA being loaned. To generate a diff of this commit: cvs rdiff -u -r1.208 -r1.209 src/sys/kern/uipc_socket.c cvs rdiff -u -r1.162 -r1.163 src/sys/nfs/nfs_serv.c cvs rdiff -u -r1.128 -r1.129 src/sys/sys/socketvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/uipc_socket.c diff -u src/sys/kern/uipc_socket.c:1.208 src/sys/kern/uipc_socket.c:1.209 --- src/sys/kern/uipc_socket.c:1.208 Fri Jan 27 19:48:40 2012 +++ src/sys/kern/uipc_socket.c Wed Feb 1 02:27:23 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_socket.c,v 1.208 2012/01/27 19:48:40 para Exp $ */ +/* $NetBSD: uipc_socket.c,v 1.209 2012/02/01 02:27:23 matt Exp $ */ /*- * Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.208 2012/01/27 19:48:40 para Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.209 2012/02/01 02:27:23 matt Exp $"); #include "opt_compat_netbsd.h" #include "opt_sock_counters.h" @@ -197,7 +197,7 @@ sokvaunreserve(vsize_t len) */ vaddr_t -sokvaalloc(vsize_t len, struct socket *so) +sokvaalloc(vaddr_t sva, vsize_t len, struct socket *so) { vaddr_t lva; @@ -212,7 +212,8 @@ sokvaalloc(vsize_t len, struct socket *s * allocate kva. */ - lva = uvm_km_alloc(kernel_map, len, 0, UVM_KMF_VAONLY | UVM_KMF_WAITVA); + lva = uvm_km_alloc(kernel_map, len, atop(sva) & uvmexp.colormask, + UVM_KMF_COLORMATCH | UVM_KMF_VAONLY | UVM_KMF_WAITVA); if (lva == 0) { sokvaunreserve(len); return (0); @@ -349,7 +350,7 @@ sosend_loan(struct socket *so, struct ui KASSERT(npgs <= M_EXT_MAXPAGES); - lva = sokvaalloc(len, so); + lva = sokvaalloc(sva, len, so); if (lva == 0) return 0; Index: src/sys/nfs/nfs_serv.c diff -u src/sys/nfs/nfs_serv.c:1.162 src/sys/nfs/nfs_serv.c:1.163 --- src/sys/nfs/nfs_serv.c:1.162 Mon Nov 21 09:07:59 2011 +++ src/sys/nfs/nfs_serv.c Wed Feb 1 02:27:24 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: nfs_serv.c,v 1.162 2011/11/21 09:07:59 hannken Exp $ */ +/* $NetBSD: nfs_serv.c,v 1.163 2012/02/01 02:27:24 matt Exp $ */ /* * Copyright (c) 1989, 1993 @@ -55,7 +55,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.162 2011/11/21 09:07:59 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.163 2012/02/01 02:27:24 matt Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -699,7 +699,8 @@ nfsrv_read(struct nfsrv_descript *nfsd, KASSERT(npages <= M_EXT_MAXPAGES); /* XXX */ /* allocate kva for mbuf data */ - lva = sokvaalloc(npages << PAGE_SHIFT, slp->ns_so); + lva = sokvaalloc(pgoff, npages << PAGE_SHIFT, + slp->ns_so); if (lva == 0) { /* fall back to VOP_READ */ goto loan_fail; Index: src/sys/sys/socketvar.h diff -u src/sys/sys/socketvar.h:1.128 src/sys/sys/socketvar.h:1.129 --- src/sys/sys/socketvar.h:1.128 Wed Dec 21 19:27:47 2011 +++ src/sys/sys/socketvar.h Wed Feb 1 02:27:23 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: socketvar.h,v 1.128 2011/12/21 19:27:47 christos Exp $ */ +/* $NetBSD: socketvar.h,v 1.129 2012/02/01 02:27:23 matt Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -508,7 +508,7 @@ void sblastmbufchk(struct sockbuf *, con #endif /* SOCKBUF_DEBUG */ /* sosend loan */ -vaddr_t sokvaalloc(vsize_t, struct socket *); +vaddr_t sokvaalloc(vaddr_t, vsize_t, struct socket *); void sokvafree(vaddr_t, vsize_t); void soloanfree(struct mbuf *, void *, size_t, void *);