From: Paolo Bonzini <pbonzini@redhat.com>
To: "Nicholas A. Bellinger" <nab@daterainc.com>,
target-devel <target-devel@vger.kernel.org>
Cc: linux-scsi <linux-scsi@vger.kernel.org>,
kvm-devel <kvm@vger.kernel.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
Nicholas Bellinger <nab@linux-iscsi.org>
Subject: Re: [PATCH 1/8] lib/iovec: Add memcpy_fromiovec_out library function
Date: Fri, 30 Jan 2015 10:33:32 +0100 [thread overview]
Message-ID: <54CB4FEC.7080908@redhat.com> (raw)
In-Reply-To: <1422605552-24797-2-git-send-email-nab@daterainc.com>
On 30/01/2015 09:12, Nicholas A. Bellinger wrote:
> From: Nicholas Bellinger <nab@linux-iscsi.org>
>
> This patch adds a new memcpy_fromiovec_out() library function which modifies
> the passed *iov following memcpy_fromiovec(), but also returns the next current
> iovec pointer via **iov_out.
>
> This is useful for vhost ANY_LAYOUT support when guests are allowed to generate
> incoming virtio request headers combined with subsequent SGL payloads into a
> single iovec.
>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
> ---
> include/linux/uio.h | 2 ++
> lib/iovec.c | 27 +++++++++++++++++++++++++++
> 2 files changed, 29 insertions(+)
>
> diff --git a/include/linux/uio.h b/include/linux/uio.h
> index 1c5e453..3e4473d 100644
> --- a/include/linux/uio.h
> +++ b/include/linux/uio.h
> @@ -136,6 +136,8 @@ size_t csum_and_copy_to_iter(void *addr, size_t bytes, __wsum *csum, struct iov_
> size_t csum_and_copy_from_iter(void *addr, size_t bytes, __wsum *csum, struct iov_iter *i);
>
> int memcpy_fromiovec(unsigned char *kdata, struct iovec *iov, int len);
> +int memcpy_fromiovec_out(unsigned char *kdata, struct iovec *iov,
> + struct iovec **iov_out, 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,
> diff --git a/lib/iovec.c b/lib/iovec.c
> index 2d99cb4..6a813dd 100644
> --- a/lib/iovec.c
> +++ b/lib/iovec.c
> @@ -28,6 +28,33 @@ int memcpy_fromiovec(unsigned char *kdata, struct iovec *iov, int len)
> EXPORT_SYMBOL(memcpy_fromiovec);
>
> /*
> + * Copy iovec to kernel, saving the current iov to *iov_out.
> + * Returns -EFAULT on error.
Perhaps document that iov is modified, zeroing everything in [iov,
*iov_out) and possibly removing the front of *iov_out?
Paolo
> + */
> +
> +int memcpy_fromiovec_out(unsigned char *kdata, struct iovec *iov,
> + struct iovec **iov_out, int len)
> +{
> + while (len > 0) {
> + if (iov->iov_len) {
> + int copy = min_t(unsigned int, len, iov->iov_len);
> + if (copy_from_user(kdata, iov->iov_base, copy))
> + return -EFAULT;
> + len -= copy;
> + kdata += copy;
> + iov->iov_base += copy;
> + iov->iov_len -= copy;
> + }
> + if (!iov->iov_len)
> + iov++;
> + }
> + *iov_out = iov;
> +
> + return 0;
> +}
> +EXPORT_SYMBOL(memcpy_fromiovec_out);
> +
> +/*
> * Copy kernel to iovec. Returns -EFAULT on error.
> */
>
>
next prev parent reply other threads:[~2015-01-30 9:33 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-30 8:12 [PATCH 0/8] vhost/scsi: Add ANY_LAYOUT support Nicholas A. Bellinger
2015-01-30 8:12 ` [PATCH 1/8] lib/iovec: Add memcpy_fromiovec_out library function Nicholas A. Bellinger
2015-01-30 9:33 ` Paolo Bonzini [this message]
2015-02-01 7:15 ` Nicholas A. Bellinger
2015-01-30 8:12 ` [PATCH 2/8] vhost/scsi: Convert completion path to use memcpy_toiovecend Nicholas A. Bellinger
2015-01-30 8:12 ` [PATCH 3/8] vhost/scsi: Fix incorrect early vhost_scsi_handle_vq failures Nicholas A. Bellinger
2015-01-30 8:12 ` [PATCH 4/8] vhost/scsi: Change vhost_scsi_map_to_sgl to accept iov ptr + len Nicholas A. Bellinger
2015-01-30 10:51 ` Michael S. Tsirkin
2015-02-01 7:24 ` Nicholas A. Bellinger
2015-01-30 8:12 ` [PATCH 5/8] vhost/scsi: Add common vhost_scsi_queue_desc code Nicholas A. Bellinger
2015-01-30 8:12 ` [PATCH 6/8] vhost/scsi: Add ANY_LAYOUT prerequisites Nicholas A. Bellinger
2015-01-30 8:12 ` [PATCH 7/8] vhost/scsi: Add ANY_LAYOUT support Nicholas A. Bellinger
2015-01-30 8:12 ` [PATCH 8/8] vhost/scsi: Set VIRTIO_F_ANY_LAYOUT + VIRTIO_F_VERSION_1 feature bits Nicholas A. Bellinger
2015-02-02 8:15 ` [PATCH 0/8] vhost/scsi: Add ANY_LAYOUT support Christoph Hellwig
2015-02-03 0:22 ` Nicholas A. Bellinger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54CB4FEC.7080908@redhat.com \
--to=pbonzini@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=mst@redhat.com \
--cc=nab@daterainc.com \
--cc=nab@linux-iscsi.org \
--cc=target-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).