All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V3 0/3] vDPA: API for reporting IOVA range
@ 2020-10-23  2:24 ` Jason Wang
  0 siblings, 0 replies; 16+ messages in thread
From: Jason Wang @ 2020-10-23  2:24 UTC (permalink / raw)
  To: mst, virtualization, linux-kernel
  Cc: rob.miller, lingshan.zhu, eperezma, lulu, shahafs, hanand,
	mhabets, gdawar, saugatm, vmireyno, zhangweining, eli,
	Jason Wang

Hi All:

This series introduces API for reporing IOVA range. This is a must for
userspace to work correclty:

- for the process that uses vhost-vDPA directly, the IOVA must be
  allocated from this range.
- for VM(qemu), when vIOMMU is not enabled, fail early if GPA is out
  of range
- for VM(qemu), when vIOMMU is enabled, determine a valid guest
  address width and then guest IOVA allocator can behave correctly.

Please review.

Changes from V2:
- silent build warnings

Changes from V1:

- do not mandate get_iova_range() for device with its own DMA
  translation logic and assume a [0, ULLONG_MAX] range
- mandate IOVA range only for IOMMU that forcing aperture
- forbid the map which is out of the IOVA range in vhost-vDPA

Jason Wang (3):
  vdpa: introduce config op to get valid iova range
  vhost: vdpa: report iova range
  vdpa_sim: implement get_iova_range()

 drivers/vdpa/vdpa_sim/vdpa_sim.c | 12 ++++++++++
 drivers/vhost/vdpa.c             | 40 ++++++++++++++++++++++++++++++++
 include/linux/vdpa.h             | 15 ++++++++++++
 include/uapi/linux/vhost.h       |  4 ++++
 include/uapi/linux/vhost_types.h |  9 +++++++
 5 files changed, 80 insertions(+)

-- 
2.20.1


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

* [PATCH V3 0/3] vDPA: API for reporting IOVA range
@ 2020-10-23  2:24 ` Jason Wang
  0 siblings, 0 replies; 16+ messages in thread
From: Jason Wang @ 2020-10-23  2:24 UTC (permalink / raw)
  To: mst, virtualization, linux-kernel
  Cc: shahafs, lulu, saugatm, mhabets, vmireyno, gdawar, eperezma,
	hanand, zhangweining, eli, lingshan.zhu, rob.miller

Hi All:

This series introduces API for reporing IOVA range. This is a must for
userspace to work correclty:

- for the process that uses vhost-vDPA directly, the IOVA must be
  allocated from this range.
- for VM(qemu), when vIOMMU is not enabled, fail early if GPA is out
  of range
- for VM(qemu), when vIOMMU is enabled, determine a valid guest
  address width and then guest IOVA allocator can behave correctly.

Please review.

Changes from V2:
- silent build warnings

Changes from V1:

- do not mandate get_iova_range() for device with its own DMA
  translation logic and assume a [0, ULLONG_MAX] range
- mandate IOVA range only for IOMMU that forcing aperture
- forbid the map which is out of the IOVA range in vhost-vDPA

Jason Wang (3):
  vdpa: introduce config op to get valid iova range
  vhost: vdpa: report iova range
  vdpa_sim: implement get_iova_range()

 drivers/vdpa/vdpa_sim/vdpa_sim.c | 12 ++++++++++
 drivers/vhost/vdpa.c             | 40 ++++++++++++++++++++++++++++++++
 include/linux/vdpa.h             | 15 ++++++++++++
 include/uapi/linux/vhost.h       |  4 ++++
 include/uapi/linux/vhost_types.h |  9 +++++++
 5 files changed, 80 insertions(+)

-- 
2.20.1

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

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

* [PATCH V3 1/3] vdpa: introduce config op to get valid iova range
  2020-10-23  2:24 ` Jason Wang
@ 2020-10-23  2:24   ` Jason Wang
  -1 siblings, 0 replies; 16+ messages in thread
From: Jason Wang @ 2020-10-23  2:24 UTC (permalink / raw)
  To: mst, virtualization, linux-kernel
  Cc: rob.miller, lingshan.zhu, eperezma, lulu, shahafs, hanand,
	mhabets, gdawar, saugatm, vmireyno, zhangweining, eli,
	Jason Wang

This patch introduce a config op to get valid iova range from the vDPA
device.

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 include/linux/vdpa.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h
index eae0bfd87d91..30bc7a7223bb 100644
--- a/include/linux/vdpa.h
+++ b/include/linux/vdpa.h
@@ -52,6 +52,16 @@ struct vdpa_device {
 	int nvqs;
 };
 
+/**
+ * vDPA IOVA range - the IOVA range support by the device
+ * @first: start of the IOVA range
+ * @last: end of the IOVA range
+ */
+struct vdpa_iova_range {
+	u64 first;
+	u64 last;
+};
+
 /**
  * vDPA_config_ops - operations for configuring a vDPA device.
  * Note: vDPA device drivers are required to implement all of the
@@ -151,6 +161,10 @@ struct vdpa_device {
  * @get_generation:		Get device config generation (optional)
  *				@vdev: vdpa device
  *				Returns u32: device generation
+ * @get_iova_range:		Get supported iova range (optional)
+ *				@vdev: vdpa device
+ *				Returns the iova range supported by
+ *				the device.
  * @set_map:			Set device memory mapping (optional)
  *				Needed for device that using device
  *				specific DMA translation (on-chip IOMMU)
@@ -216,6 +230,7 @@ struct vdpa_config_ops {
 	void (*set_config)(struct vdpa_device *vdev, unsigned int offset,
 			   const void *buf, unsigned int len);
 	u32 (*get_generation)(struct vdpa_device *vdev);
+	struct vdpa_iova_range (*get_iova_range)(struct vdpa_device *vdev);
 
 	/* DMA ops */
 	int (*set_map)(struct vdpa_device *vdev, struct vhost_iotlb *iotlb);
-- 
2.20.1


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

* [PATCH V3 1/3] vdpa: introduce config op to get valid iova range
@ 2020-10-23  2:24   ` Jason Wang
  0 siblings, 0 replies; 16+ messages in thread
From: Jason Wang @ 2020-10-23  2:24 UTC (permalink / raw)
  To: mst, virtualization, linux-kernel
  Cc: shahafs, lulu, saugatm, mhabets, vmireyno, gdawar, eperezma,
	hanand, zhangweining, eli, lingshan.zhu, rob.miller

This patch introduce a config op to get valid iova range from the vDPA
device.

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 include/linux/vdpa.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h
index eae0bfd87d91..30bc7a7223bb 100644
--- a/include/linux/vdpa.h
+++ b/include/linux/vdpa.h
@@ -52,6 +52,16 @@ struct vdpa_device {
 	int nvqs;
 };
 
+/**
+ * vDPA IOVA range - the IOVA range support by the device
+ * @first: start of the IOVA range
+ * @last: end of the IOVA range
+ */
+struct vdpa_iova_range {
+	u64 first;
+	u64 last;
+};
+
 /**
  * vDPA_config_ops - operations for configuring a vDPA device.
  * Note: vDPA device drivers are required to implement all of the
@@ -151,6 +161,10 @@ struct vdpa_device {
  * @get_generation:		Get device config generation (optional)
  *				@vdev: vdpa device
  *				Returns u32: device generation
+ * @get_iova_range:		Get supported iova range (optional)
+ *				@vdev: vdpa device
+ *				Returns the iova range supported by
+ *				the device.
  * @set_map:			Set device memory mapping (optional)
  *				Needed for device that using device
  *				specific DMA translation (on-chip IOMMU)
@@ -216,6 +230,7 @@ struct vdpa_config_ops {
 	void (*set_config)(struct vdpa_device *vdev, unsigned int offset,
 			   const void *buf, unsigned int len);
 	u32 (*get_generation)(struct vdpa_device *vdev);
+	struct vdpa_iova_range (*get_iova_range)(struct vdpa_device *vdev);
 
 	/* DMA ops */
 	int (*set_map)(struct vdpa_device *vdev, struct vhost_iotlb *iotlb);
-- 
2.20.1

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

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

* [PATCH V3 2/3] vhost: vdpa: report iova range
  2020-10-23  2:24 ` Jason Wang
