Skip to content

Commit 3bb7df6

Browse files
vhost: fix vring addr update with vDPA
For vDPA devices, vq are not locked once the device has been configured at runtime. On the other hand, we need to hold the vq lock to evaluate vq->access_ok, invalidate vring addresses and translate them. Move vring address update earlier and, when vDPA is configured, skip parts which expect lock to be taken. Bugzilla ID: 1394 Fixes: 741dc05 ("vhost: annotate virtqueue access checks") Signed-off-by: David Marchand <[email protected]> Reviewed-by: Maxime Coquelin <[email protected]>
1 parent d0d7032 commit 3bb7df6

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lib/vhost/vhost_user.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -986,17 +986,20 @@ vhost_user_set_vring_addr(struct virtio_net **pdev,
986986
/* addr->index refers to the queue index. The txq 1, rxq is 0. */
987987
vq = dev->virtqueue[ctx->msg.payload.addr.index];
988988

989-
/* vhost_user_lock_all_queue_pairs locked all qps */
990-
VHOST_USER_ASSERT_LOCK(dev, vq, VHOST_USER_SET_VRING_ADDR);
991-
992-
access_ok = vq->access_ok;
993-
994989
/*
995990
* Rings addresses should not be interpreted as long as the ring is not
996991
* started and enabled
997992
*/
998993
memcpy(&vq->ring_addrs, addr, sizeof(*addr));
999994

995+
if (dev->flags & VIRTIO_DEV_VDPA_CONFIGURED)
996+
goto out;
997+
998+
/* vhost_user_lock_all_queue_pairs locked all qps */
999+
VHOST_USER_ASSERT_LOCK(dev, vq, VHOST_USER_SET_VRING_ADDR);
1000+
1001+
access_ok = vq->access_ok;
1002+
10001003
vring_invalidate(dev, vq);
10011004

10021005
if ((vq->enabled && (dev->features &
@@ -1006,6 +1009,7 @@ vhost_user_set_vring_addr(struct virtio_net **pdev,
10061009
*pdev = dev;
10071010
}
10081011

1012+
out:
10091013
return RTE_VHOST_MSG_RESULT_OK;
10101014
}
10111015

0 commit comments

Comments
 (0)