linux-stable/drivers/vhost
Mike Christie 0993d26ddd vhost-scsi: Fix alignment handling with windows
[ Upstream commit 5ced58bfa1 ]

The linux block layer requires bios/requests to have lengths with a 512
byte alignment. Some drivers/layers like dm-crypt and the directi IO code
will test for it and just fail. Other drivers like SCSI just assume the
requirement is met and will end up in infinte retry loops. The problem
for drivers like SCSI is that it uses functions like blk_rq_cur_sectors
and blk_rq_sectors which divide the request's length by 512. If there's
lefovers then it just gets dropped. But other code in the block/scsi
layer may use blk_rq_bytes/blk_rq_cur_bytes and end up thinking there is
still data left and try to retry the cmd. We can then end up getting
stuck in retry loops where part of the block/scsi thinks there is data
left, but other parts think we want to do IOs of zero length.

Linux will always check for alignment, but windows will not. When
vhost-scsi then translates the iovec it gets from a windows guest to a
scatterlist, we can end up with sg items where the sg->length is not
divisible by 512 due to the misaligned offset:

sg[0].offset = 255;
sg[0].length = 3841;
sg...
sg[N].offset = 0;
sg[N].length = 255;

When the lio backends then convert the SG to bios or other iovecs, we
end up sending them with the same misaligned values and can hit the
issues above.

This just has us drop down to allocating a temp page and copying the data
when we detect a misaligned buffer and the IO is large enough that it
will get split into multiple bad IOs.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
Message-Id: <20230709202859.138387-2-michael.christie@oracle.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-09-13 09:47:54 +02:00
..
Kconfig vhost_task: Allow vhost layer to use copy_process 2023-03-23 12:45:36 +01:00
Makefile
iotlb.c vhost_iotlb: split out IOTLB initialization 2022-05-31 12:44:28 -04:00
net.c vhost_net: revert upend_idx only on retriable error 2023-06-08 15:43:08 -04:00
scsi.c vhost-scsi: Fix alignment handling with windows 2023-09-13 09:47:54 +02:00
test.c vhost-test: remove meaningless debug info 2023-02-20 19:26:58 -05:00
test.h
vdpa.c vhost_vdpa: support PACKED when setting-getting vring_base 2023-06-09 12:08:04 -04:00
vhost.c vhost: support PACKED when setting-getting vring_base 2023-06-09 12:07:52 -04:00
vhost.h vhost: support PACKED when setting-getting vring_base 2023-06-09 12:07:52 -04:00
vringh.c vringh: support VA with iotlb 2023-04-21 03:02:33 -04:00
vsock.c vsock: support sockmap 2023-03-29 08:19:38 +01:00