@ 2020-10-23  2:24   ` Jason Wang
  -1 siblings, 0 replies; 16+ messages in thread
From: Jason Wang @ 2020-10-23  2:24 UTC (permalink / raw)
  To: mst, virtualization, linux-kernel
  Cc: rob.miller, lingshan.zhu, eperezma, lulu, shahafs, hanand,
	mhabets, gdawar, saugatm, vmireyno, zhangweining, eli,
	Jason Wang

This patch introduces a new ioctl for vhost-vdpa device that can
report the iova range by the device.

For device that implements get_iova_range() method, we fetch it from
the vDPA device. If device doesn't implement get_iova_range() but
depends on platform IOMMU, we will query via DOMAIN_ATTR_GEOMETRY,
otherwise [0, ULLONG_MAX] is assumed.

For safety, this patch also rules out the map request which is not in
the valid range.

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 drivers/vhost/vdpa.c             | 40 ++++++++++++++++++++++++++++++++
 include/uapi/linux/vhost.h       |  4 ++++
 include/uapi/linux/vhost_types.h |  9 +++++++
 3 files changed, 53 insertions(+)

diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
index a2dbc85e0b0d..562ed99116d1 100644
--- a/drivers/vhost/vdpa.c
+++ b/drivers/vhost/vdpa.c
@@ -47,6 +47,7 @@ struct vhost_vdpa {
 	int minor;
 	struct eventfd_ctx *config_ctx;
 	int in_batch;
+	struct vdpa_iova_range range;
 };
 
 static DEFINE_IDA(vhost_vdpa_ida);
@@ -337,6 +338,16 @@ static long vhost_vdpa_set_config_call(struct vhost_vdpa *v, u32 __user *argp)
 	return 0;
 }
 
+static long vhost_vdpa_get_iova_range(struct vhost_vdpa *v, u32 __user *argp)
+{
+	struct vhost_vdpa_iova_range range = {
+		.first = v->range.first,
+		.last = v->range.last,
+	};
+
+	return copy_to_user(argp, &range, sizeof(range));
+}
+
 static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
 				   void __user *argp)
 {
@@ -470,6 +481,8 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep,
 	case VHOST_GET_BACKEND_FEATURES:
 		features = VHOST_VDPA_BACKEND_FEATURES;
 		r = copy_to_user(featurep, &features, sizeof(features));
+	case VHOST_VDPA_GET_IOVA_RANGE:
+		r = vhost_vdpa_get_iova_range(v, argp);
 		break;
 	default:
 		r = vhost_dev_ioctl(&v->vdev, cmd, argp);
@@ -597,6 +610,10 @@ static int vhost_vdpa_process_iotlb_update(struct vhost_vdpa *v,
 	long pinned;
 	int ret = 0;
 
+	if (msg->iova < v->range.first ||
+	    msg->iova + msg->size - 1 > v->range.last)
+		return -EINVAL;
+
 	if (vhost_iotlb_itree_first(iotlb, msg->iova,
 				    msg->iova + msg->size - 1))
 		return -EEXIST;
@@ -783,6 +800,27 @@ static void vhost_vdpa_free_domain(struct vhost_vdpa *v)
 	v->domain = NULL;
 }
 
+static void vhost_vdpa_set_iova_range(struct vhost_vdpa *v)
+{
+	struct vdpa_iova_range *range = &v->range;
+	struct iommu_domain_geometry geo;
+	struct vdpa_device *vdpa = v->vdpa;
+	const struct vdpa_config_ops *ops = vdpa->config;
+
+	if (ops->get_iova_range) {
+		*range = ops->get_iova_range(vdpa);
+	} else if (v->domain &&
+		   !iommu_domain_get_attr(v->domain,
+		   DOMAIN_ATTR_GEOMETRY, &geo) &&
+		   geo.force_aperture) {
+		range->first = geo.aperture_start;
+		range->last = geo.aperture_end;
+	} else {
+		range->first = 0;
+		range->last = ULLONG_MAX;
+	}
+}
+
 static int vhost_vdpa_open(struct inode *inode, struct file *filep)
 {
 	struct vhost_vdpa *v;
@@ -823,6 +861,8 @@ static int vhost_vdpa_open(struct inode *inode, struct file *filep)
 	if (r)
 		goto err_init_iotlb;
 
+	vhost_vdpa_set_iova_range(v);
+
 	filep->private_data = v;
 
 	return 0;
diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h
index 75232185324a..c998860d7bbc 100644
--- a/include/uapi/linux/vhost.h
+++ b/include/uapi/linux/vhost.h
@@ -146,4 +146,8 @@
 
 /* Set event fd for config interrupt*/
 #define VHOST_VDPA_SET_CONFIG_CALL	_IOW(VHOST_VIRTIO, 0x77, int)
+
+/* Get the valid iova range */
+#define VHOST_VDPA_GET_IOVA_RANGE	_IOR(VHOST_VIRTIO, 0x78, \
+					     struct vhost_vdpa_iova_range)
 #endif
diff --git a/include/uapi/linux/vhost_types.h b/include/uapi/linux/vhost_types.h
index 9a269a88a6ff..f7f6a3a28977 100644
--- a/include/uapi/linux/vhost_types.h
+++ b/include/uapi/linux/vhost_types.h
@@ -138,6 +138,15 @@ struct vhost_vdpa_config {
 	__u8 buf[0];
 };
 
+/* vhost vdpa IOVA range
+ * @first: First address that can be mapped by vhost-vDPA
+ * @last: Last address that can be mapped by vhost-vDPA
+ */
+struct vhost_vdpa_iova_range {
+	__u64 first;
+	__u64 last;
+};
+
 /* Feature bits */
 /* Log all write descriptors. Can be changed while device is active. */
 #define VHOST_F_LOG_ALL 26
-- 
2.20.1


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

* [PATCH V3 2/3] vhost: vdpa: report iova range
@ 2020-10-23  2:24   ` Jason Wang
  0 siblings, 0 replies; 16+ messages in thread
From: Jason Wang @ 2020-10-23  2:24 UTC (permalink / raw)
  To: mst, virtualization, linux-kernel
  Cc: shahafs, lulu, saugatm, mhabets, vmireyno, gdawar, eperezma,
	hanand, zhangweining, eli, lingshan.zhu, rob.miller

This patch introduces a new ioctl for vhost-vdpa device that can
report the iova range by the device.

For device that implements get_iova_range() method, we fetch it from
the vDPA device. If device doesn't implement get_iova_range() but
depends on platform IOMMU, we will query via DOMAIN_ATTR_GEOMETRY,
otherwise [0, ULLONG_MAX] is assumed.

For safety, this patch also rules out the map request which is not in
the valid range.

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 drivers/vhost/vdpa.c             | 40 ++++++++++++++++++++++++++++++++
 include/uapi/linux/vhost.h       |  4 ++++
 include/uapi/linux/vhost_types.h |  9 +++++++
 3 files changed, 53 insertions(+)

diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
index a2dbc85e0b0d..562ed99116d1 100644
--- a/drivers/vhost/vdpa.c
+++ b/drivers/vhost/vdpa.c
@@ -47,6 +47,7 @@ struct vhost_vdpa {
 	int minor;
 	struct eventfd_ctx *config_ctx;
 	int in_batch;
+	struct vdpa_iova_range range;
 };
 
 static DEFINE_IDA(vhost_vdpa_ida);
@@ -337,6 +338,16 @@ static long vhost_vdpa_set_config_call(struct vhost_vdpa *v, u32 __user *argp)
 	return 0;
 }
 
+static long vhost_vdpa_get_iova_range(struct vhost_vdpa *v, u32 __user *argp)
+{
+	struct vhost_vdpa_iova_range range = {
+		.first = v->range.first,
+		.last = v->range.last,
+	};
+
+	return copy_to_user(argp, &range, sizeof(range));
+}
+
 static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
 				   void __user *argp)
 {
@@ -470,6 +481,8 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep,
 	case VHOST_GET_BACKEND_FEATURES:
 		features = VHOST_VDPA_BACKEND_FEATURES;
 		r = copy_to_user(featurep, &features, sizeof(features));
+	case VHOST_VDPA_GET_IOVA_RANGE:
+		r = vhost_vdpa_get_iova_range(v, argp);
 		break;
 	default:
 		r = vhost_dev_ioctl(&v->vdev, cmd, argp);
@@ -597,6 +610,10 @@ static int vhost_vdpa_process_iotlb_update(struct vhost_vdpa *v,
 	long pinned;
 	int ret = 0;
 
+	if (msg->iova < v->range.first ||
+	    msg->iova + msg->size - 1 > v->range.last)
+		return -EINVAL;
+
 	if (vhost_iotlb_itree_first(iotlb, msg->iova,
 				    msg->iova + msg->size - 1))
 		return -EEXIST;
@@ -783,6 +800,27 @@ static void vhost_vdpa_free_domain(struct vhost_vdpa *v)
 	v->domain = NULL;
 }
 
+static void vhost_vdpa_set_iova_range(struct vhost_vdpa *v)
+{
+	struct vdpa_iova_range *range = &v->range;
+	struct iommu_domain_geometry geo;
+	struct vdpa_device *vdpa = v->vdpa;
+	const struct vdpa_config_ops *ops = vdpa->config;
+
+	if (ops->get_iova_range) {
+		*range = ops->get_iova_range(vdpa);
+	} else if (v->domain &&
+		   !iommu_domain_get_attr(v->domain,
+		   DOMAIN_ATTR_GEOMETRY, &geo) &&
+		   geo.force_aperture) {
+		range->first = geo.aperture_start;
+		range->last = geo.aperture_end;
+	} else {
+		range->first = 0;
+		range->last = ULLONG_MAX;
+	}
+}
+
 static int vhost_vdpa_open(struct inode *inode, struct file *filep)
 {
 	struct vhost_vdpa *v;
@@ -823,6 +861,8 @@ static int vhost_vdpa_open(struct inode *inode, struct file *filep)
 	if (r)
 		goto err_init_iotlb;
 
+	vhost_vdpa_set_iova_range(v);
+
 	filep->private_data = v;
 
 	return 0;
diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h
index 75232185324a..c998860d7bbc 100644
--- a/include/uapi/linux/vhost.h
+++ b/include/uapi/linux/vhost.h
@@ -146,4 +146,8 @@
 
 /* Set event fd for config interrupt*/
 #define VHOST_VDPA_SET_CONFIG_CALL	_IOW(VHOST_VIRTIO, 0x77, int)
+
+/* Get the valid iova range */
+#define VHOST_VDPA_GET_IOVA_RANGE	_IOR(VHOST_VIRTIO, 0x78, \
+					     struct vhost_vdpa_iova_range)
 #endif
diff --git a/include/uapi/linux/vhost_types.h b/include/uapi/linux/vhost_types.h
index 9a269a88a6ff..f7f6a3a28977 100644
--- a/include/uapi/linux/vhost_types.h
+++ b/include/uapi/linux/vhost_types.h
@@ -138,6 +138,15 @@ struct vhost_vdpa_config {
 	__u8 buf[0];
 };
 
+/* vhost vdpa IOVA range
+ * @first: First address that can be mapped by vhost-vDPA
+ * @last: Last address that can be mapped by vhost-vDPA
+ */
+struct vhost_vdpa_iova_range {
+	__u64 first;
+	__u64 last;
+};
+
 /* Feature bits */
 /* Log all write descriptors. Can be changed while device is active. */
 #define VHOST_F_LOG_ALL 26
-- 
2.20.1

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

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

* [PATCH V3 3/3] vdpa_sim: implement get_iova_range()
  2020-10-23  2:24 ` Jason Wang
@ 2020-10-23  2:24   ` Jason Wang
  -1 siblings, 0 replies; 16+ messages in thread
From: Jason Wang @ 2020-10-23  2:24 UTC (permalink / raw)
  To: mst, virtualization, linux-kernel
  Cc: rob.miller, lingshan.zhu, eperezma, lulu, shahafs, hanand,
	mhabets, gdawar, saugatm, vmireyno, zhangweining, eli,
	Jason Wang

This implements a sample get_iova_range() for the simulator which
advertise [0, ULLONG_MAX] as the valid range.

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 drivers/vdpa/vdpa_sim/vdpa_sim.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c
index 62d640327145..ff6c9fd8d879 100644
--- a/drivers/vdpa/vdpa_sim/vdpa_sim.c
+++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c
@@ -574,6 +574,16 @@ static u32 vdpasim_get_generation(struct vdpa_device *vdpa)
 	return vdpasim->generation;
 }
 
