vdpa_sim: fix vringh initialization in vdpasim_queue_ready()
authorStefano Garzarella <sgarzare@redhat.com>
Thu, 10 Nov 2022 14:13:35 +0000 (15:13 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 12 Jan 2023 11:02:08 +0000 (12:02 +0100)
commitc72123cd79dd3b230014e209db368e4160e72dfb
tree5f277dc40e0ebc1738e89d9057ae85887d9f4105
parenta2907867e2c86067accd2f011d6f23ee5533aa6c
vdpa_sim: fix vringh initialization in vdpasim_queue_ready()

[ Upstream commit 794ec498c9fa79e6bfd71b931410d5897a9c00d4 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/vdpa/vdpa_sim/vdpa_sim.c