diff options
author | Stefano Garzarella <sgarzare@redhat.com> | 2022-11-10 15:13:35 +0100 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2022-12-28 05:28:10 -0500 |
commit | 794ec498c9fa79e6bfd71b931410d5897a9c00d4 (patch) | |
tree | eab30069c5a557471f22d9bc4cb023fd9833d112 /drivers/vdpa/vdpa_sim | |
parent | f4e468f708386ce5fa6878a7ef43a9818ceeaecf (diff) | |
download | linux-stable-794ec498c9fa79e6bfd71b931410d5897a9c00d4.tar.gz linux-stable-794ec498c9fa79e6bfd71b931410d5897a9c00d4.tar.bz2 linux-stable-794ec498c9fa79e6bfd71b931410d5897a9c00d4.zip |
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: 2c53d0f64c06 ("vdpasim: vDPA device simulator")
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Message-Id: <20221110141335.62171-1-sgarzare@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Acked-by: Eugenio PĂ©rez <eperezma@redhat.com>
Diffstat (limited to 'drivers/vdpa/vdpa_sim')
-rw-r--r-- | drivers/vdpa/vdpa_sim/vdpa_sim.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c index b071f0d842fb..b20689f8fe89 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c @@ -67,8 +67,7 @@ static void vdpasim_queue_ready(struct vdpasim *vdpasim, unsigned int idx) { struct vdpasim_virtqueue *vq = &vdpasim->vqs[idx]; - vringh_init_iotlb(&vq->vring, vdpasim->dev_attr.supported_features, - VDPASIM_QUEUE_MAX, false, + vringh_init_iotlb(&vq->vring, vdpasim->features, vq->num, false, (struct vring_desc *)(uintptr_t)vq->desc_addr, (struct vring_avail *) (uintptr_t)vq->driver_addr, |