Skip to content

Commit a09483c

Browse files
dtatuleamstsirkin
authored andcommitted
vdpa: Block vq property changes in DRIVER_OK
The virtio standard doesn't allow for virtqueue address and state changes when the device is in DRIVER_OK. Return an error in such cases unless the device is suspended. The suspended device exception is needed because some devices support virtqueue changes when the device is suspended. Signed-off-by: Dragos Tatulea <dtatulea@nvidia.com> Suggested-by: Eugenio Pérez <eperezma@redhat.com> Message-Id: <20231225134210.151540-3-dtatulea@nvidia.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
1 parent c7e1944 commit a09483c

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

drivers/vhost/vdpa.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,9 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
703703

704704
switch (cmd) {
705705
case VHOST_SET_VRING_ADDR:
706+
if ((ops->get_status(vdpa) & VIRTIO_CONFIG_S_DRIVER_OK) && !v->suspended)
707+
return -EINVAL;
708+
706709
if (ops->set_vq_address(vdpa, idx,
707710
(u64)(uintptr_t)vq->desc,
708711
(u64)(uintptr_t)vq->avail,
@@ -711,6 +714,9 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
711714
break;
712715

713716
case VHOST_SET_VRING_BASE:
717+
if ((ops->get_status(vdpa) & VIRTIO_CONFIG_S_DRIVER_OK) && !v->suspended)
718+
return -EINVAL;
719+
714720
if (vhost_has_feature(vq, VIRTIO_F_RING_PACKED)) {
715721
vq_state.packed.last_avail_idx = vq->last_avail_idx & 0x7fff;
716722
vq_state.packed.last_avail_counter = !!(vq->last_avail_idx & 0x8000);

0 commit comments

Comments
 (0)