netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vhost: Allow null msg.size on VHOST_IOTLB_INVALIDATE
@ 2023-08-23 15:30 Eric Auger
  2023-08-24  3:23 ` Jason Wang
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Auger @ 2023-08-23 15:30 UTC (permalink / raw)
  To: eric.auger.pro, eric.auger, elic, mail, jasowang, mst,
	linux-kernel, kvm, kvmarm, netdev, virtualization

Commit e2ae38cf3d91 ("vhost: fix hung thread due to erroneous iotlb
entries") Forbade vhost iotlb msg with null size to prevent entries
with size = start = 0 and last = ULONG_MAX to end up in the iotlb.

Then commit 95932ab2ea07 ("vhost: allow batching hint without size")
only applied the check for VHOST_IOTLB_UPDATE and VHOST_IOTLB_INVALIDATE
message types to fix a regression observed with batching hit.

Still, the introduction of that check introduced a regression for
some users attempting to invalidate the whole ULONG_MAX range by
setting the size to 0. This is the case with qemu/smmuv3/vhost
integration which does not work anymore. It Looks safe to partially
revert the original commit and allow VHOST_IOTLB_INVALIDATE messages
with null size. vhost_iotlb_del_range() will compute a correct end
iova. Same for vhost_vdpa_iotlb_unmap().

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Fixes: e2ae38cf3d91 ("vhost: fix hung thread due to erroneous iotlb entries")
---
 drivers/vhost/vhost.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

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


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

* Re: [PATCH] vhost: Allow null msg.size on VHOST_IOTLB_INVALIDATE
  2023-08-23 15:30 [PATCH] vhost: Allow null msg.size on VHOST_IOTLB_INVALIDATE Eric Auger
@ 2023-08-24  3:23 ` Jason Wang
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Wang @ 2023-08-24  3:23 UTC (permalink / raw)
  To: Eric Auger
  Cc: eric.auger.pro, elic, mail, mst, linux-kernel, kvm, kvmarm,
	netdev, virtualization

On Wed, Aug 23, 2023 at 11:30 PM Eric Auger <eric.auger@redhat.com> wrote:
>
> Commit e2ae38cf3d91 ("vhost: fix hung thread due to erroneous iotlb
> entries") Forbade vhost iotlb msg with null size to prevent entries
> with size = start = 0 and last = ULONG_MAX to end up in the iotlb.
>
> Then commit 95932ab2ea07 ("vhost: allow batching hint without size")
> only applied the check for VHOST_IOTLB_UPDATE and VHOST_IOTLB_INVALIDATE
> message types to fix a regression observed with batching hit.
>
> Still, the introduction of that check introduced a regression for
> some users attempting to invalidate the whole ULONG_MAX range by
> setting the size to 0. This is the case with qemu/smmuv3/vhost
> integration which does not work anymore. It Looks safe to partially
> revert the original commit and allow VHOST_IOTLB_INVALIDATE messages
> with null size. vhost_iotlb_del_range() will compute a correct end
> iova. Same for vhost_vdpa_iotlb_unmap().
>
> Signed-off-by: Eric Auger <eric.auger@redhat.com>

Cc: stable@vger.kernel.org

I think we need to document the usage of 0 as msg.size for
IOTLB_INVALIDATE in uapi.

Other than this:

Acked-by: Jason Wang <jasowang@redhat.com>

Thanks

> Fixes: e2ae38cf3d91 ("vhost: fix hung thread due to erroneous iotlb entries")
> ---
>  drivers/vhost/vhost.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
> index c71d573f1c94..e0c181ad17e3 100644
> --- a/drivers/vhost/vhost.c
> +++ b/drivers/vhost/vhost.c
> @@ -1458,9 +1458,7 @@ ssize_t vhost_chr_write_iter(struct vhost_dev *dev,
>                 goto done;
>         }
>
> -       if ((msg.type == VHOST_IOTLB_UPDATE ||
> -            msg.type == VHOST_IOTLB_INVALIDATE) &&
> -            msg.size == 0) {
> +       if (msg.type == VHOST_IOTLB_UPDATE && msg.size == 0) {
>                 ret = -EINVAL;
>                 goto done;
>         }
> --
> 2.41.0
>


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

end of thread, other threads:[~2023-08-24  3:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-23 15:30 [PATCH] vhost: Allow null msg.size on VHOST_IOTLB_INVALIDATE Eric Auger
2023-08-24  3:23 ` Jason Wang

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).