Re: [PATCH vhost v4 08/15] vdpa: Block vq state change in DRIVER_OK unless device supports it

From: Eugenio Perez Martin
Date: Wed Dec 20 2023 - 11:33:22 EST


On Tue, Dec 19, 2023 at 7:10 PM Dragos Tatulea <dtatulea@xxxxxxxxxx> wrote:
>
> Virtqueue state change during DRIVE_OK is not supported by the virtio
> standard. Allow this op in DRIVER_OK only for devices that support
> changing the state during DRIVER_OK if the device is suspended.
>
> Signed-off-by: Dragos Tatulea <dtatulea@xxxxxxxxxx>
> Suggested-by: Eugenio Pérez <eperezma@xxxxxxxxxx>

Acked-by: Eugenio Pérez <eperezma@xxxxxxxxxx>

> ---
> drivers/vhost/vdpa.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
> index 6bfa3391935a..77509440c723 100644
> --- a/drivers/vhost/vdpa.c
> +++ b/drivers/vhost/vdpa.c
> @@ -641,6 +641,9 @@ static bool vhost_vdpa_vq_config_allowed(struct vhost_vdpa *v, unsigned int cmd)
> case VHOST_SET_VRING_ADDR:
> feature = VHOST_BACKEND_F_CHANGEABLE_VQ_ADDR_IN_SUSPEND;
> break;
> + case VHOST_SET_VRING_BASE:
> + feature = VHOST_BACKEND_F_CHANGEABLE_VQ_STATE_IN_SUSPEND;
> + break;
> default:
> return false;
> }
> @@ -737,6 +740,9 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
> break;
>
> case VHOST_SET_VRING_BASE:
> + if (!vhost_vdpa_vq_config_allowed(v, cmd))
> + return -EOPNOTSUPP;
> +
> if (vhost_has_feature(vq, VIRTIO_F_RING_PACKED)) {
> vq_state.packed.last_avail_idx = vq->last_avail_idx & 0x7fff;
> vq_state.packed.last_avail_counter = !!(vq->last_avail_idx & 0x8000);
> --
> 2.43.0
>