netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iovec: move memcpy_from/toiovecend to lib/iovec.c
@ 2014-06-19 18:22 Michael S. Tsirkin
  2014-06-19 19:12 ` Randy Dunlap
  2014-06-20  4:06 ` David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Michael S. Tsirkin @ 2014-06-19 18:22 UTC (permalink / raw)
  To: linux-kernel
  Cc: Randy Dunlap, Stephen Rothwell, Hans J. Koch, Greg Kroah-Hartman,
	David S. Miller, stephen hemminger, Sean Hefty, FX Le Bail,
	Jason Wang, Hannes Frederic Sowa, Zhi Yong Wu, Nicholas Bellinger,
	netdev

ERROR: "memcpy_fromiovecend" [drivers/vhost/vhost_scsi.ko] undefined!

commit 9f977ef7b671f6169eca78bf40f230fe84b7c7e5
    vhost-scsi: Include prot_bytes into expected data transfer length
in target-pending makes drivers/vhost/scsi.c call memcpy_fromiovecend().
This function is not available when CONFIG_NET is not enabled.

socket.h already includes uio.h, so no callers need updating.

Reported-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---

David, could you please ack merging this through
target-pending to avoid dependency issues?

Thanks!

 include/linux/socket.h |  4 ----
 include/linux/uio.h    |  4 ++++
 lib/iovec.c            | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++
 net/core/iovec.c       | 55 --------------------------------------------------
 4 files changed, 59 insertions(+), 59 deletions(-)

diff --git a/include/linux/socket.h b/include/linux/socket.h
index 8e98297..ec538fc 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -305,8 +305,6 @@ struct ucred {
 /* IPX options */
 #define IPX_TYPE	1
 
-extern int memcpy_fromiovecend(unsigned char *kdata, const struct iovec *iov,
-			       int offset, int len);
 extern int csum_partial_copy_fromiovecend(unsigned char *kdata, 
 					  struct iovec *iov, 
 					  int offset, 
@@ -315,8 +313,6 @@ extern unsigned long iov_pages(const struct iovec *iov, int offset,
 			       unsigned long nr_segs);
 
 extern int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *address, int mode);
-extern int memcpy_toiovecend(const struct iovec *v, unsigned char *kdata,
-			     int offset, int len);
 extern int move_addr_to_kernel(void __user *uaddr, int ulen, struct sockaddr_storage *kaddr);
 extern int put_cmsg(struct msghdr*, int level, int type, int len, void *data);
 
diff --git a/include/linux/uio.h b/include/linux/uio.h
index 199bcc3..8a4709a 100644
--- a/include/linux/uio.h
+++ b/include/linux/uio.h
@@ -89,5 +89,9 @@ static inline size_t iov_iter_count(struct iov_iter *i)
 
 int memcpy_fromiovec(unsigned char *kdata, struct iovec *iov, int len);
 int memcpy_toiovec(struct iovec *iov, unsigned char *kdata, int len);
+int memcpy_fromiovecend(unsigned char *kdata, const struct iovec *iov,
+			int offset, int len);
+int memcpy_toiovecend(const struct iovec *v, unsigned char *kdata,
+		      int offset, int len);
 
 #endif
diff --git a/lib/iovec.c b/lib/iovec.c
index 454baa8..7a7c2da 100644
--- a/lib/iovec.c
+++ b/lib/iovec.c
@@ -51,3 +51,58 @@ int memcpy_toiovec(struct iovec *iov, unsigned char *kdata, int len)
 	return 0;
 }
 EXPORT_SYMBOL(memcpy_toiovec);