+static struct vdpa_iova_range vdpasim_get_iova_range(struct vdpa_device *vdpa)
+{
+	struct vdpa_iova_range range = {
+		.first = 0ULL,
+		.last = ULLONG_MAX,
+	};
+
+	return range;
+}
+
 static int vdpasim_set_map(struct vdpa_device *vdpa,
 			   struct vhost_iotlb *iotlb)
 {
@@ -657,6 +667,7 @@ static const struct vdpa_config_ops vdpasim_net_config_ops = {
 	.get_config             = vdpasim_get_config,
 	.set_config             = vdpasim_set_config,
 	.get_generation         = vdpasim_get_generation,
+	.get_iova_range         = vdpasim_get_iova_range,
 	.dma_map                = vdpasim_dma_map,
 	.dma_unmap              = vdpasim_dma_unmap,
 	.free                   = vdpasim_free,
@@ -683,6 +694,7 @@ static const struct vdpa_config_ops vdpasim_net_batch_config_ops = {
 	.get_config             = vdpasim_get_config,
 	.set_config             = vdpasim_set_config,
 	.get_generation         = vdpasim_get_generation,
+	.get_iova_range         = vdpasim_get_iova_range,
 	.set_map                = vdpasim_set_map,
 	.free                   = vdpasim_free,
 };
-- 
2.20.1


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

* [PATCH V3 3/3] vdpa_sim: implement get_iova_range()
@ 2020-10-23  2:24   ` Jason Wang
  0 siblings, 0 replies; 16+ messages in thread
From: Jason Wang @ 2020-10-23  2:24 UTC (permalink / raw)
  To: mst, virtualization, linux-kernel
  Cc: shahafs, lulu, saugatm, mhabets, vmireyno, gdawar, eperezma,
	hanand, zhangweining, eli, lingshan.zhu, rob.miller

This implements a sample get_iova_range() for the simulator which
advertise [0, ULLONG_MAX] as the valid range.

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 drivers/vdpa/vdpa_sim/vdpa_sim.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c
index 62d640327145..ff6c9fd8d879 100644
--- a/drivers/vdpa/vdpa_sim/vdpa_sim.c
+++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c
@@ -574,6 +574,16 @@ static u32 vdpasim_get_generation(struct vdpa_device *vdpa)
 	return vdpasim->generation;
 }
 
+static struct vdpa_iova_range vdpasim_get_iova_range(struct vdpa_device *vdpa)
+{
+	struct vdpa_iova_range range = {
+		.first = 0ULL,
+		.last = ULLONG_MAX,
+	};
+
+	return range;
+}
+
 static int vdpasim_set_map(struct vdpa_device *vdpa,
 			   struct vhost_iotlb *iotlb)
 {
@@ -657,6 +667,7 @@ static const struct vdpa_config_ops vdpasim_net_config_ops = {
 	.get_config             = vdpasim_get_config,
 	.set_config             = vdpasim_set_config,
 	.get_generation         = vdpasim_get_generation,
+	.get_iova_range         = vdpasim_get_iova_range,
 	.dma_map                = vdpasim_dma_map,
 	.dma_unmap              = vdpasim_dma_unmap,
 	.free                   = vdpasim_free,
@@ -683,6 +694,7 @@ static const struct vdpa_config_ops vdpasim_net_batch_config_ops = {
 	.get_config             = vdpasim_get_config,
 	.set_config             = vdpasim_set_config,
 	.get_generation         = vdpasim_get_generation,
+	.get_iova_range         = vdpasim_get_iova_range,
 	.set_map                = vdpasim_set_map,
 	.free                   = vdpasim_free,
 };
-- 
2.20.1

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

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

* Re: [PATCH V3 2/3] vhost: vdpa: report iova range
  2020-10-23  2:24   ` Jason Wang
  (?)
@ 2020-10-23  5:28     ` kernel test robot
  -1 siblings, 0 replies; 16+ messages in thread
From: kernel test robot @ 2020-10-23  5:28 UTC (permalink / raw)
  To: Jason Wang, mst, virtualization, linux-kernel
  Cc: kbuild-all, rob.miller, lingshan.zhu, eperezma, lulu, shahafs,
	hanand, mhabets

[-- Attachment #1: Type: text/plain, Size: 7297 bytes --]

Hi Jason,

I love your patch! Perhaps something to improve:

[auto build test WARNING on vhost/linux-next]
[also build test WARNING on linus/master v5.9 next-20201023]
[cannot apply to linux/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Jason-Wang/vDPA-API-for-reporting-IOVA-range/20201023-102708
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git linux-next
config: m68k-randconfig-r034-20201022 (attached as .config)
compiler: m68k-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/446e7b97838ebf87f1acd61580137716fdad104a
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Jason-Wang/vDPA-API-for-reporting-IOVA-range/20201023-102708
        git checkout 446e7b97838ebf87f1acd61580137716fdad104a
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=m68k 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/vhost/vdpa.c: In function 'vhost_vdpa_setup_vq_irq':
   drivers/vhost/vdpa.c:94:6: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
      94 |  int ret, irq;
         |      ^~~
   drivers/vhost/vdpa.c: In function 'vhost_vdpa_unlocked_ioctl':
>> drivers/vhost/vdpa.c:483:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
     483 |   r = copy_to_user(featurep, &features, sizeof(features));
         |   ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/vhost/vdpa.c:484:2: note: here
     484 |  case VHOST_VDPA_GET_IOVA_RANGE:
         |  ^~~~

vim +483 drivers/vhost/vdpa.c

4c8cf31885f69e8 Tiwei Bie    2020-03-26  426  
4c8cf31885f69e8 Tiwei Bie    2020-03-26  427  static long vhost_vdpa_unlocked_ioctl(struct file *filep,
4c8cf31885f69e8 Tiwei Bie    2020-03-26  428  				      unsigned int cmd, unsigned long arg)
4c8cf31885f69e8 Tiwei Bie    2020-03-26  429  {
4c8cf31885f69e8 Tiwei Bie    2020-03-26  430  	struct vhost_vdpa *v = filep->private_data;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  431  	struct vhost_dev *d = &v->vdev;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  432  	void __user *argp = (void __user *)arg;
a127c5bbb6a8eee Jason Wang   2020-09-07  433  	u64 __user *featurep = argp;
a127c5bbb6a8eee Jason Wang   2020-09-07  434  	u64 features;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  435  	long r;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  436  
a127c5bbb6a8eee Jason Wang   2020-09-07  437  	if (cmd == VHOST_SET_BACKEND_FEATURES) {
a127c5bbb6a8eee Jason Wang   2020-09-07  438  		r = copy_from_user(&features, featurep, sizeof(features));
a127c5bbb6a8eee Jason Wang   2020-09-07  439  		if (r)
a127c5bbb6a8eee Jason Wang   2020-09-07  440  			return r;
a127c5bbb6a8eee Jason Wang   2020-09-07  441  		if (features & ~VHOST_VDPA_BACKEND_FEATURES)
a127c5bbb6a8eee Jason Wang   2020-09-07  442  			return -EOPNOTSUPP;
a127c5bbb6a8eee Jason Wang   2020-09-07  443  		vhost_set_backend_features(&v->vdev, features);
a127c5bbb6a8eee Jason Wang   2020-09-07  444  		return 0;
a127c5bbb6a8eee Jason Wang   2020-09-07  445  	}
a127c5bbb6a8eee Jason Wang   2020-09-07  446  
4c8cf31885f69e8 Tiwei Bie    2020-03-26  447  	mutex_lock(&d->mutex);
4c8cf31885f69e8 Tiwei Bie    2020-03-26  448  
4c8cf31885f69e8 Tiwei Bie    2020-03-26  449  	switch (cmd) {
4c8cf31885f69e8 Tiwei Bie    2020-03-26  450  	case VHOST_VDPA_GET_DEVICE_ID:
4c8cf31885f69e8 Tiwei Bie    2020-03-26  451  		r = vhost_vdpa_get_device_id(v, argp);
4c8cf31885f69e8 Tiwei Bie    2020-03-26  452  		break;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  453  	case VHOST_VDPA_GET_STATUS:
4c8cf31885f69e8 Tiwei Bie    2020-03-26  454  		r = vhost_vdpa_get_status(v, argp);
4c8cf31885f69e8 Tiwei Bie    2020-03-26  455  		break;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  456  	case VHOST_VDPA_SET_STATUS:
4c8cf31885f69e8 Tiwei Bie    2020-03-26  457  		r = vhost_vdpa_set_status(v, argp);
4c8cf31885f69e8 Tiwei Bie    2020-03-26  458  		break;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  459  	case VHOST_VDPA_GET_CONFIG:
4c8cf31885f69e8 Tiwei Bie    2020-03-26  460  		r = vhost_vdpa_get_config(v, argp);
4c8cf31885f69e8 Tiwei Bie    2020-03-26  461  		break;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  462  	case VHOST_VDPA_SET_CONFIG:
4c8cf31885f69e8 Tiwei Bie    2020-03-26  463  		r = vhost_vdpa_set_config(v, argp);
4c8cf31885f69e8 Tiwei Bie    2020-03-26  464  		break;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  465  	case VHOST_GET_FEATURES:
4c8cf31885f69e8 Tiwei Bie    2020-03-26  466  		r = vhost_vdpa_get_features(v, argp);
4c8cf31885f69e8 Tiwei Bie    2020-03-26  467  		break;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  468  	case VHOST_SET_FEATURES:
4c8cf31885f69e8 Tiwei Bie    2020-03-26  469  		r = vhost_vdpa_set_features(v, argp);
4c8cf31885f69e8 Tiwei Bie    2020-03-26  470  		break;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  471  	case VHOST_VDPA_GET_VRING_NUM:
4c8cf31885f69e8 Tiwei Bie    2020-03-26  472  		r = vhost_vdpa_get_vring_num(v, argp);
4c8cf31885f69e8 Tiwei Bie    2020-03-26  473  		break;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  474  	case VHOST_SET_LOG_BASE:
4c8cf31885f69e8 Tiwei Bie    2020-03-26  475  	case VHOST_SET_LOG_FD:
4c8cf31885f69e8 Tiwei Bie    2020-03-26  476  		r = -ENOIOCTLCMD;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  477  		break;
776f395004d829b Zhu Lingshan 2020-06-05  478  	case VHOST_VDPA_SET_CONFIG_CALL:
776f395004d829b Zhu Lingshan 2020-06-05  479  		r = vhost_vdpa_set_config_call(v, argp);
776f395004d829b Zhu Lingshan 2020-06-05  480  		break;
a127c5bbb6a8eee Jason Wang   2020-09-07  481  	case VHOST_GET_BACKEND_FEATURES:
a127c5bbb6a8eee Jason Wang   2020-09-07  482  		features = VHOST_VDPA_BACKEND_FEATURES;
a127c5bbb6a8eee Jason Wang   2020-09-07 @483  		r = copy_to_user(featurep, &features, sizeof(features));
446e7b97838ebf8 Jason Wang   2020-10-23  484  	case VHOST_VDPA_GET_IOVA_RANGE:
446e7b97838ebf8 Jason Wang   2020-10-23  485  		r = vhost_vdpa_get_iova_range(v, argp);
a127c5bbb6a8eee Jason Wang   2020-09-07  486  		break;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  487  	default:
4c8cf31885f69e8 Tiwei Bie    2020-03-26  488  		r = vhost_dev_ioctl(&v->vdev, cmd, argp);
4c8cf31885f69e8 Tiwei Bie    2020-03-26  489  		if (r == -ENOIOCTLCMD)
4c8cf31885f69e8 Tiwei Bie    2020-03-26  490  			r = vhost_vdpa_vring_ioctl(v, cmd, argp);
4c8cf31885f69e8 Tiwei Bie    2020-03-26  491  		break;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  492  	}
4c8cf31885f69e8 Tiwei Bie    2020-03-26  493  
4c8cf31885f69e8 Tiwei Bie    2020-03-26  494  	mutex_unlock(&d->mutex);
4c8cf31885f69e8 Tiwei Bie    2020-03-26  495  	return r;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  496  }
4c8cf31885f69e8 Tiwei Bie    2020-03-26  497  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 25854 bytes --]

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

* Re: [PATCH V3 2/3] vhost: vdpa: report iova range
@ 2020-10-23  5:28     ` kernel test robot
  0 siblings, 0 replies; 16+ messages in thread
From: kernel test robot @ 2020-10-23  5:28 UTC (permalink / raw)
  To: Jason Wang, mst, virtualization, linux-kernel
  Cc: shahafs, kbuild-all, lulu, mhabets, eperezma, hanand,
	lingshan.zhu, rob.miller

[-- Attachment #1: Type: text/plain, Size: 7297 bytes --]

Hi Jason,

I love your patch! Perhaps something to improve:

[auto build test WARNING on vhost/linux-next]
[also build test WARNING on linus/master v5.9 next-20201023]
[cannot apply to linux/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Jason-Wang/vDPA-API-for-reporting-IOVA-range/20201023-102708
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git linux-next
config: m68k-randconfig-r034-20201022 (attached as .config)
compiler: m68k-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/446e7b97838ebf87f1acd61580137716fdad104a
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Jason-Wang/vDPA-API-for-reporting-IOVA-range/20201023-102708
        git checkout 446e7b97838ebf87f1acd61580137716fdad104a
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=m68k 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/vhost/vdpa.c: In function 'vhost_vdpa_setup_vq_irq':
   drivers/vhost/vdpa.c:94:6: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
      94 |  int ret, irq;
         |      ^~~
   drivers/vhost/vdpa.c: In function 'vhost_vdpa_unlocked_ioctl':
>> drivers/vhost/vdpa.c:483:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
     483 |   r = copy_to_user(featurep, &features, sizeof(features));
         |   ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/vhost/vdpa.c:484:2: note: here
     484 |  case VHOST_VDPA_GET_IOVA_RANGE:
         |  ^~~~

vim +483 drivers/vhost/vdpa.c

4c8cf31885f69e8 Tiwei Bie    2020-03-26  426  
4c8cf31885f69e8 Tiwei Bie    2020-03-26  427  static long vhost_vdpa_unlocked_ioctl(struct file *filep,
4c8cf31885f69e8 Tiwei Bie    2020-03-26  428  				      unsigned int cmd, unsigned long arg)
4c8cf31885f69e8 Tiwei Bie    2020-03-26  429  {
4c8cf31885f69e8 Tiwei Bie    2020-03-26  430  	struct vhost_vdpa *v = filep->private_data;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  431  	struct vhost_dev *d = &v->vdev;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  432  	void __user *argp = (void __user *)arg;
a127c5bbb6a8eee Jason Wang   2020-09-07  433  	u64 __user *featurep = argp;
a127c5bbb6a8eee Jason Wang   2020-09-07  434  	u64 features;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  435  	long r;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  436  
a127c5bbb6a8eee Jason Wang   2020-09-07  437  	if (cmd == VHOST_SET_BACKEND_FEATURES) {
a127c5bbb6a8eee Jason Wang   2020-09-07  438  		r = copy_from_user(&features, featurep, sizeof(features));
a127c5bbb6a8eee Jason Wang   2020-09-07  439  		if (r)
a127c5bbb6a8eee Jason Wang   2020-09-07  440  			return r;
a127c5bbb6a8eee Jason Wang   2020-09-07  441  		if (features & ~VHOST_VDPA_BACKEND_FEATURES)
a127c5bbb6a8eee Jason Wang   2020-09-07  442  			return -EOPNOTSUPP;
a127c5bbb6a8eee Jason Wang   2020-09-07  443  		vhost_set_backend_features(&v->vdev, features);
a127c5bbb6a8eee Jason Wang   2020-09-07  444  		return 0;
a127c5bbb6a8eee Jason Wang   2020-09-07  445  	}
a127c5bbb6a8eee Jason Wang   2020-09-07  446  
4c8cf31885f69e8 Tiwei Bie    2020-03-26  447  	mutex_lock(&d->mutex);
4c8cf31885f69e8 Tiwei Bie    2020-03-26  448  
4c8cf31885f69e8 Tiwei Bie    2020-03-26  449  	switch (cmd) {
4c8cf31885f69e8 Tiwei Bie    2020-03-26  450  	case VHOST_VDPA_GET_DEVICE_ID:
4c8cf31885f69e8 Tiwei Bie    2020-03-26  451  		r = vhost_vdpa_get_device_id(v, argp);
4c8cf31885f69e8 Tiwei Bie    2020-03-26  452  		break;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  453  	case VHOST_VDPA_GET_STATUS:
4c8cf31885f69e8 Tiwei Bie    2020-03-26  454  		r = vhost_vdpa_get_status(v, argp);
4c8cf31885f69e8 Tiwei Bie    2020-03-26  455  		break;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  456  	case VHOST_VDPA_SET_STATUS:
4c8cf31885f69e8 Tiwei Bie    2020-03-26  457  		r = vhost_vdpa_set_status(v, argp);
4c8cf31885f69e8 Tiwei Bie    2020-03-26  458  		break;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  459  	case VHOST_VDPA_GET_CONFIG:
4c8cf31885f69e8 Tiwei Bie    2020-03-26  460  		r = vhost_vdpa_get_config(v, argp);
4c8cf31885f69e8 Tiwei Bie    2020-03-26  461  		break;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  462  	case VHOST_VDPA_SET_CONFIG:
4c8cf31885f69e8 Tiwei Bie    2020-03-26  463  		r = vhost_vdpa_set_config(v, argp);
4c8cf31885f69e8 Tiwei Bie    2020-03-26  464  		break;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  465  	case VHOST_GET_FEATURES:
4c8cf31885f69e8 Tiwei Bie    2020-03-26  466  		r = vhost_vdpa_get_features(v, argp);
4c8cf31885f69e8 Tiwei Bie    2020-03-26  467  		break;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  468  	case VHOST_SET_FEATURES:
4c8cf31885f69e8 Tiwei Bie    2020-03-26  469  		r = vhost_vdpa_set_features(v, argp);
4c8cf31885f69e8 Tiwei Bie    2020-03-26  470  		break;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  471  	case VHOST_VDPA_GET_VRING_NUM:
4c8cf31885f69e8 Tiwei Bie    2020-03-26  472  		r = vhost_vdpa_get_vring_num(v, argp);
4c8cf31885f69e8 Tiwei Bie    2020-03-26  473  		break;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  474  	case VHOST_SET_LOG_BASE:
4c8cf31885f69e8 Tiwei Bie    2020-03-26  475  	case VHOST_SET_LOG_FD:
4c8cf31885f69e8 Tiwei Bie    2020-03-26  476  		r = -ENOIOCTLCMD;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  477  		break;
776f395004d829b Zhu Lingshan 2020-06-05  478  	case VHOST_VDPA_SET_CONFIG_CALL:
776f395004d829b Zhu Lingshan 2020-06-05  479  		r = vhost_vdpa_set_config_call(v, argp);
776f395004d829b Zhu Lingshan 2020-06-05  480  		break;
a127c5bbb6a8eee Jason Wang   2020-09-07  481  	case VHOST_GET_BACKEND_FEATURES:
a127c5bbb6a8eee Jason Wang   2020-09-07  482  		features = VHOST_VDPA_BACKEND_FEATURES;
a127c5bbb6a8eee Jason Wang   2020-09-07 @483  		r = copy_to_user(featurep, &features, sizeof(features));
446e7b97838ebf8 Jason Wang   2020-10-23  484  	case VHOST_VDPA_GET_IOVA_RANGE:
446e7b97838ebf8 Jason Wang   2020-10-23  485  		r = vhost_vdpa_get_iova_range(v, argp);
a127c5bbb6a8eee Jason Wang   2020-09-07  486  		break;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  487  	default:
4c8cf31885f69e8 Tiwei Bie    2020-03-26  488  		r = vhost_dev_ioctl(&v->vdev, cmd, argp);
4c8cf31885f69e8 Tiwei Bie    2020-03-26  489  		if (r == -ENOIOCTLCMD)
4c8cf31885f69e8 Tiwei Bie    2020-03-26  490  			r = vhost_vdpa_vring_ioctl(v, cmd, argp);
4c8cf31885f69e8 Tiwei Bie    2020-03-26  491  		break;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  492  	}
4c8cf31885f69e8 Tiwei Bie    2020-03-26  493  
4c8cf31885f69e8 Tiwei Bie    2020-03-26  494  	mutex_unlock(&d->mutex);
4c8cf31885f69e8 Tiwei Bie    2020-03-26  495  	return r;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  496  }
4c8cf31885f69e8 Tiwei Bie    2020-03-26  497  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 25854 bytes --]

[-- Attachment #3: Type: text/plain, Size: 183 bytes --]

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

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

* Re: [PATCH V3 2/3] vhost: vdpa: report iova range
@ 2020-10-23  5:28     ` kernel test robot
  0 siblings, 0 replies; 16+ messages in thread
From: kernel test robot @ 2020-10-23  5:28 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 7419 bytes --]

Hi Jason,

I love your patch! Perhaps something to improve:

[auto build test WARNING on vhost/linux-next]
[also build test WARNING on linus/master v5.9 next-20201023]
[cannot apply to linux/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Jason-Wang/vDPA-API-for-reporting-IOVA-range/20201023-102708
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git linux-next
config: m68k-randconfig-r034-20201022 (attached as .config)
compiler: m68k-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/446e7b97838ebf87f1acd61580137716fdad104a
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Jason-Wang/vDPA-API-for-reporting-IOVA-range/20201023-102708
        git checkout 446e7b97838ebf87f1acd61580137716fdad104a
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=m68k 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/vhost/vdpa.c: In function 'vhost_vdpa_setup_vq_irq':
   drivers/vhost/vdpa.c:94:6: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
      94 |  int ret, irq;
         |      ^~~
   drivers/vhost/vdpa.c: In function 'vhost_vdpa_unlocked_ioctl':
>> drivers/vhost/vdpa.c:483:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
     483 |   r = copy_to_user(featurep, &features, sizeof(features));
         |   ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/vhost/vdpa.c:484:2: note: here
     484 |  case VHOST_VDPA_GET_IOVA_RANGE:
         |  ^~~~

vim +483 drivers/vhost/vdpa.c

4c8cf31885f69e8 Tiwei Bie    2020-03-26  426  
4c8cf31885f69e8 Tiwei Bie    2020-03-26  427  static long vhost_vdpa_unlocked_ioctl(struct file *filep,
4c8cf31885f69e8 Tiwei Bie    2020-03-26  428  				      unsigned int cmd, unsigned long arg)
4c8cf31885f69e8 Tiwei Bie    2020-03-26  429  {
4c8cf31885f69e8 Tiwei Bie    2020-03-26  430  	struct vhost_vdpa *v = filep->private_data;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  431  	struct vhost_dev *d = &v->vdev;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  432  	void __user *argp = (void __user *)arg;
a127c5bbb6a8eee Jason Wang   2020-09-07  433  	u64 __user *featurep = argp;
a127c5bbb6a8eee Jason Wang   2020-09-07  434  	u64 features;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  435  	long r;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  436  
a127c5bbb6a8eee Jason Wang   2020-09-07  437  	if (cmd == VHOST_SET_BACKEND_FEATURES) {
a127c5bbb6a8eee Jason Wang   2020-09-07  438  		r = copy_from_user(&features, featurep, sizeof(features));
a127c5bbb6a8eee Jason Wang   2020-09-07  439  		if (r)
a127c5bbb6a8eee Jason Wang   2020-09-07  440  			return r;
a127c5bbb6a8eee Jason Wang   2020-09-07  441  		if (features & ~VHOST_VDPA_BACKEND_FEATURES)
a127c5bbb6a8eee Jason Wang   2020-09-07  442  			return -EOPNOTSUPP;
a127c5bbb6a8eee Jason Wang   2020-09-07  443  		vhost_set_backend_features(&v->vdev, features);
a127c5bbb6a8eee Jason Wang   2020-09-07  444  		return 0;
a127c5bbb6a8eee Jason Wang   2020-09-07  445  	}
a127c5bbb6a8eee Jason Wang   2020-09-07  446  
4c8cf31885f69e8 Tiwei Bie    2020-03-26  447  	mutex_lock(&d->mutex);
4c8cf31885f69e8 Tiwei Bie    2020-03-26  448  
4c8cf31885f69e8 Tiwei Bie    2020-03-26  449  	switch (cmd) {
4c8cf31885f69e8 Tiwei Bie    2020-03-26  450  	case VHOST_VDPA_GET_DEVICE_ID:
4c8cf31885f69e8 Tiwei Bie    2020-03-26  451  		r = vhost_vdpa_get_device_id(v, argp);
4c8cf31885f69e8 Tiwei Bie    2020-03-26  452  		break;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  453  	case VHOST_VDPA_GET_STATUS:
4c8cf31885f69e8 Tiwei Bie    2020-03-26  454  		r = vhost_vdpa_get_status(v, argp);
4c8cf31885f69e8 Tiwei Bie    2020-03-26  455  		break;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  456  	case VHOST_VDPA_SET_STATUS:
4c8cf31885f69e8 Tiwei Bie    2020-03-26  457  		r = vhost_vdpa_set_status(v, argp);
4c8cf31885f69e8 Tiwei Bie    2020-03-26  458  		break;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  459  	case VHOST_VDPA_GET_CONFIG:
4c8cf31885f69e8 Tiwei Bie    2020-03-26  460  		r = vhost_vdpa_get_config(v, argp);
4c8cf31885f69e8 Tiwei Bie    2020-03-26  461  		break;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  462  	case VHOST_VDPA_SET_CONFIG:
4c8cf31885f69e8 Tiwei Bie    2020-03-26  463  		r = vhost_vdpa_set_config(v, argp);
4c8cf31885f69e8 Tiwei Bie    2020-03-26  464  		break;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  465  	case VHOST_GET_FEATURES:
4c8cf31885f69e8 Tiwei Bie    2020-03-26  466  		r = vhost_vdpa_get_features(v, argp);
4c8cf31885f69e8 Tiwei Bie    2020-03-26  467  		break;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  468  	case VHOST_SET_FEATURES:
4c8cf31885f69e8 Tiwei Bie    2020-03-26  469  		r = vhost_vdpa_set_features(v, argp);
4c8cf31885f69e8 Tiwei Bie    2020-03-26  470  		break;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  471  	case VHOST_VDPA_GET_VRING_NUM:
4c8cf31885f69e8 Tiwei Bie    2020-03-26  472  		r = vhost_vdpa_get_vring_num(v, argp);
4c8cf31885f69e8 Tiwei Bie    2020-03-26  473  		break;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  474  	case VHOST_SET_LOG_BASE:
4c8cf31885f69e8 Tiwei Bie    2020-03-26  475  	case VHOST_SET_LOG_FD:
4c8cf31885f69e8 Tiwei Bie    2020-03-26  476  		r = -ENOIOCTLCMD;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  477  		break;
776f395004d829b Zhu Lingshan 2020-06-05  478  	case VHOST_VDPA_SET_CONFIG_CALL:
776f395004d829b Zhu Lingshan 2020-06-05  479  		r = vhost_vdpa_set_config_call(v, argp);
776f395004d829b Zhu Lingshan 2020-06-05  480  		break;
a127c5bbb6a8eee Jason Wang   2020-09-07  481  	case VHOST_GET_BACKEND_FEATURES:
a127c5bbb6a8eee Jason Wang   2020-09-07  482  		features = VHOST_VDPA_BACKEND_FEATURES;
a127c5bbb6a8eee Jason Wang   2020-09-07 @483  		r = copy_to_user(featurep, &features, sizeof(features));
446e7b97838ebf8 Jason Wang   2020-10-23  484  	case VHOST_VDPA_GET_IOVA_RANGE:
446e7b97838ebf8 Jason Wang   2020-10-23  485  		r = vhost_vdpa_get_iova_range(v, argp);
a127c5bbb6a8eee Jason Wang   2020-09-07  486  		break;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  487  	default:
4c8cf31885f69e8 Tiwei Bie    2020-03-26  488  		r = vhost_dev_ioctl(&v->vdev, cmd, argp);
4c8cf31885f69e8 Tiwei Bie    2020-03-26  489  		if (r == -ENOIOCTLCMD)
4c8cf31885f69e8 Tiwei Bie    2020-03-26  490  			r = vhost_vdpa_vring_ioctl(v, cmd, argp);
4c8cf31885f69e8 Tiwei Bie    2020-03-26  491  		break;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  492  	}
4c8cf31885f69e8 Tiwei Bie    2020-03-26  493  
4c8cf31885f69e8 Tiwei Bie    2020-03-26  494  	mutex_unlock(&d->mutex);
4c8cf31885f69e8 Tiwei Bie    2020-03-26  495  	return r;
4c8cf31885f69e8 Tiwei Bie    2020-03-26  496  }
4c8cf31885f69e8 Tiwei Bie    2020-03-26  497  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 25854 bytes --]

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

* Re: [PATCH V3 2/3] vhost: vdpa: report iova range
  2020-10-23  5:28     ` kernel test robot
  (?)
@ 2020-10-23  8:46       ` Jason Wang
  -1 siblings, 0 replies; 16+ messages in thread
From: Jason Wang @ 2020-10-23  8:46 UTC (permalink / raw)
  To: kernel test robot, mst, virtualization, linux-kernel
  Cc: kbuild-all, rob.miller, lingshan.zhu, eperezma, lulu, shahafs,
	hanand, mhabets


On 2020/10/23 下午1:28, kernel test robot wrote:
> Hi Jason,
>
> I love your patch! Perhaps something to improve:
>
> [auto build test WARNING on vhost/linux-next]
> [also build test WARNING on linus/master v5.9 next-20201023]
> [cannot apply to linux/master]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch]
>
> url:    https://github.com/0day-ci/linux/commits/Jason-Wang/vDPA-API-for-reporting-IOVA-range/20201023-102708
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git linux-next
> config: m68k-randconfig-r034-20201022 (attached as .config)
> compiler: m68k-linux-gcc (GCC) 9.3.0
> reproduce (this is a W=1 build):
>          wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>          chmod +x ~/bin/make.cross
>          # https://github.com/0day-ci/linux/commit/446e7b97838ebf87f1acd61580137716fdad104a
>          git remote add linux-review https://github.com/0day-ci/linux
>          git fetch --no-tags linux-review Jason-Wang/vDPA-API-for-reporting-IOVA-range/20201023-102708
>          git checkout 446e7b97838ebf87f1acd61580137716fdad104a
>          # save the attached .config to linux build tree
>          COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=m68k
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
> All warnings (new ones prefixed by >>):
>
>     drivers/vhost/vdpa.c: In function 'vhost_vdpa_setup_vq_irq':
>     drivers/vhost/vdpa.c:94:6: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
>        94 |  int ret, irq;
>           |      ^~~
>     drivers/vhost/vdpa.c: In function 'vhost_vdpa_unlocked_ioctl':


This looks like another issue that needs to be fixed.


>>> drivers/vhost/vdpa.c:483:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
>       483 |   r = copy_to_user(featurep, &features, sizeof(features));
>           |   ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>     drivers/vhost/vdpa.c:484:2: note: here
>       484 |  case VHOST_VDPA_GET_IOVA_RANGE:
>           |  ^~~~
>
> vim +483 drivers/vhost/vdpa.c


My bad. V4 is on the road.

Thanks


>
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  426
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  427  static long vhost_vdpa_unlocked_ioctl(struct file *filep,
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  428  				      unsigned int cmd, unsigned long arg)
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  429  {
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  430  	struct vhost_vdpa *v = filep->private_data;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  431  	struct vhost_dev *d = &v->vdev;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  432  	void __user *argp = (void __user *)arg;
> a127c5bbb6a8eee Jason Wang   2020-09-07  433  	u64 __user *featurep = argp;
> a127c5bbb6a8eee Jason Wang   2020-09-07  434  	u64 features;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  435  	long r;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  436
> a127c5bbb6a8eee Jason Wang   2020-09-07  437  	if (cmd == VHOST_SET_BACKEND_FEATURES) {
> a127c5bbb6a8eee Jason Wang   2020-09-07  438  		r = copy_from_user(&features, featurep, sizeof(features));
> a127c5bbb6a8eee Jason Wang   2020-09-07  439  		if (r)
> a127c5bbb6a8eee Jason Wang   2020-09-07  440  			return r;
> a127c5bbb6a8eee Jason Wang   2020-09-07  441  		if (features & ~VHOST_VDPA_BACKEND_FEATURES)
> a127c5bbb6a8eee Jason Wang   2020-09-07  442  			return -EOPNOTSUPP;
> a127c5bbb6a8eee Jason Wang   2020-09-07  443  		vhost_set_backend_features(&v->vdev, features);
> a127c5bbb6a8eee Jason Wang   2020-09-07  444  		return 0;
> a127c5bbb6a8eee Jason Wang   2020-09-07  445  	}
> a127c5bbb6a8eee Jason Wang   2020-09-07  446
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  447  	mutex_lock(&d->mutex);
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  448
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  449  	switch (cmd) {
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  450  	case VHOST_VDPA_GET_DEVICE_ID:
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  451  		r = vhost_vdpa_get_device_id(v, argp);
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  452  		break;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  453  	case VHOST_VDPA_GET_STATUS:
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  454  		r = vhost_vdpa_get_status(v, argp);
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  455  		break;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  456  	case VHOST_VDPA_SET_STATUS:
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  457  		r = vhost_vdpa_set_status(v, argp);
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  458  		break;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  459  	case VHOST_VDPA_GET_CONFIG:
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  460  		r = vhost_vdpa_get_config(v, argp);
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  461  		break;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  462  	case VHOST_VDPA_SET_CONFIG:
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  463  		r = vhost_vdpa_set_config(v, argp);
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  464  		break;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  465  	case VHOST_GET_FEATURES:
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  466  		r = vhost_vdpa_get_features(v, argp);
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  467  		break;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  468  	case VHOST_SET_FEATURES:
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  469  		r = vhost_vdpa_set_features(v, argp);
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  470  		break;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  471  	case VHOST_VDPA_GET_VRING_NUM:
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  472  		r = vhost_vdpa_get_vring_num(v, argp);
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  473  		break;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  474  	case VHOST_SET_LOG_BASE:
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  475  	case VHOST_SET_LOG_FD:
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  476  		r = -ENOIOCTLCMD;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  477  		break;
> 776f395004d829b Zhu Lingshan 2020-06-05  478  	case VHOST_VDPA_SET_CONFIG_CALL:
> 776f395004d829b Zhu Lingshan 2020-06-05  479  		r = vhost_vdpa_set_config_call(v, argp);
> 776f395004d829b Zhu Lingshan 2020-06-05  480  		break;
> a127c5bbb6a8eee Jason Wang   2020-09-07  481  	case VHOST_GET_BACKEND_FEATURES:
> a127c5bbb6a8eee Jason Wang   2020-09-07  482  		features = VHOST_VDPA_BACKEND_FEATURES;
> a127c5bbb6a8eee Jason Wang   2020-09-07 @483  		r = copy_to_user(featurep, &features, sizeof(features));
> 446e7b97838ebf8 Jason Wang   2020-10-23  484  	case VHOST_VDPA_GET_IOVA_RANGE:
> 446e7b97838ebf8 Jason Wang   2020-10-23  485  		r = vhost_vdpa_get_iova_range(v, argp);
> a127c5bbb6a8eee Jason Wang   2020-09-07  486  		break;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  487  	default:
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  488  		r = vhost_dev_ioctl(&v->vdev, cmd, argp);
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  489  		if (r == -ENOIOCTLCMD)
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  490  			r = vhost_vdpa_vring_ioctl(v, cmd, argp);
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  491  		break;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  492  	}
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  493
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  494  	mutex_unlock(&d->mutex);
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  495  	return r;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  496  }
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  497
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org


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

* Re: [PATCH V3 2/3] vhost: vdpa: report iova range
@ 2020-10-23  8:46       ` Jason Wang
  0 siblings, 0 replies; 16+ messages in thread
From: Jason Wang @ 2020-10-23  8:46 UTC (permalink / raw)
  To: kernel test robot, mst, virtualization, linux-kernel
  Cc: shahafs, kbuild-all, lulu, mhabets, eperezma, hanand,
	lingshan.zhu, rob.miller


On 2020/10/23 下午1:28, kernel test robot wrote:
> Hi Jason,
>
> I love your patch! Perhaps something to improve:
>
> [auto build test WARNING on vhost/linux-next]
> [also build test WARNING on linus/master v5.9 next-20201023]
> [cannot apply to linux/master]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch]
>
> url:    https://github.com/0day-ci/linux/commits/Jason-Wang/vDPA-API-for-reporting-IOVA-range/20201023-102708
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git linux-next
> config: m68k-randconfig-r034-20201022 (attached as .config)
> compiler: m68k-linux-gcc (GCC) 9.3.0
> reproduce (this is a W=1 build):
>          wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>          chmod +x ~/bin/make.cross
>          # https://github.com/0day-ci/linux/commit/446e7b97838ebf87f1acd61580137716fdad104a
>          git remote add linux-review https://github.com/0day-ci/linux
>          git fetch --no-tags linux-review Jason-Wang/vDPA-API-for-reporting-IOVA-range/20201023-102708
>          git checkout 446e7b97838ebf87f1acd61580137716fdad104a
>          # save the attached .config to linux build tree
>          COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=m68k
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
> All warnings (new ones prefixed by >>):
>
>     drivers/vhost/vdpa.c: In function 'vhost_vdpa_setup_vq_irq':
>     drivers/vhost/vdpa.c:94:6: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
>        94 |  int ret, irq;
>           |      ^~~
>     drivers/vhost/vdpa.c: In function 'vhost_vdpa_unlocked_ioctl':


This looks like another issue that needs to be fixed.


>>> drivers/vhost/vdpa.c:483:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
>       483 |   r = copy_to_user(featurep, &features, sizeof(features));
>           |   ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>     drivers/vhost/vdpa.c:484:2: note: here
>       484 |  case VHOST_VDPA_GET_IOVA_RANGE:
>           |  ^~~~
>
> vim +483 drivers/vhost/vdpa.c


My bad. V4 is on the road.

Thanks


>
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  426
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  427  static long vhost_vdpa_unlocked_ioctl(struct file *filep,
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  428  				      unsigned int cmd, unsigned long arg)
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  429  {
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  430  	struct vhost_vdpa *v = filep->private_data;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  431  	struct vhost_dev *d = &v->vdev;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  432  	void __user *argp = (void __user *)arg;
> a127c5bbb6a8eee Jason Wang   2020-09-07  433  	u64 __user *featurep = argp;
> a127c5bbb6a8eee Jason Wang   2020-09-07  434  	u64 features;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  435  	long r;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  436
> a127c5bbb6a8eee Jason Wang   2020-09-07  437  	if (cmd == VHOST_SET_BACKEND_FEATURES) {
> a127c5bbb6a8eee Jason Wang   2020-09-07  438  		r = copy_from_user(&features, featurep, sizeof(features));
> a127c5bbb6a8eee Jason Wang   2020-09-07  439  		if (r)
> a127c5bbb6a8eee Jason Wang   2020-09-07  440  			return r;
> a127c5bbb6a8eee Jason Wang   2020-09-07  441  		if (features & ~VHOST_VDPA_BACKEND_FEATURES)
> a127c5bbb6a8eee Jason Wang   2020-09-07  442  			return -EOPNOTSUPP;
> a127c5bbb6a8eee Jason Wang   2020-09-07  443  		vhost_set_backend_features(&v->vdev, features);
> a127c5bbb6a8eee Jason Wang   2020-09-07  444  		return 0;
> a127c5bbb6a8eee Jason Wang   2020-09-07  445  	}
> a127c5bbb6a8eee Jason Wang   2020-09-07  446
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  447  	mutex_lock(&d->mutex);
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  448
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  449  	switch (cmd) {
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  450  	case VHOST_VDPA_GET_DEVICE_ID:
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  451  		r = vhost_vdpa_get_device_id(v, argp);
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  452  		break;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  453  	case VHOST_VDPA_GET_STATUS:
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  454  		r = vhost_vdpa_get_status(v, argp);
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  455  		break;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  456  	case VHOST_VDPA_SET_STATUS:
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  457  		r = vhost_vdpa_set_status(v, argp);
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  458  		break;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  459  	case VHOST_VDPA_GET_CONFIG:
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  460  		r = vhost_vdpa_get_config(v, argp);
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  461  		break;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  462  	case VHOST_VDPA_SET_CONFIG:
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  463  		r = vhost_vdpa_set_config(v, argp);
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  464  		break;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  465  	case VHOST_GET_FEATURES:
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  466  		r = vhost_vdpa_get_features(v, argp);
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  467  		break;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  468  	case VHOST_SET_FEATURES:
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  469  		r = vhost_vdpa_set_features(v, argp);
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  470  		break;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  471  	case VHOST_VDPA_GET_VRING_NUM:
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  472  		r = vhost_vdpa_get_vring_num(v, argp);
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  473  		break;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  474  	case VHOST_SET_LOG_BASE:
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  475  	case VHOST_SET_LOG_FD:
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  476  		r = -ENOIOCTLCMD;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  477  		break;
> 776f395004d829b Zhu Lingshan 2020-06-05  478  	case VHOST_VDPA_SET_CONFIG_CALL:
> 776f395004d829b Zhu Lingshan 2020-06-05  479  		r = vhost_vdpa_set_config_call(v, argp);
> 776f395004d829b Zhu Lingshan 2020-06-05  480  		break;
> a127c5bbb6a8eee Jason Wang   2020-09-07  481  	case VHOST_GET_BACKEND_FEATURES:
> a127c5bbb6a8eee Jason Wang   2020-09-07  482  		features = VHOST_VDPA_BACKEND_FEATURES;
> a127c5bbb6a8eee Jason Wang   2020-09-07 @483  		r = copy_to_user(featurep, &features, sizeof(features));
> 446e7b97838ebf8 Jason Wang   2020-10-23  484  	case VHOST_VDPA_GET_IOVA_RANGE:
> 446e7b97838ebf8 Jason Wang   2020-10-23  485  		r = vhost_vdpa_get_iova_range(v, argp);
> a127c5bbb6a8eee Jason Wang   2020-09-07  486  		break;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  487  	default:
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  488  		r = vhost_dev_ioctl(&v->vdev, cmd, argp);
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  489  		if (r == -ENOIOCTLCMD)
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  490  			r = vhost_vdpa_vring_ioctl(v, cmd, argp);
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  491  		break;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  492  	}
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  493
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  494  	mutex_unlock(&d->mutex);
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  495  	return r;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  496  }
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  497
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

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

* Re: [PATCH V3 2/3] vhost: vdpa: report iova range
@ 2020-10-23  8:46       ` Jason Wang
  0 siblings, 0 replies; 16+ messages in thread
From: Jason Wang @ 2020-10-23  8:46 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 7817 bytes --]


On 2020/10/23 下午1:28, kernel test robot wrote:
> Hi Jason,
>
> I love your patch! Perhaps something to improve:
>
> [auto build test WARNING on vhost/linux-next]
> [also build test WARNING on linus/master v5.9 next-20201023]
> [cannot apply to linux/master]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch]
>
> url:    https://github.com/0day-ci/linux/commits/Jason-Wang/vDPA-API-for-reporting-IOVA-range/20201023-102708
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git linux-next
> config: m68k-randconfig-r034-20201022 (attached as .config)
> compiler: m68k-linux-gcc (GCC) 9.3.0
> reproduce (this is a W=1 build):
>          wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>          chmod +x ~/bin/make.cross
>          # https://github.com/0day-ci/linux/commit/446e7b97838ebf87f1acd61580137716fdad104a
>          git remote add linux-review https://github.com/0day-ci/linux
>          git fetch --no-tags linux-review Jason-Wang/vDPA-API-for-reporting-IOVA-range/20201023-102708
>          git checkout 446e7b97838ebf87f1acd61580137716fdad104a
>          # save the attached .config to linux build tree
>          COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=m68k
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
> All warnings (new ones prefixed by >>):
>
>     drivers/vhost/vdpa.c: In function 'vhost_vdpa_setup_vq_irq':
>     drivers/vhost/vdpa.c:94:6: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
>        94 |  int ret, irq;
>           |      ^~~
>     drivers/vhost/vdpa.c: In function 'vhost_vdpa_unlocked_ioctl':


This looks like another issue that needs to be fixed.


>>> drivers/vhost/vdpa.c:483:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
>       483 |   r = copy_to_user(featurep, &features, sizeof(features));
>           |   ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>     drivers/vhost/vdpa.c:484:2: note: here
>       484 |  case VHOST_VDPA_GET_IOVA_RANGE:
>           |  ^~~~
>
> vim +483 drivers/vhost/vdpa.c


My bad. V4 is on the road.

Thanks


>
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  426
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  427  static long vhost_vdpa_unlocked_ioctl(struct file *filep,
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  428  				      unsigned int cmd, unsigned long arg)
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  429  {
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  430  	struct vhost_vdpa *v = filep->private_data;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  431  	struct vhost_dev *d = &v->vdev;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  432  	void __user *argp = (void __user *)arg;
> a127c5bbb6a8eee Jason Wang   2020-09-07  433  	u64 __user *featurep = argp;
> a127c5bbb6a8eee Jason Wang   2020-09-07  434  	u64 features;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  435  	long r;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  436
> a127c5bbb6a8eee Jason Wang   2020-09-07  437  	if (cmd == VHOST_SET_BACKEND_FEATURES) {
> a127c5bbb6a8eee Jason Wang   2020-09-07  438  		r = copy_from_user(&features, featurep, sizeof(features));
> a127c5bbb6a8eee Jason Wang   2020-09-07  439  		if (r)
> a127c5bbb6a8eee Jason Wang   2020-09-07  440  			return r;
> a127c5bbb6a8eee Jason Wang   2020-09-07  441  		if (features & ~VHOST_VDPA_BACKEND_FEATURES)
> a127c5bbb6a8eee Jason Wang   2020-09-07  442  			return -EOPNOTSUPP;
> a127c5bbb6a8eee Jason Wang   2020-09-07  443  		vhost_set_backend_features(&v->vdev, features);
> a127c5bbb6a8eee Jason Wang   2020-09-07  444  		return 0;
> a127c5bbb6a8eee Jason Wang   2020-09-07  445  	}
> a127c5bbb6a8eee Jason Wang   2020-09-07  446
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  447  	mutex_lock(&d->mutex);
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  448
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  449  	switch (cmd) {
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  450  	case VHOST_VDPA_GET_DEVICE_ID:
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  451  		r = vhost_vdpa_get_device_id(v, argp);
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  452  		break;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  453  	case VHOST_VDPA_GET_STATUS:
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  454  		r = vhost_vdpa_get_status(v, argp);
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  455  		break;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  456  	case VHOST_VDPA_SET_STATUS:
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  457  		r = vhost_vdpa_set_status(v, argp);
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  458  		break;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  459  	case VHOST_VDPA_GET_CONFIG:
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  460  		r = vhost_vdpa_get_config(v, argp);
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  461  		break;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  462  	case VHOST_VDPA_SET_CONFIG:
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  463  		r = vhost_vdpa_set_config(v, argp);
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  464  		break;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  465  	case VHOST_GET_FEATURES:
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  466  		r = vhost_vdpa_get_features(v, argp);
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  467  		break;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  468  	case VHOST_SET_FEATURES:
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  469  		r = vhost_vdpa_set_features(v, argp);
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  470  		break;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  471  	case VHOST_VDPA_GET_VRING_NUM:
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  472  		r = vhost_vdpa_get_vring_num(v, argp);
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  473  		break;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  474  	case VHOST_SET_LOG_BASE:
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  475  	case VHOST_SET_LOG_FD:
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  476  		r = -ENOIOCTLCMD;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  477  		break;
> 776f395004d829b Zhu Lingshan 2020-06-05  478  	case VHOST_VDPA_SET_CONFIG_CALL:
> 776f395004d829b Zhu Lingshan 2020-06-05  479  		r = vhost_vdpa_set_config_call(v, argp);
> 776f395004d829b Zhu Lingshan 2020-06-05  480  		break;
> a127c5bbb6a8eee Jason Wang   2020-09-07  481  	case VHOST_GET_BACKEND_FEATURES:
> a127c5bbb6a8eee Jason Wang   2020-09-07  482  		features = VHOST_VDPA_BACKEND_FEATURES;
> a127c5bbb6a8eee Jason Wang   2020-09-07 @483  		r = copy_to_user(featurep, &features, sizeof(features));
> 446e7b97838ebf8 Jason Wang   2020-10-23  484  	case VHOST_VDPA_GET_IOVA_RANGE:
> 446e7b97838ebf8 Jason Wang   2020-10-23  485  		r = vhost_vdpa_get_iova_range(v, argp);
> a127c5bbb6a8eee Jason Wang   2020-09-07  486  		break;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  487  	default:
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  488  		r = vhost_dev_ioctl(&v->vdev, cmd, argp);
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  489  		if (r == -ENOIOCTLCMD)
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  490  			r = vhost_vdpa_vring_ioctl(v, cmd, argp);
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  491  		break;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  492  	}
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  493
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  494  	mutex_unlock(&d->mutex);
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  495  	return r;
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  496  }
> 4c8cf31885f69e8 Tiwei Bie    2020-03-26  497
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

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

* Re: [PATCH V3 2/3] vhost: vdpa: report iova range
  2020-10-23  2:24   ` Jason Wang
  (?)
  (?)
@ 2020-10-25  9:32   ` Eli Cohen
  2020-10-25 10:01     ` Eli Cohen
  -1 siblings, 1 reply; 16+ messages in thread
From: Eli Cohen @ 2020-10-25  9:32 UTC (permalink / raw)
  To: Jason Wang
  Cc: mst, virtualization, linux-kernel, rob.miller, lingshan.zhu,
	eperezma, lulu, shahafs, hanand, mhabets, gdawar, saugatm,
	vmireyno, zhangweining, eli

On Fri, Oct 23, 2020 at 10:24:53AM +0800, Jason Wang wrote:
> This patch introduces a new ioctl for vhost-vdpa device that can
> report the iova range by the device.
> 
> For device that implements get_iova_range() method, we fetch it from
> the vDPA device. If device doesn't implement get_iova_range() but
> depends on platform IOMMU, we will query via DOMAIN_ATTR_GEOMETRY,
> otherwise [0, ULLONG_MAX] is assumed.
> 
> For safety, this patch also rules out the map request which is not in
> the valid range.
> 
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
>  drivers/vhost/vdpa.c             | 40 ++++++++++++++++++++++++++++++++
>  include/uapi/linux/vhost.h       |  4 ++++
>  include/uapi/linux/vhost_types.h |  9 +++++++
>  3 files changed, 53 insertions(+)
> 
> diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
> index a2dbc85e0b0d..562ed99116d1 100644
> --- a/drivers/vhost/vdpa.c
> +++ b/drivers/vhost/vdpa.c
> @@ -47,6 +47,7 @@ struct vhost_vdpa {
>  	int minor;
>  	struct eventfd_ctx *config_ctx;
>  	int in_batch;
> +	struct vdpa_iova_range range;
>  };
>  
>  static DEFINE_IDA(vhost_vdpa_ida);
> @@ -337,6 +338,16 @@ static long vhost_vdpa_set_config_call(struct vhost_vdpa *v, u32 __user *argp)
>  	return 0;
>  }
>  
> +static long vhost_vdpa_get_iova_range(struct vhost_vdpa *v, u32 __user *argp)
> +{
> +	struct vhost_vdpa_iova_range range = {
> +		.first = v->range.first,
> +		.last = v->range.last,
> +	};
> +
> +	return copy_to_user(argp, &range, sizeof(range));
> +}
> +
>  static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
>  				   void __user *argp)
>  {
> @@ -470,6 +481,8 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep,
>  	case VHOST_GET_BACKEND_FEATURES:
>  		features = VHOST_VDPA_BACKEND_FEATURES;
>  		r = copy_to_user(featurep, &features, sizeof(features));

missing break statement.

> +	case VHOST_VDPA_GET_IOVA_RANGE:
> +		r = vhost_vdpa_get_iova_range(v, argp);
>  		break;
>  	default:
>  		r = vhost_dev_ioctl(&v->vdev, cmd, argp);
> @@ -597,6 +610,10 @@ static int vhost_vdpa_process_iotlb_update(struct vhost_vdpa *v,
>  	long pinned;
>  	int ret = 0;
>  
> +	if (msg->iova < v->range.first ||
> +	    msg->iova + msg->size - 1 > v->range.last)
> +		return -EINVAL;
> +
>  	if (vhost_iotlb_itree_first(iotlb, msg->iova,
>  				    msg->iova + msg->size - 1))
>  		return -EEXIST;
> @@ -783,6 +800,27 @@ static void vhost_vdpa_free_domain(struct vhost_vdpa *v)
>  	v->domain = NULL;
>  }
>  
> +static void vhost_vdpa_set_iova_range(struct vhost_vdpa *v)
> +{
> +	struct vdpa_iova_range *range = &v->range;
> +	struct iommu_domain_geometry geo;
> +	struct vdpa_device *vdpa = v->vdpa;
> +	const struct vdpa_config_ops *ops = vdpa->config;
> +
> +	if (ops->get_iova_range) {
> +		*range = ops->get_iova_range(vdpa);
> +	} else if (v->domain &&
> +		   !iommu_domain_get_attr(v->domain,
> +		   DOMAIN_ATTR_GEOMETRY, &geo) &&
> +		   geo.force_aperture) {
> +		range->first = geo.aperture_start;
> +		range->last = geo.aperture_end;
> +	} else {
> +		range->first = 0;
> +		range->last = ULLONG_MAX;
> +	}
> +}
> +
>  static int vhost_vdpa_open(struct inode *inode, struct file *filep)
>  {
>  	struct vhost_vdpa *v;
> @@ -823,6 +861,8 @@ static int vhost_vdpa_open(struct inode *inode, struct file *filep)
>  	if (r)
>  		goto err_init_iotlb;
>  
> +	vhost_vdpa_set_iova_range(v);
> +
>  	filep->private_data = v;
>  
>  	return 0;
> diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h
> index 75232185324a..c998860d7bbc 100644
> --- a/include/uapi/linux/vhost.h
> +++ b/include/uapi/linux/vhost.h
> @@ -146,4 +146,8 @@
>  
>  /* Set event fd for config interrupt*/
>  #define VHOST_VDPA_SET_CONFIG_CALL	_IOW(VHOST_VIRTIO, 0x77, int)
> +
> +/* Get the valid iova range */
> +#define VHOST_VDPA_GET_IOVA_RANGE	_IOR(VHOST_VIRTIO, 0x78, \
> +					     struct vhost_vdpa_iova_range)
>  #endif
> diff --git a/include/uapi/linux/vhost_types.h b/include/uapi/linux/vhost_types.h
> index 9a269a88a6ff..f7f6a3a28977 100644
> --- a/include/uapi/linux/vhost_types.h
> +++ b/include/uapi/linux/vhost_types.h
> @@ -138,6 +138,15 @@ struct vhost_vdpa_config {
>  	__u8 buf[0];
>  };
>  
> +/* vhost vdpa IOVA range
> + * @first: First address that can be mapped by vhost-vDPA
> + * @last: Last address that can be mapped by vhost-vDPA
> + */
> +struct vhost_vdpa_iova_range {
> +	__u64 first;
> +	__u64 last;
> +};
> +
>  /* Feature bits */
>  /* Log all write descriptors. Can be changed while device is active. */
>  #define VHOST_F_LOG_ALL 26
> -- 
> 2.20.1
> 

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

* Re: [PATCH V3 2/3] vhost: vdpa: report iova range
  2020-10-25  9:32   ` Eli Cohen
@ 2020-10-25 10:01     ` Eli Cohen
  0 siblings, 0 replies; 16+ messages in thread
From: Eli Cohen @ 2020-10-25 10:01 UTC (permalink / raw)
  To: Jason Wang
  Cc: mst, virtualization, linux-kernel, rob.miller, lingshan.zhu,
	eperezma, lulu, shahafs, hanand, mhabets, gdawar, saugatm,
	vmireyno, zhangweining, eli

On Sun, Oct 25, 2020 at 11:32:39AM +0200, Eli Cohen wrote:

Ignore this. I did not notice it's v3. For some reason I don't see V4 of
this patch in my mailbox.

Anyways, for V4:

Reviewed-by: Eli Cohen <elic@nvidia.com>

> On Fri, Oct 23, 2020 at 10:24:53AM +0800, Jason Wang wrote

> > This patch introduces a new ioctl for vhost-vdpa device that can
> > report the iova range by the device.
> > 
> > For device that implements get_iova_range() method, we fetch it from
> > the vDPA device. If device doesn't implement get_iova_range() but
> > depends on platform IOMMU, we will query via DOMAIN_ATTR_GEOMETRY,
> > otherwise [0, ULLONG_MAX] is assumed.
> > 
> > For safety, this patch also rules out the map request which is not in
> > the valid range.
> > 
> > Signed-off-by: Jason Wang <jasowang@redhat.com>
> > ---
> >  drivers/vhost/vdpa.c             | 40 ++++++++++++++++++++++++++++++++
> >  include/uapi/linux/vhost.h       |  4 ++++
> >  include/uapi/linux/vhost_types.h |  9 +++++++
> >  3 files changed, 53 insertions(+)
> > 
> > diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
> > index a2dbc85e0b0d..562ed99116d1 100644
> > --- a/drivers/vhost/vdpa.c
> > +++ b/drivers/vhost/vdpa.c
> > @@ -47,6 +47,7 @@ struct vhost_vdpa {
> >  	int minor;
> >  	struct eventfd_ctx *config_ctx;
> >  	int in_batch;
> > +	struct vdpa_iova_range range;
> >  };
> >  
> >  static DEFINE_IDA(vhost_vdpa_ida);
> > @@ -337,6 +338,16 @@ static long vhost_vdpa_set_config_call(struct vhost_vdpa *v, u32 __user *argp)
> >  	return 0;
> >  }
> >  
> > +static long vhost_vdpa_get_iova_range(struct vhost_vdpa *v, u32 __user *argp)
> > +{
> > +	struct vhost_vdpa_iova_range range = {
> > +		.first = v->range.first,
> > +		.last = v->range.last,
> > +	};
> > +
> > +	return copy_to_user(argp, &range, sizeof(range));
> > +}
> > +
> >  static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
> >  				   void __user *argp)
> >  {
> > @@ -470,6 +481,8 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep,
> >  	case VHOST_GET_BACKEND_FEATURES:
> >  		features = VHOST_VDPA_BACKEND_FEATURES;
> >  		r = copy_to_user(featurep, &features, sizeof(features));
> 
> missing break statement.
> 
> > +	case VHOST_VDPA_GET_IOVA_RANGE:
> > +		r = vhost_vdpa_get_iova_range(v, argp);
> >  		break;
> >  	default:
> >  		r = vhost_dev_ioctl(&v->vdev, cmd, argp);
> > @@ -597,6 +610,10 @@ static int vhost_vdpa_process_iotlb_update(struct vhost_vdpa *v,
> >  	long pinned;
> >  	int ret = 0;
> >  
> > +	if (msg->iova < v->range.first ||
> > +	    msg->iova + msg->size - 1 > v->range.last)
> > +		return -EINVAL;
> > +
> >  	if (vhost_iotlb_itree_first(iotlb, msg->iova,
> >  				    msg->iova + msg->size - 1))
> >  		return -EEXIST;
> > @@ -783,6 +800,27 @@ static void vhost_vdpa_free_domain(struct vhost_vdpa *v)
> >  	v->domain = NULL;
> >  }
> >  
> > +static void vhost_vdpa_set_iova_range(struct vhost_vdpa *v)
> > +{
> > +	struct vdpa_iova_range *range = &v->range;
> > +	struct iommu_domain_geometry geo;
> > +	struct vdpa_device *vdpa = v->vdpa;
> > +	const struct vdpa_config_ops *ops = vdpa->config;
> > +
> > +	if (ops->get_iova_range) {
> > +		*range = ops->get_iova_range(vdpa);
> > +	} else if (v->domain &&
> > +		   !iommu_domain_get_attr(v->domain,
> > +		   DOMAIN_ATTR_GEOMETRY, &geo) &&
> > +		   geo.force_aperture) {
> > +		range->first = geo.aperture_start;
> > +		range->last = geo.aperture_end;
> > +	} else {
> > +		range->first = 0;
> > +		range->last = ULLONG_MAX;
> > +	}
> > +}
> > +
> >  static int vhost_vdpa_open(struct inode *inode, struct file *filep)
> >  {
> >  	struct vhost_vdpa *v;
> > @@ -823,6 +861,8 @@ static int vhost_vdpa_open(struct inode *inode, struct file *filep)
> >  	if (r)
> >  		goto err_init_iotlb;
> >  
> > +	vhost_vdpa_set_iova_range(v);
> > +
> >  	filep->private_data = v;
> >  
> >  	return 0;
> > diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h
> > index 75232185324a..c998860d7bbc 100644
> > --- a/include/uapi/linux/vhost.h
> > +++ b/include/uapi/linux/vhost.h
> > @@ -146,4 +146,8 @@
> >  
> >  /* Set event fd for config interrupt*/
> >  #define VHOST_VDPA_SET_CONFIG_CALL	_IOW(VHOST_VIRTIO, 0x77, int)
> > +
> > +/* Get the valid iova range */
> > +#define VHOST_VDPA_GET_IOVA_RANGE	_IOR(VHOST_VIRTIO, 0x78, \
> > +					     struct vhost_vdpa_iova_range)
> >  #endif
> > diff --git a/include/uapi/linux/vhost_types.h b/include/uapi/linux/vhost_types.h
> > index 9a269a88a6ff..f7f6a3a28977 100644
> > --- a/include/uapi/linux/vhost_types.h
> > +++ b/include/uapi/linux/vhost_types.h
> > @@ -138,6 +138,15 @@ struct vhost_vdpa_config {
> >  	__u8 buf[0];
> >  };
> >  
> > +/* vhost vdpa IOVA range
> > + * @first: First address that can be mapped by vhost-vDPA
> > + * @last: Last address that can be mapped by vhost-vDPA
> > + */
> > +struct vhost_vdpa_iova_range {
> > +	__u64 first;
> > +	__u64 last;
> > +};
> > +
> >  /* Feature bits */
> >  /* Log all write descriptors. Can be changed while device is active. */
> >  #define VHOST_F_LOG_ALL 26
> > -- 
> > 2.20.1
> > 

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

end of thread, other threads:[~2020-10-25 10:02 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-23  2:24 [PATCH V3 0/3] vDPA: API for reporting IOVA range Jason Wang
2020-10-23  2:24 ` Jason Wang
2020-10-23  2:24 ` [PATCH V3 1/3] vdpa: introduce config op to get valid iova range Jason Wang
2020-10-23  2:24   ` Jason Wang
2020-10-23  2:24 ` [PATCH V3 2/3] vhost: vdpa: report " Jason Wang
2020-10-23  2:24   ` Jason Wang
2020-10-23  5:28   ` kernel test robot
2020-10-23  5:28     ` kernel test robot
2020-10-23  5:28     ` kernel test robot
2020-10-23  8:46     ` Jason Wang
2020-10-23  8:46       ` Jason Wang
2020-10-23  8:46       ` Jason Wang
2020-10-25  9:32   ` Eli Cohen
2020-10-25 10:01     ` Eli Cohen
2020-10-23  2:24 ` [PATCH V3 3/3] vdpa_sim: implement get_iova_range() Jason Wang
2020-10-23  2:24   ` Jason Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.