]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob
ab5f9f7bf0b186c4caa4b7574a235bbee5d6c4a9
[thirdparty/kernel/stable-queue.git] /
1 From 27e99ade81368e6fdda3212bff9345177cf9e57a Mon Sep 17 00:00:00 2001
2 From: Wang Sen <senwang@linux.vnet.ibm.com>
3 Date: Mon, 30 Jul 2012 14:25:06 +0800
4 Subject: SCSI: scsi: virtio-scsi: Fix address translation failure of HighMem pages used by sg list
5
6 From: Wang Sen <senwang@linux.vnet.ibm.com>
7
8 commit 27e99ade81368e6fdda3212bff9345177cf9e57a upstream.
9
10 When using the commands below to write some data to a virtio-scsi LUN of the
11 QEMU guest(32-bit) with 1G physical memory(qemu -m 1024), the qemu will crash.
12
13 # sudo mkfs.ext4 /dev/sdb (/dev/sdb is the virtio-scsi LUN.)
14 # sudo mount /dev/sdb /mnt
15 # dd if=/dev/zero of=/mnt/file bs=1M count=1024
16
17 In current implementation, sg_set_buf is called to add buffers to sg list which
18 is put into the virtqueue eventually. But if there are some HighMem pages in
19 table->sgl you can not get virtual address by sg_virt. So, sg_virt(sg_elem) may
20 return NULL value. This will cause QEMU exit when virtqueue_map_sg is called
21 in QEMU because an invalid GPA is passed by virtqueue.
22
23 Two solutions are discussed here:
24 http://lkml.indiana.edu/hypermail/linux/kernel/1207.3/00675.html
25
26 Finally, value assignment approach was adopted because:
27
28 Value assignment creates a well-formed scatterlist, because the termination
29 marker in source sg_list has been set in blk_rq_map_sg(). The last entry of the
30 source sg_list is just copied to the the last entry in destination list. Note
31 that, for now, virtio_ring does not care about the form of the scatterlist and
32 simply processes the first out_num + in_num consecutive elements of the sg[]
33 array.
34
35 I have tested the patch on my workstation. QEMU would not crash any more.
36
37 Signed-off-by: Wang Sen <senwang@linux.vnet.ibm.com>
38 Acked-by: Paolo Bonzini <pbonzini@redhat.com>
39 Signed-off-by: James Bottomley <JBottomley@Parallels.com>
40 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
41
42 ---
43 drivers/scsi/virtio_scsi.c | 2 +-
44 1 file changed, 1 insertion(+), 1 deletion(-)
45
46 --- a/drivers/scsi/virtio_scsi.c
47 +++ b/drivers/scsi/virtio_scsi.c
48 @@ -198,7 +198,7 @@ static void virtscsi_map_sgl(struct scat
49 int i;
50
51 for_each_sg(table->sgl, sg_elem, table->nents, i)
52 - sg_set_buf(&sg[idx++], sg_virt(sg_elem), sg_elem->length);
53 + sg[idx++] = *sg_elem;
54
55 *p_idx = idx;
56 }