From owner-svn-src-all@FreeBSD.ORG Wed Jun 17 21:12:32 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B60CE1065677; Wed, 17 Jun 2009 21:12:32 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A229B8FC22; Wed, 17 Jun 2009 21:12:32 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n5HLCWYw088436; Wed, 17 Jun 2009 21:12:32 GMT (envelope-from dchagin@svn.freebsd.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n5HLCW5f088432; Wed, 17 Jun 2009 21:12:32 GMT (envelope-from dchagin@svn.freebsd.org) Message-Id: <200906172112.n5HLCW5f088432@svn.freebsd.org> From: Dmitry Chagin Date: Wed, 17 Jun 2009 21:12:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r194400 - in stable/7/sys: . amd64/linux32 contrib/pf X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Jun 2009 21:12:33 -0000 Author: dchagin Date: Wed Jun 17 21:12:32 2009 New Revision: 194400 URL: http://svn.freebsd.org/changeset/base/194400 Log: MFC r185438: Fix iovec32 for linux32/amd64. Add a custom version of copyiniov() to deal with the 32-bit iovec pointers from userland (to be used later). Adjust prototypes for linux_readv() and linux_writev() to use new l_iovec32 definition and to match actual linux code. In particular, use ulong for fd (why ?). Approved by: kib (mentor) Modified: stable/7/sys/ (props changed) stable/7/sys/amd64/linux32/linux.h stable/7/sys/amd64/linux32/linux32_machdep.c stable/7/sys/amd64/linux32/syscalls.master stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/amd64/linux32/linux.h ============================================================================== --- stable/7/sys/amd64/linux32/linux.h Wed Jun 17 21:03:27 2009 (r194399) +++ stable/7/sys/amd64/linux32/linux.h Wed Jun 17 21:12:32 2009 (r194400) @@ -879,6 +879,16 @@ typedef int l_mqd_t; (LINUX_CLONE_VM | LINUX_CLONE_FS | LINUX_CLONE_FILES | \ LINUX_CLONE_SIGHAND | LINUX_CLONE_THREAD) +struct iovec; + +struct l_iovec32 { + uint32_t iov_base; + l_size_t iov_len; +}; + +int linux32_copyiniov(struct l_iovec32 *iovp32, l_ulong iovcnt, + struct iovec **iovp, int error); + /* robust futexes */ struct linux_robust_list { l_uintptr_t next; Modified: stable/7/sys/amd64/linux32/linux32_machdep.c ============================================================================== --- stable/7/sys/amd64/linux32/linux32_machdep.c Wed Jun 17 21:03:27 2009 (r194399) +++ stable/7/sys/amd64/linux32/linux32_machdep.c Wed Jun 17 21:12:32 2009 (r194400) @@ -232,20 +232,15 @@ linux_execve(struct thread *td, struct l return (error); } -struct iovec32 { - u_int32_t iov_base; - int iov_len; -}; - -CTASSERT(sizeof(struct iovec32) == 8); +CTASSERT(sizeof(struct l_iovec32) == 8); static int -linux32_copyinuio(struct iovec32 *iovp, u_int iovcnt, struct uio **uiop) +linux32_copyinuio(struct l_iovec32 *iovp, l_ulong iovcnt, struct uio **uiop) { - struct iovec32 iov32; + struct l_iovec32 iov32; struct iovec *iov; struct uio *uio; - u_int iovlen; + uint32_t iovlen; int error, i; *uiop = NULL; @@ -255,7 +250,7 @@ linux32_copyinuio(struct iovec32 *iovp, uio = malloc(iovlen + sizeof(*uio), M_IOV, M_WAITOK); iov = (struct iovec *)(uio + 1); for (i = 0; i < iovcnt; i++) { - error = copyin(&iovp[i], &iov32, sizeof(struct iovec32)); + error = copyin(&iovp[i], &iov32, sizeof(struct l_iovec32)); if (error) { free(uio, M_IOV); return (error); @@ -281,6 +276,34 @@ linux32_copyinuio(struct iovec32 *iovp, } int +linux32_copyiniov(struct l_iovec32 *iovp32, l_ulong iovcnt, struct iovec **iovp, + int error) +{ + struct l_iovec32 iov32; + struct iovec *iov; + uint32_t iovlen; + int i; + + *iovp = NULL; + if (iovcnt > UIO_MAXIOV) + return (error); + iovlen = iovcnt * sizeof(struct iovec); + iov = malloc(iovlen, M_IOV, M_WAITOK); + for (i = 0; i < iovcnt; i++) { + error = copyin(&iovp32[i], &iov32, sizeof(struct l_iovec32)); + if (error) { + free(iov, M_IOV); + return (error); + } + iov[i].iov_base = PTRIN(iov32.iov_base); + iov[i].iov_len = iov32.iov_len; + } + *iovp = iov; + return(0); + +} + +int linux_readv(struct thread *td, struct linux_readv_args *uap) { struct uio *auio; Modified: stable/7/sys/amd64/linux32/syscalls.master ============================================================================== --- stable/7/sys/amd64/linux32/syscalls.master Wed Jun 17 21:03:27 2009 (r194399) +++ stable/7/sys/amd64/linux32/syscalls.master Wed Jun 17 21:12:32 2009 (r194400) @@ -252,10 +252,10 @@ 143 AUE_FLOCK NOPROTO { int flock(int fd, int how); } 144 AUE_MSYNC STD { int linux_msync(l_ulong addr, \ l_size_t len, l_int fl); } -145 AUE_READV STD { int linux_readv(int fd, struct iovec32 *iovp, \ - u_int iovcnt); } -146 AUE_WRITEV STD { int linux_writev(int fd, struct iovec32 *iovp, \ - u_int iovcnt); } +145 AUE_READV STD { int linux_readv(l_ulong fd, struct l_iovec32 *iovp, \ + l_ulong iovcnt); } +146 AUE_WRITEV STD { int linux_writev(l_ulong fd, struct l_iovec32 *iovp, \ + l_ulong iovcnt); } 147 AUE_GETSID STD { int linux_getsid(l_pid_t pid); } 148 AUE_NULL STD { int linux_fdatasync(l_uint fd); } 149 AUE_SYSCTL STD { int linux_sysctl( \