Skip to content

Commit 794ec49

Browse files
stefano-garzarellamstsirkin
authored andcommitted
vdpa_sim: fix vringh initialization in vdpasim_queue_ready()
When we initialize vringh, we should pass the features and the number of elements in the virtqueue negotiated with the driver, otherwise operations with vringh may fail. This was discovered in a case where the driver sets a number of elements in the virtqueue different from the value returned by .get_vq_num_max(). In vdpasim_vq_reset() is safe to initialize the vringh with default values, since the virtqueue will not be used until vdpasim_queue_ready() is called again. Fixes: 2c53d0f ("vdpasim: vDPA device simulator") Signed-off-by: Stefano Garzarella <[email protected]> Message-Id: <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> Acked-by: Jason Wang <[email protected]> Acked-by: Eugenio Pérez <[email protected]>
1 parent f4e468f commit 794ec49

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/vdpa/vdpa_sim/vdpa_sim.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ static void vdpasim_queue_ready(struct vdpasim *vdpasim, unsigned int idx)
6767
{
6868
struct vdpasim_virtqueue *vq = &vdpasim->vqs[idx];
6969

70-
vringh_init_iotlb(&vq->vring, vdpasim->dev_attr.supported_features,
71-
VDPASIM_QUEUE_MAX, false,
70+
vringh_init_iotlb(&vq->vring, vdpasim->features, vq->num, false,
7271
(struct vring_desc *)(uintptr_t)vq->desc_addr,
7372
(struct vring_avail *)
7473
(uintptr_t)vq->driver_addr,

0 commit comments

Comments
 (0)