* [PATCH] vringh: don't use vringh_kiov_advance() in vringh_iov_xfer()
@ 2023-09-25 10:30 ` Stefano Garzarella
0 siblings, 0 replies; 5+ messages in thread
From: Stefano Garzarella @ 2023-09-25 10:30 UTC (permalink / raw)
To: virtualization
Cc: netdev, kvm, Michael S. Tsirkin, Stefano Garzarella, Jason Wang,
linux-kernel
In the while loop of vringh_iov_xfer(), `partlen` could be 0 if one of
the `iov` has 0 lenght.
In this case, we should skip the iov and go to the next one.
But calling vringh_kiov_advance() with 0 lenght does not cause the
advancement, since it returns immediately if asked to advance by 0 bytes.
Let's restore the code that was there before commit b8c06ad4d67d
("vringh: implement vringh_kiov_advance()"), avoiding using
vringh_kiov_advance().
Fixes: b8c06ad4d67d ("vringh: implement vringh_kiov_advance()")
Cc: stable@vger.kernel.org
Reported-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
---
drivers/vhost/vringh.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
index 955d938eb663..7b8fd977f71c 100644
--- a/drivers/vhost/vringh.c
+++ b/drivers/vhost/vringh.c
@@ -123,8 +123,18 @@ static inline ssize_t vringh_iov_xfer(struct vringh *vrh,
done += partlen;
len -= partlen;
ptr += partlen;
+ iov->consumed += partlen;
+ iov->iov[iov->i].iov_len -= partlen;
+ iov->iov[iov->i].iov_base += partlen;
- vringh_kiov_advance(iov, partlen);
+ if (!iov->iov[iov->i].iov_len) {
+ /* Fix up old iov element then increment. */
+ iov->iov[iov->i].iov_len = iov->consumed;
+ iov->iov[iov->i].iov_base -= iov->consumed;
+
+ iov->consumed = 0;
+ iov->i++;
+ }
}
return done;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH] vringh: don't use vringh_kiov_advance() in vringh_iov_xfer()
@ 2023-09-25 10:30 ` Stefano Garzarella
0 siblings, 0 replies; 5+ messages in thread
From: Stefano Garzarella @ 2023-09-25 10:30 UTC (permalink / raw)
To: virtualization; +Cc: kvm, Michael S. Tsirkin, netdev, linux-kernel
In the while loop of vringh_iov_xfer(), `partlen` could be 0 if one of
the `iov` has 0 lenght.
In this case, we should skip the iov and go to the next one.
But calling vringh_kiov_advance() with 0 lenght does not cause the
advancement, since it returns immediately if asked to advance by 0 bytes.
Let's restore the code that was there before commit b8c06ad4d67d
("vringh: implement vringh_kiov_advance()"), avoiding using
vringh_kiov_advance().
Fixes: b8c06ad4d67d ("vringh: implement vringh_kiov_advance()")
Cc: stable@vger.kernel.org
Reported-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
---
drivers/vhost/vringh.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
index 955d938eb663..7b8fd977f71c 100644
--- a/drivers/vhost/vringh.c
+++ b/drivers/vhost/vringh.c
@@ -123,8 +123,18 @@ static inline ssize_t vringh_iov_xfer(struct vringh *vrh,
done += partlen;
len -= partlen;
ptr += partlen;
+ iov->consumed += partlen;
+ iov->iov[iov->i].iov_len -= partlen;
+ iov->iov[iov->i].iov_base += partlen;
- vringh_kiov_advance(iov, partlen);
+ if (!iov->iov[iov->i].iov_len) {
+ /* Fix up old iov element then increment. */
+ iov->iov[iov->i].iov_len = iov->consumed;
+ iov->iov[iov->i].iov_base -= iov->consumed;
+
+ iov->consumed = 0;
+ iov->i++;
+ }
}
return done;
}
--
2.41.0
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] vringh: don't use vringh_kiov_advance() in vringh_iov_xfer()
2023-09-25 10:30 ` Stefano Garzarella
@ 2023-09-26 2:57 ` Jason Wang
-1 siblings, 0 replies; 5+ messages in thread
From: Jason Wang @ 2023-09-26 2:57 UTC (permalink / raw)
To: Stefano Garzarella
Cc: netdev, Michael S. Tsirkin, linux-kernel, kvm, virtualization
On Mon, Sep 25, 2023 at 6:31 PM Stefano Garzarella <sgarzare@redhat.com> wrote:
>
> In the while loop of vringh_iov_xfer(), `partlen` could be 0 if one of
> the `iov` has 0 lenght.
> In this case, we should skip the iov and go to the next one.
> But calling vringh_kiov_advance() with 0 lenght does not cause the
> advancement, since it returns immediately if asked to advance by 0 bytes.
>
> Let's restore the code that was there before commit b8c06ad4d67d
> ("vringh: implement vringh_kiov_advance()"), avoiding using
> vringh_kiov_advance().
>
> Fixes: b8c06ad4d67d ("vringh: implement vringh_kiov_advance()")
> Cc: stable@vger.kernel.org
> Reported-by: Jason Wang <jasowang@redhat.com>
> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Thanks
> ---
> drivers/vhost/vringh.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
> index 955d938eb663..7b8fd977f71c 100644
> --- a/drivers/vhost/vringh.c
> +++ b/drivers/vhost/vringh.c
> @@ -123,8 +123,18 @@ static inline ssize_t vringh_iov_xfer(struct vringh *vrh,
> done += partlen;
> len -= partlen;
> ptr += partlen;
> + iov->consumed += partlen;
> + iov->iov[iov->i].iov_len -= partlen;
> + iov->iov[iov->i].iov_base += partlen;
>
> - vringh_kiov_advance(iov, partlen);
> + if (!iov->iov[iov->i].iov_len) {
> + /* Fix up old iov element then increment. */
> + iov->iov[iov->i].iov_len = iov->consumed;
> + iov->iov[iov->i].iov_base -= iov->consumed;
> +
> + iov->consumed = 0;
> + iov->i++;
> + }
> }
> return done;
> }
> --
> 2.41.0
>
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] vringh: don't use vringh_kiov_advance() in vringh_iov_xfer()
@ 2023-09-26 2:57 ` Jason Wang
0 siblings, 0 replies; 5+ messages in thread
From: Jason Wang @ 2023-09-26 2:57 UTC (permalink / raw)
To: Stefano Garzarella
Cc: virtualization, netdev, kvm, Michael S. Tsirkin, linux-kernel
On Mon, Sep 25, 2023 at 6:31 PM Stefano Garzarella <sgarzare@redhat.com> wrote:
>
> In the while loop of vringh_iov_xfer(), `partlen` could be 0 if one of
> the `iov` has 0 lenght.
> In this case, we should skip the iov and go to the next one.
> But calling vringh_kiov_advance() with 0 lenght does not cause the
> advancement, since it returns immediately if asked to advance by 0 bytes.
>
> Let's restore the code that was there before commit b8c06ad4d67d
> ("vringh: implement vringh_kiov_advance()"), avoiding using
> vringh_kiov_advance().
>
> Fixes: b8c06ad4d67d ("vringh: implement vringh_kiov_advance()")
> Cc: stable@vger.kernel.org
> Reported-by: Jason Wang <jasowang@redhat.com>
> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Thanks
> ---
> drivers/vhost/vringh.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
> index 955d938eb663..7b8fd977f71c 100644
> --- a/drivers/vhost/vringh.c
> +++ b/drivers/vhost/vringh.c
> @@ -123,8 +123,18 @@ static inline ssize_t vringh_iov_xfer(struct vringh *vrh,
> done += partlen;
> len -= partlen;
> ptr += partlen;
> + iov->consumed += partlen;
> + iov->iov[iov->i].iov_len -= partlen;
> + iov->iov[iov->i].iov_base += partlen;
>
> - vringh_kiov_advance(iov, partlen);
> + if (!iov->iov[iov->i].iov_len) {
> + /* Fix up old iov element then increment. */
> + iov->iov[iov->i].iov_len = iov->consumed;
> + iov->iov[iov->i].iov_base -= iov->consumed;
> +
> + iov->consumed = 0;
> + iov->i++;
> + }
> }
> return done;
> }
> --
> 2.41.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] vringh: don't use vringh_kiov_advance() in vringh_iov_xfer()
2023-09-25 10:30 ` Stefano Garzarella
(?)
(?)
@ 2023-10-04 7:30 ` patchwork-bot+netdevbpf
-1 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-10-04 7:30 UTC (permalink / raw)
To: Stefano Garzarella
Cc: virtualization, netdev, kvm, mst, jasowang, linux-kernel
Hello:
This patch was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:
On Mon, 25 Sep 2023 12:30:57 +0200 you wrote:
> In the while loop of vringh_iov_xfer(), `partlen` could be 0 if one of
> the `iov` has 0 lenght.
> In this case, we should skip the iov and go to the next one.
> But calling vringh_kiov_advance() with 0 lenght does not cause the
> advancement, since it returns immediately if asked to advance by 0 bytes.
>
> Let's restore the code that was there before commit b8c06ad4d67d
> ("vringh: implement vringh_kiov_advance()"), avoiding using
> vringh_kiov_advance().
>
> [...]
Here is the summary with links:
- vringh: don't use vringh_kiov_advance() in vringh_iov_xfer()
https://git.kernel.org/netdev/net/c/7aed44babc7f
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-10-04 7:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-25 10:30 [PATCH] vringh: don't use vringh_kiov_advance() in vringh_iov_xfer() Stefano Garzarella
2023-09-25 10:30 ` Stefano Garzarella
2023-09-26 2:57 ` Jason Wang
2023-09-26 2:57 ` Jason Wang
2023-10-04 7:30 ` patchwork-bot+netdevbpf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.