Skip to contentSkip to conversation

vhost: allow batching hint without size

PATCH In review Jason Wang 2 participants 2 messages Mar 10, 2022

Subsystems (5)
lore
Share & tools
lore

Jason Wang

author
#0 lore raw

PATCH 1/1 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")
Cc Anirudh Rayabharam <[email protected]>
---
 drivers/vhost/vhost.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/vhost/vhost.c +3 -1
index 082380c03a3e..1768362115c6 100644
@@ -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;
 	}
Signature · 1 line
2.18.1
Tested-by on v1 1/1
#1 lore raw
Quoted 41 lines

-----Original Message-----
From: Jason Wang <[email protected]>
Sent: Thursday, March 10, 2022 9:52 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Jason Wang <[email protected]>; Eli Cohen <[email protected]>; Anirudh Rayabharam <[email protected]>
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")
Cc Anirudh Rayabharam <[email protected]>
---
 drivers/vhost/vhost.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/vhost/vhost.c +3 -2
index 082380c03a3e..1768362115c6 100644
@@ -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