netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vdpa: reject F_ENABLE_AFTER_DRIVER_OK if backend does not support it
@ 2023-07-03 14:22 Eugenio Pérez
  2023-07-03 14:52 ` Michael S. Tsirkin
  0 siblings, 1 reply; 27+ messages in thread
From: Eugenio Pérez @ 2023-07-03 14:22 UTC (permalink / raw)
  To: mst
  Cc: Jason Wang, Eugenio Pérez, netdev, linux-kernel,
	Shannon Nelson, virtualization, kvm

With the current code it is accepted as long as userland send it.

Although userland should not set a feature flag that has not been
offered to it with VHOST_GET_BACKEND_FEATURES, the current code will not
complain for it.

Since there is no specific reason for any parent to reject that backend
feature bit when it has been proposed, let's control it at vdpa frontend
level. Future patches may move this control to the parent driver.

Fixes: 967800d2d52e ("vdpa: accept VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK backend feature")
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>

---
Sent with Fixes: tag pointing to git.kernel.org/pub/scm/linux/kernel/git/mst
commit. Please let me know if I should send a v3 of [1] instead.

[1] https://lore.kernel.org/lkml/20230609121244-mutt-send-email-mst@kernel.org/T/
---
 drivers/vhost/vdpa.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
index e1abf29fed5b..a7e554352351 100644
--- a/drivers/vhost/vdpa.c
+++ b/drivers/vhost/vdpa.c
@@ -681,18 +681,21 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep,
 {
 	struct vhost_vdpa *v = filep->private_data;
 	struct vhost_dev *d = &v->vdev;
+	const struct vdpa_config_ops *ops = v->vdpa->config;
 	void __user *argp = (void __user *)arg;
 	u64 __user *featurep = argp;
-	u64 features;
+	u64 features, parent_features = 0;
 	long r = 0;
 
 	if (cmd == VHOST_SET_BACKEND_FEATURES) {
 		if (copy_from_user(&features, featurep, sizeof(features)))
 			return -EFAULT;
+		if (ops->get_backend_features)
+			parent_features = ops->get_backend_features(v->vdpa);
 		if (features & ~(VHOST_VDPA_BACKEND_FEATURES |
 				 BIT_ULL(VHOST_BACKEND_F_SUSPEND) |
 				 BIT_ULL(VHOST_BACKEND_F_RESUME) |
-				 BIT_ULL(VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK)))
+				 parent_features))
 			return -EOPNOTSUPP;
 		if ((features & BIT_ULL(VHOST_BACKEND_F_SUSPEND)) &&
 		     !vhost_vdpa_can_suspend(v))
-- 
2.39.3


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

end of thread, other threads:[~2023-07-20  0:03 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-03 14:22 [PATCH] vdpa: reject F_ENABLE_AFTER_DRIVER_OK if backend does not support it Eugenio Pérez
2023-07-03 14:52 ` Michael S. Tsirkin
2023-07-04 10:25   ` Eugenio Perez Martin
2023-07-04 10:38     ` Michael S. Tsirkin
2023-07-04 11:36       ` Eugenio Perez Martin
2023-07-04 15:45         ` Michael S. Tsirkin
2023-07-05  7:49           ` Jason Wang
2023-07-05  8:41             ` Michael S. Tsirkin
2023-07-06  1:55               ` Jason Wang
2023-07-06  7:05                 ` Eugenio Perez Martin
2023-07-06  7:55                   ` Jason Wang
2023-07-06  8:03                     ` Jason Wang
2023-07-06  9:38                       ` Eugenio Perez Martin
2023-07-07  7:57                         ` Jason Wang
2023-07-07 10:25                           ` Eugenio Perez Martin
2023-07-05 18:27             ` Eugenio Perez Martin
2023-07-06  0:07               ` Shannon Nelson
2023-07-06  6:07                 ` Michael S. Tsirkin
2023-07-06  6:35                   ` Eugenio Perez Martin
2023-07-06  6:39                     ` Michael S. Tsirkin
2023-07-19 22:20                   ` Si-Wei Liu
2023-07-19 22:26                     ` Michael S. Tsirkin
2023-07-20  0:03                       ` Si-Wei Liu
2023-07-05  7:55       ` Jason Wang
2023-07-05  8:42         ` Michael S. Tsirkin
2023-07-06  1:56           ` Jason Wang
2023-07-06  6:05             ` Michael S. Tsirkin

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