* [PATCH v1] vhost: fail device start if iotlb update fails
@ 2024-11-07 11:32 Prasad Pandit
2024-11-07 13:19 ` Stefano Garzarella
2024-11-11 1:38 ` Jason Wang
0 siblings, 2 replies; 4+ messages in thread
From: Prasad Pandit @ 2024-11-07 11:32 UTC (permalink / raw)
To: qemu-devel; +Cc: Stefano Garzarella, jasowang, eperezma, mst, Prasad Pandit
From: Prasad Pandit <pjp@fedoraproject.org>
While starting a vhost device, updating iotlb entries
via 'vhost_device_iotlb_miss' may return an error.
qemu-kvm: vhost_device_iotlb_miss:
700871,700871: Fail to update device iotlb
Fail device start when such an error occurs.
Signed-off-by: Prasad Pandit <pjp@fedoraproject.org>
---
hw/virtio/vhost.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
v1:
- Remove VHOST_OPS_DEBUG call.
- Call vhost_set_iotlb_callback and vhost_dev_start with 'false' argument.
v0:
- https://lore.kernel.org/qemu-devel/20241105060053.61973-1-ppandit@redhat.com/
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 76f9b2aaad..c40f48ac4d 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -2095,11 +2095,22 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings)
* vhost-kernel code requires for this.*/
for (i = 0; i < hdev->nvqs; ++i) {
struct vhost_virtqueue *vq = hdev->vqs + i;
- vhost_device_iotlb_miss(hdev, vq->used_phys, true);
+ r = vhost_device_iotlb_miss(hdev, vq->used_phys, true);
+ if (r) {
+ goto fail_iotlb;
+ }
}
}
vhost_start_config_intr(hdev);
return 0;
+fail_iotlb:
+ if (vhost_dev_has_iommu(hdev) &&
+ hdev->vhost_ops->vhost_set_iotlb_callback) {
+ hdev->vhost_ops->vhost_set_iotlb_callback(hdev, false);
+ }
+ if (hdev->vhost_ops->vhost_dev_start) {
+ hdev->vhost_ops->vhost_dev_start(hdev, false);
+ }
fail_start:
if (vrings) {
vhost_dev_set_vring_enable(hdev, false);
--
2.47.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v1] vhost: fail device start if iotlb update fails
2024-11-07 11:32 [PATCH v1] vhost: fail device start if iotlb update fails Prasad Pandit
@ 2024-11-07 13:19 ` Stefano Garzarella
2024-11-11 1:38 ` Jason Wang
1 sibling, 0 replies; 4+ messages in thread
From: Stefano Garzarella @ 2024-11-07 13:19 UTC (permalink / raw)
To: Prasad Pandit; +Cc: qemu-devel, jasowang, eperezma, mst, Prasad Pandit
On Thu, Nov 07, 2024 at 05:02:47PM +0530, Prasad Pandit wrote:
>From: Prasad Pandit <pjp@fedoraproject.org>
>
>While starting a vhost device, updating iotlb entries
>via 'vhost_device_iotlb_miss' may return an error.
>
> qemu-kvm: vhost_device_iotlb_miss:
> 700871,700871: Fail to update device iotlb
>
>Fail device start when such an error occurs.
>
>Signed-off-by: Prasad Pandit <pjp@fedoraproject.org>
>---
> hw/virtio/vhost.c | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
>
>v1:
> - Remove VHOST_OPS_DEBUG call.
> - Call vhost_set_iotlb_callback and vhost_dev_start with 'false' argument.
LGTM!
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
>
>v0:
> - https://lore.kernel.org/qemu-devel/20241105060053.61973-1-ppandit@redhat.com/
>
>diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
>index 76f9b2aaad..c40f48ac4d 100644
>--- a/hw/virtio/vhost.c
>+++ b/hw/virtio/vhost.c
>@@ -2095,11 +2095,22 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings)
> * vhost-kernel code requires for this.*/
> for (i = 0; i < hdev->nvqs; ++i) {
> struct vhost_virtqueue *vq = hdev->vqs + i;
>- vhost_device_iotlb_miss(hdev, vq->used_phys, true);
>+ r = vhost_device_iotlb_miss(hdev, vq->used_phys, true);
>+ if (r) {
>+ goto fail_iotlb;
>+ }
> }
> }
> vhost_start_config_intr(hdev);
> return 0;
>+fail_iotlb:
>+ if (vhost_dev_has_iommu(hdev) &&
>+ hdev->vhost_ops->vhost_set_iotlb_callback) {
>+ hdev->vhost_ops->vhost_set_iotlb_callback(hdev, false);
>+ }
>+ if (hdev->vhost_ops->vhost_dev_start) {
>+ hdev->vhost_ops->vhost_dev_start(hdev, false);
>+ }
> fail_start:
> if (vrings) {
> vhost_dev_set_vring_enable(hdev, false);
>--
>2.47.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v1] vhost: fail device start if iotlb update fails
2024-11-07 11:32 [PATCH v1] vhost: fail device start if iotlb update fails Prasad Pandit
2024-11-07 13:19 ` Stefano Garzarella
@ 2024-11-11 1:38 ` Jason Wang
2024-11-11 9:49 ` Prasad Pandit
1 sibling, 1 reply; 4+ messages in thread
From: Jason Wang @ 2024-11-11 1:38 UTC (permalink / raw)
To: Prasad Pandit
Cc: qemu-devel, Stefano Garzarella, eperezma, mst, Prasad Pandit
Hi Prasad:
On Thu, Nov 7, 2024 at 7:33 PM Prasad Pandit <ppandit@redhat.com> wrote:
>
> From: Prasad Pandit <pjp@fedoraproject.org>
>
> While starting a vhost device, updating iotlb entries
> via 'vhost_device_iotlb_miss' may return an error.
>
> qemu-kvm: vhost_device_iotlb_miss:
> 700871,700871: Fail to update device iotlb
Actually, such updating is a workaround for vhost-net kernel to run.
I wonder what kind of issue would we get if we don't do this?
Thanks
>
> Fail device start when such an error occurs.
>
> Signed-off-by: Prasad Pandit <pjp@fedoraproject.org>
> ---
> hw/virtio/vhost.c | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
>
> v1:
> - Remove VHOST_OPS_DEBUG call.
> - Call vhost_set_iotlb_callback and vhost_dev_start with 'false' argument.
>
> v0:
> - https://lore.kernel.org/qemu-devel/20241105060053.61973-1-ppandit@redhat.com/
>
> diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
> index 76f9b2aaad..c40f48ac4d 100644
> --- a/hw/virtio/vhost.c
> +++ b/hw/virtio/vhost.c
> @@ -2095,11 +2095,22 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings)
> * vhost-kernel code requires for this.*/
> for (i = 0; i < hdev->nvqs; ++i) {
> struct vhost_virtqueue *vq = hdev->vqs + i;
> - vhost_device_iotlb_miss(hdev, vq->used_phys, true);
> + r = vhost_device_iotlb_miss(hdev, vq->used_phys, true);
> + if (r) {
> + goto fail_iotlb;
> + }
> }
> }
> vhost_start_config_intr(hdev);
> return 0;
> +fail_iotlb:
> + if (vhost_dev_has_iommu(hdev) &&
> + hdev->vhost_ops->vhost_set_iotlb_callback) {
> + hdev->vhost_ops->vhost_set_iotlb_callback(hdev, false);
> + }
> + if (hdev->vhost_ops->vhost_dev_start) {
> + hdev->vhost_ops->vhost_dev_start(hdev, false);
> + }
> fail_start:
> if (vrings) {
> vhost_dev_set_vring_enable(hdev, false);
> --
> 2.47.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v1] vhost: fail device start if iotlb update fails
2024-11-11 1:38 ` Jason Wang
@ 2024-11-11 9:49 ` Prasad Pandit
0 siblings, 0 replies; 4+ messages in thread
From: Prasad Pandit @ 2024-11-11 9:49 UTC (permalink / raw)
To: Jason Wang; +Cc: qemu-devel, Stefano Garzarella, eperezma, mst, Prasad Pandit
Hello Jason,
On Mon, 11 Nov 2024 at 07:08, Jason Wang <jasowang@redhat.com> wrote:
> > While starting a vhost device, updating iotlb entries
> > via 'vhost_device_iotlb_miss' may return an error.
> >
> > qemu-kvm: vhost_device_iotlb_miss:
> > 700871,700871: Fail to update device iotlb
>
> Actually, such updating is a workaround for vhost-net kernel to run.
> I wonder what kind of issue would we get if we don't do this?
* During Postcopy migration, while starting the 'vhost-user' device,
update of its iotlb entries would fail and the guest on the
destination would hang, not finishing the migration. There might be
other such scenarios.
Thank you.
---
- Prasad
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-11-11 9:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-07 11:32 [PATCH v1] vhost: fail device start if iotlb update fails Prasad Pandit
2024-11-07 13:19 ` Stefano Garzarella
2024-11-11 1:38 ` Jason Wang
2024-11-11 9:49 ` Prasad Pandit
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).