WSL2-Linux-Kernel/drivers/vdpa/vdpa_sim
Eugenio Pérez ee6ef81377 vdpa_sim: set last_used_idx as last_avail_idx in vdpasim_queue_ready
[ Upstream commit b4cca6d48e ]

Starting from an used_idx different than 0 is needed in use cases like
virtual machine migration.  Not doing so and letting the caller set an
avail idx different than 0 causes destination device to try to use old
buffers that source driver already recover and are not available
anymore.

Since vdpa_sim does not support receive inflight descriptors as a
destination of a migration, let's set both avail_idx and used_idx the
same at vq start.  This is how vhost-user works in a
VHOST_SET_VRING_BASE call.

Although the simple fix is to set last_used_idx at vdpasim_set_vq_state,
it would be reset at vdpasim_queue_ready.  The last_avail_idx case is
fixed with commit 0e84f918fa ("vdpa_sim: not reset state in
vdpasim_queue_ready").  Since the only option is to make it equal to
last_avail_idx, adding the only change needed here.

This was discovered and tested live migrating the vdpa_sim_net device.

Fixes: 2c53d0f64c ("vdpasim: vDPA device simulator")
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
Message-Id: <20230302181857.925374-1-eperezma@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-03-22 13:31:24 +01:00
..
Makefile vdpa: add vdpa simulator for block device 2021-05-03 04:55:53 -04:00
vdpa_sim.c vdpa_sim: set last_used_idx as last_avail_idx in vdpasim_queue_ready 2023-03-22 13:31:24 +01:00
vdpa_sim.h vdpa_sim: use iova module to allocate IOVA addresses 2021-05-03 04:55:52 -04:00
vdpa_sim_blk.c vdpa_sim: fix possible memory leak in vdpasim_net_init() and vdpasim_blk_init() 2023-01-12 11:59:10 +01:00
vdpa_sim_net.c vdpa_sim: fix possible memory leak in vdpasim_net_init() and vdpasim_blk_init() 2023-01-12 11:59:10 +01:00