[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1704919215-91319-7-git-send-email-steven.sistare@oracle.com>
Date: Wed, 10 Jan 2024 12:40:08 -0800
From: Steve Sistare <steven.sistare@...cle.com>
To: virtualization@...ts.linux-foundation.org, linux-kernel@...r.kernel.org
Cc: "Michael S. Tsirkin" <mst@...hat.com>, Jason Wang <jasowang@...hat.com>,
Si-Wei Liu <si-wei.liu@...cle.com>,
Eugenio Perez Martin <eperezma@...hat.com>,
Xuan Zhuo <xuanzhuo@...ux.alibaba.com>,
Dragos Tatulea <dtatulea@...dia.com>, Eli Cohen <elic@...dia.com>,
Xie Yongji <xieyongji@...edance.com>,
Steve Sistare <steven.sistare@...cle.com>
Subject: [RFC V1 06/13] vhost-vdpa: VHOST_BACKEND_F_IOTLB_REMAP
Add the VHOST_BACKEND_F_IOTLB_REMAP backend capability, which indicates
that VHOST_IOTLB_REMAP is supported.
If VHOST_BACKEND_F_IOTLB_REMAP is advertised, then the user must call
VHOST_IOTLB_REMAP after ownership of a device is transferred to a new
process via VHOST_NEW_OWNER. Disabling the feature during negotiation
does not negate this requirement.
Signed-off-by: Steve Sistare <steven.sistare@...cle.com>
---
drivers/vhost/vdpa.c | 8 +++++++-
include/uapi/linux/vhost_types.h | 2 ++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
index ec5ca20bd47d..8fe1562d24af 100644
--- a/drivers/vhost/vdpa.c
+++ b/drivers/vhost/vdpa.c
@@ -789,7 +789,8 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep,
BIT_ULL(VHOST_BACKEND_F_SUSPEND) |
BIT_ULL(VHOST_BACKEND_F_RESUME) |
BIT_ULL(VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK) |
- BIT_ULL(VHOST_BACKEND_F_NEW_OWNER)))
+ BIT_ULL(VHOST_BACKEND_F_NEW_OWNER) |
+ BIT_ULL(VHOST_BACKEND_F_IOTLB_REMAP)))
return -EOPNOTSUPP;
if ((features & BIT_ULL(VHOST_BACKEND_F_SUSPEND)) &&
!vhost_vdpa_can_suspend(v))
@@ -1229,11 +1230,16 @@ static int vhost_vdpa_process_iotlb_remap(struct vhost_vdpa *v,
u64 start = msg->iova;
u64 last = start + msg->size - 1;
struct vhost_iotlb_map *map;
+ u64 features;
int r = 0;
if (msg->perm || !msg->size)
return -EINVAL;
+ features = ops->get_backend_features(vdpa);
+ if (!(features & BIT_ULL(VHOST_BACKEND_F_IOTLB_REMAP)))
+ return -EOPNOTSUPP;
+
map = vhost_iotlb_itree_first(iotlb, start, last);
if (!map)
return -ENOENT;
diff --git a/include/uapi/linux/vhost_types.h b/include/uapi/linux/vhost_types.h
index 35908315ff55..7e79e9bd0f7b 100644
--- a/include/uapi/linux/vhost_types.h
+++ b/include/uapi/linux/vhost_types.h
@@ -203,5 +203,7 @@ struct vhost_vdpa_iova_range {
#define VHOST_BACKEND_F_IOTLB_PERSIST 0x8
/* Supports VHOST_NEW_OWNER */
#define VHOST_BACKEND_F_NEW_OWNER 0x9
+/* Supports VHOST_IOTLB_REMAP */
+#define VHOST_BACKEND_F_IOTLB_REMAP 0xa
#endif
--
2.39.3
Powered by blists - more mailing lists