+
+/*
+ *	Copy kernel to iovec. Returns -EFAULT on error.
+ */
+
+int memcpy_toiovecend(const struct iovec *iov, unsigned char *kdata,
+		      int offset, int len)
+{
+	int copy;
+	for (; len > 0; ++iov) {
+		/* Skip over the finished iovecs */
+		if (unlikely(offset >= iov->iov_len)) {
+			offset -= iov->iov_len;
+			continue;
+		}
+		copy = min_t(unsigned int, iov->iov_len - offset, len);
+		if (copy_to_user(iov->iov_base + offset, kdata, copy))
+			return -EFAULT;
+		offset = 0;
+		kdata += copy;
+		len -= copy;
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL(memcpy_toiovecend);
+
+/*
+ *	Copy iovec to kernel. Returns -EFAULT on error.
+ */
+
+int memcpy_fromiovecend(unsigned char *kdata, const struct iovec *iov,
+			int offset, int len)
+{
+	/* Skip over the finished iovecs */
+	while (offset >= iov->iov_len) {
+		offset -= iov->iov_len;
+		iov++;
+	}
+
+	while (len > 0) {
+		u8 __user *base = iov->iov_base + offset;
+		int copy = min_t(unsigned int, len, iov->iov_len - offset);
+
+		offset = 0;
+		if (copy_from_user(kdata, base, copy))
+			return -EFAULT;
+		len -= copy;
+		kdata += copy;
+		iov++;
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL(memcpy_fromiovecend);
diff --git a/net/core/iovec.c b/net/core/iovec.c
index b618694..827dd6b 100644
--- a/net/core/iovec.c
+++ b/net/core/iovec.c
@@ -75,61 +75,6 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
 }
 
 /*
- *	Copy kernel to iovec. Returns -EFAULT on error.
- */
-
-int memcpy_toiovecend(const struct iovec *iov, unsigned char *kdata,
-		      int offset, int len)
-{
-	int copy;
-	for (; len > 0; ++iov) {
-		/* Skip over the finished iovecs */
-		if (unlikely(offset >= iov->iov_len)) {
-			offset -= iov->iov_len;
-			continue;
-		}
-		copy = min_t(unsigned int, iov->iov_len - offset, len);
-		if (copy_to_user(iov->iov_base + offset, kdata, copy))
-			return -EFAULT;
-		offset = 0;
-		kdata += copy;
-		len -= copy;
-	}
-
-	return 0;
-}
-EXPORT_SYMBOL(memcpy_toiovecend);
-
-/*
- *	Copy iovec to kernel. Returns -EFAULT on error.
- */
-
-int memcpy_fromiovecend(unsigned char *kdata, const struct iovec *iov,
-			int offset, int len)
-{
-	/* Skip over the finished iovecs */
-	while (offset >= iov->iov_len) {
-		offset -= iov->iov_len;
-		iov++;
-	}
-
-	while (len > 0) {
-		u8 __user *base = iov->iov_base + offset;
-		int copy = min_t(unsigned int, len, iov->iov_len - offset);
-
-		offset = 0;
-		if (copy_from_user(kdata, base, copy))
-			return -EFAULT;
-		len -= copy;
-		kdata += copy;
-		iov++;
-	}
-
-	return 0;
-}
-EXPORT_SYMBOL(memcpy_fromiovecend);
-
-/*
  *	And now for the all-in-one: copy and checksum from a user iovec
  *	directly to a datagram
  *	Calls to csum_partial but the last must be in 32 bit chunks
-- 
MST

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] iovec: move memcpy_from/toiovecend to lib/iovec.c
  2014-06-19 18:22 [PATCH] iovec: move memcpy_from/toiovecend to lib/iovec.c Michael S. Tsirkin
@ 2014-06-19 19:12 ` Randy Dunlap
  2014-06-20  4:06 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: Randy Dunlap @ 2014-06-19 19:12 UTC (permalink / raw)
  To: Michael S. Tsirkin, linux-kernel
  Cc: Stephen Rothwell, Hans J. Koch, Greg Kroah-Hartman,
	David S. Miller, stephen hemminger, Sean Hefty, FX Le Bail,
	Jason Wang, Hannes Frederic Sowa, Zhi Yong Wu, Nicholas Bellinger,
	netdev

On 06/19/14 11:22, Michael S. Tsirkin wrote:
> ERROR: "memcpy_fromiovecend" [drivers/vhost/vhost_scsi.ko] undefined!
> 
> commit 9f977ef7b671f6169eca78bf40f230fe84b7c7e5
>     vhost-scsi: Include prot_bytes into expected data transfer length
> in target-pending makes drivers/vhost/scsi.c call memcpy_fromiovecend().
> This function is not available when CONFIG_NET is not enabled.
> 
> socket.h already includes uio.h, so no callers need updating.
> 
> Reported-by: Randy Dunlap <rdunlap@infradead.org>
> Cc: Stephen Rothwell <sfr@canb.auug.org.au>
> Cc: "David S. Miller" <davem@davemloft.net>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

Acked-by: Randy Dunlap <rdunlap@infradead.org> [build-tested]

Thanks.

> ---
> 
> David, could you please ack merging this through
> target-pending to avoid dependency issues?
> 
> Thanks!
> 
>  include/linux/socket.h |  4 ----
>  include/linux/uio.h    |  4 ++++
>  lib/iovec.c            | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  net/core/iovec.c       | 55 --------------------------------------------------
>  4 files changed, 59 insertions(+), 59 deletions(-)
> 
> diff --git a/include/linux/socket.h b/include/linux/socket.h
> index 8e98297..ec538fc 100644
> --- a/include/linux/socket.h
> +++ b/include/linux/socket.h
> @@ -305,8 +305,6 @@ struct ucred {
>  /* IPX options */
>  #define IPX_TYPE	1
>  
> -extern int memcpy_fromiovecend(unsigned char *kdata, const struct iovec *iov,
> -			       int offset, int len);
>  extern int csum_partial_copy_fromiovecend(unsigned char *kdata, 
>  					  struct iovec *iov, 
>  					  int offset, 
> @@ -315,8 +313,6 @@ extern unsigned long iov_pages(const struct iovec *iov, int offset,
>  			       unsigned long nr_segs);
>  
>  extern int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *address, int mode);
> -extern int memcpy_toiovecend(const struct iovec *v, unsigned char *kdata,
> -			     int offset, int len);
>  extern int move_addr_to_kernel(void __user *uaddr, int ulen, struct sockaddr_storage *kaddr);
>  extern int put_cmsg(struct msghdr*, int level, int type, int len, void *data);
>  
> diff --git a/include/linux/uio.h b/include/linux/uio.h
> index 199bcc3..8a4709a 100644
> --- a/include/linux/uio.h
> +++ b/include/linux/uio.h
> @@ -89,5 +89,9 @@ static inline size_t iov_iter_count(struct iov_iter *i)
>  
>  int memcpy_fromiovec(unsigned char *kdata, struct iovec *iov, int len);
>  int memcpy_toiovec(struct iovec *iov, unsigned char *kdata, int len);
> +int memcpy_fromiovecend(unsigned char *kdata, const struct iovec *iov,
> +			int offset, int len);
> +int memcpy_toiovecend(const struct iovec *v, unsigned char *kdata,
> +		      int offset, int len);
>  
>  #endif
> diff --git a/lib/iovec.c b/lib/iovec.c
> index 454baa8..7a7c2da 100644
> --- a/lib/iovec.c
> +++ b/lib/iovec.c
> @@ -51,3 +51,58 @@ int memcpy_toiovec(struct iovec *iov, unsigned char *kdata, int len)
>  	return 0;
>  }
>  EXPORT_SYMBOL(memcpy_toiovec);
> +
> +/*
> + *	Copy kernel to iovec. Returns -EFAULT on error.
> + */
> +
> +int memcpy_toiovecend(const struct iovec *iov, unsigned char *kdata,
> +		      int offset, int len)
> +{
> +	int copy;
> +	for (; len > 0; ++iov) {
> +		/* Skip over the finished iovecs */
> +		if (unlikely(offset >= iov->iov_len)) {
> +			offset -= iov->iov_len;
> +			continue;
> +		}
> +		copy = min_t(unsigned int, iov->iov_len - offset, len);
> +		if (copy_to_user(iov->iov_base + offset, kdata, copy))
> +			return -EFAULT;
> +		offset = 0;
> +		kdata += copy;
> +		len -= copy;
> +	}
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(memcpy_toiovecend);
> +
> +/*
> + *	Copy iovec to kernel. Returns -EFAULT on error.
> + */
> +
> +int memcpy_fromiovecend(unsigned char *kdata, const struct iovec *iov,
> +			int offset, int len)
> +{
> +	/* Skip over the finished iovecs */
> +	while (offset >= iov->iov_len) {
> +		offset -= iov->iov_len;
> +		iov++;
> +	}
> +
> +	while (len > 0) {
> +		u8 __user *base = iov->iov_base + offset;
> +		int copy = min_t(unsigned int, len, iov->iov_len - offset);
> +
> +		offset = 0;
> +		if (copy_from_user(kdata, base, copy))
> +			return -EFAULT;
> +		len -= copy;
> +		kdata += copy;
> +		iov++;
> +	}
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(memcpy_fromiovecend);
> diff --git a/net/core/iovec.c b/net/core/iovec.c
> index b618694..827dd6b 100644
> --- a/net/core/iovec.c
> +++ b/net/core/iovec.c
> @@ -75,61 +75,6 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
>  }
>  
>  /*
> - *	Copy kernel to iovec. Returns -EFAULT on error.
> - */
> -
> -int memcpy_toiovecend(const struct iovec *iov, unsigned char *kdata,
> -		      int offset, int len)
> -{
> -	int copy;
> -	for (; len > 0; ++iov) {
> -		/* Skip over the finished iovecs */
> -		if (unlikely(offset >= iov->iov_len)) {
> -			offset -= iov->iov_len;
> -			continue;
> -		}
> -		copy = min_t(unsigned int, iov->iov_len - offset, len);
> -		if (copy_to_user(iov->iov_base + offset, kdata, copy))
> -			return -EFAULT;
> -		offset = 0;
> -		kdata += copy;
> -		len -= copy;
> -	}
> -
> -	return 0;
> -}
> -EXPORT_SYMBOL(memcpy_toiovecend);
> -
> -/*
> - *	Copy iovec to kernel. Returns -EFAULT on error.
> - */
> -
> -int memcpy_fromiovecend(unsigned char *kdata, const struct iovec *iov,
> -			int offset, int len)
> -{
> -	/* Skip over the finished iovecs */
> -	while (offset >= iov->iov_len) {
> -		offset -= iov->iov_len;
> -		iov++;
> -	}
> -
> -	while (len > 0) {
> -		u8 __user *base = iov->iov_base + offset;
> -		int copy = min_t(unsigned int, len, iov->iov_len - offset);
> -
> -		offset = 0;
> -		if (copy_from_user(kdata, base, copy))
> -			return -EFAULT;
> -		len -= copy;
> -		kdata += copy;
> -		iov++;
> -	}
> -
> -	return 0;
> -}
> -EXPORT_SYMBOL(memcpy_fromiovecend);
> -
> -/*
>   *	And now for the all-in-one: copy and checksum from a user iovec
>   *	directly to a datagram
>   *	Calls to csum_partial but the last must be in 32 bit chunks
> 


-- 
~Randy

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] iovec: move memcpy_from/toiovecend to lib/iovec.c
  2014-06-19 18:22 [PATCH] iovec: move memcpy_from/toiovecend to lib/iovec.c Michael S. Tsirkin
  2014-06-19 19:12 ` Randy Dunlap
@ 2014-06-20  4:06 ` David Miller
  2014-06-20 18:11   ` Nicholas A. Bellinger
  1 sibling, 1 reply; 4+ messages in thread
From: David Miller @ 2014-06-20  4:06 UTC (permalink / raw)
  To: mst
  Cc: linux-kernel, rdunlap, sfr, hjk, gregkh, stephen, sean.hefty,
	fx.lebail, jasowang, hannes, wuzhy, nab, netdev

From: "Michael S. Tsirkin" <mst@redhat.com>
Date: Thu, 19 Jun 2014 21:22:56 +0300

> ERROR: "memcpy_fromiovecend" [drivers/vhost/vhost_scsi.ko] undefined!
> 
> commit 9f977ef7b671f6169eca78bf40f230fe84b7c7e5
>     vhost-scsi: Include prot_bytes into expected data transfer length
> in target-pending makes drivers/vhost/scsi.c call memcpy_fromiovecend().
> This function is not available when CONFIG_NET is not enabled.
> 
> socket.h already includes uio.h, so no callers need updating.
> 
> Reported-by: Randy Dunlap <rdunlap@infradead.org>
> Cc: Stephen Rothwell <sfr@canb.auug.org.au>
> Cc: "David S. Miller" <davem@davemloft.net>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> 
> David, could you please ack merging this through
> target-pending to avoid dependency issues?

Yep, this looks fine:

Signed-off-by: David S. Miller <davem@davemloft.net>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] iovec: move memcpy_from/toiovecend to lib/iovec.c
  2014-06-20  4:06 ` David Miller
@ 2014-06-20 18:11   ` Nicholas A. Bellinger
  0 siblings, 0 replies; 4+ messages in thread
From: Nicholas A. Bellinger @ 2014-06-20 18:11 UTC (permalink / raw)
  To: David Miller
  Cc: mst, linux-kernel, rdunlap, sfr, hjk, gregkh, stephen, sean.hefty,
	fx.lebail, jasowang, hannes, wuzhy, netdev

On Thu, 2014-06-19 at 21:06 -0700, David Miller wrote:
> From: "Michael S. Tsirkin" <mst@redhat.com>
> Date: Thu, 19 Jun 2014 21:22:56 +0300
> 
> > ERROR: "memcpy_fromiovecend" [drivers/vhost/vhost_scsi.ko] undefined!
> > 
> > commit 9f977ef7b671f6169eca78bf40f230fe84b7c7e5
> >     vhost-scsi: Include prot_bytes into expected data transfer length
> > in target-pending makes drivers/vhost/scsi.c call memcpy_fromiovecend().
> > This function is not available when CONFIG_NET is not enabled.
> > 
> > socket.h already includes uio.h, so no callers need updating.
> > 
> > Reported-by: Randy Dunlap <rdunlap@infradead.org>
> > Cc: Stephen Rothwell <sfr@canb.auug.org.au>
> > Cc: "David S. Miller" <davem@davemloft.net>
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > ---
> > 
> > David, could you please ack merging this through
> > target-pending to avoid dependency issues?
> 
> Yep, this looks fine:
> 
> Signed-off-by: David S. Miller <davem@davemloft.net>

Applied to target-pending/queue, and will include in the next PULL
request.

Thanks folks.

--nab

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-06-20 18:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-19 18:22 [PATCH] iovec: move memcpy_from/toiovecend to lib/iovec.c Michael S. Tsirkin
2014-06-19 19:12 ` Randy Dunlap
2014-06-20  4:06 ` David Miller
2014-06-20 18:11   ` Nicholas A. Bellinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).