diff mbox series

vhost: allow batching hint without size

Message ID 20220310075211.4801-1-jasowang@redhat.com (mailing list archive)
State Not Applicable
Headers show
Series vhost: allow batching hint without size | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Jason Wang March 10, 2022, 7:52 a.m. UTC
Commit e2ae38cf3d91 ("vhost: fix hung thread due to erroneous iotlb
entries") tries to reject the IOTLB message whose size is zero. But
the size is not necessarily meaningful, one example is the batching
hint, so the commit breaks that.

Fixing this be reject zero size message only if the message is used to
update/invalidate the IOTLB.

Fixes: e2ae38cf3d91 ("vhost: fix hung thread due to erroneous iotlb entries")
Reported-by: Eli Cohen <elic@nvidia.com>
Cc: Anirudh Rayabharam <mail@anirudhrb.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 drivers/vhost/vhost.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Eli Cohen March 10, 2022, 10:59 a.m. UTC | #1
Tested-by: Eli Cohen <elic@nvidia.com>

> -----Original Message-----
> From: Jason Wang <jasowang@redhat.com>
> Sent: Thursday, March 10, 2022 9:52 AM
> To: mst@redhat.com
> Cc: kvm@vger.kernel.org; virtualization@lists.linux-foundation.org; netdev@vger.kernel.org; linux-kernel@vger.kernel.org; Jason Wang
> <jasowang@redhat.com>; Eli Cohen <elic@nvidia.com>; Anirudh Rayabharam <mail@anirudhrb.com>
> Subject: [PATCH] vhost: allow batching hint without size
> 
> Commit e2ae38cf3d91 ("vhost: fix hung thread due to erroneous iotlb
> entries") tries to reject the IOTLB message whose size is zero. But
> the size is not necessarily meaningful, one example is the batching
> hint, so the commit breaks that.
> 
> Fixing this be reject zero size message only if the message is used to
> update/invalidate the IOTLB.
> 
> Fixes: e2ae38cf3d91 ("vhost: fix hung thread due to erroneous iotlb entries")
> Reported-by: Eli Cohen <elic@nvidia.com>
> Cc: Anirudh Rayabharam <mail@anirudhrb.com>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
>  drivers/vhost/vhost.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
> index 082380c03a3e..1768362115c6 100644
> --- a/drivers/vhost/vhost.c
> +++ b/drivers/vhost/vhost.c
> @@ -1170,7 +1170,9 @@ ssize_t vhost_chr_write_iter(struct vhost_dev *dev,
>  		goto done;
>  	}
> 
> -	if (msg.size == 0) {
> +	if ((msg.type == VHOST_IOTLB_UPDATE ||
> +	     msg.type == VHOST_IOTLB_INVALIDATE) &&
> +	     msg.size == 0) {
>  		ret = -EINVAL;
>  		goto done;
>  	}
> --
> 2.18.1
diff mbox series

Patch

diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 082380c03a3e..1768362115c6 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -1170,7 +1170,9 @@  ssize_t vhost_chr_write_iter(struct vhost_dev *dev,
 		goto done;
 	}
 
-	if (msg.size == 0) {
+	if ((msg.type == VHOST_IOTLB_UPDATE ||
+	     msg.type == VHOST_IOTLB_INVALIDATE) &&
+	     msg.size == 0) {
 		ret = -EINVAL;
 		goto done;
 	}