qemu/hw/virtio
Michael S. Tsirkin 8059feee00 virtio: introduce virtio_map
virtio_map_sg currently fails if one of the entries it's mapping is
contigious in GPA but not HVA address space.  Introduce virtio_map which
handles this by splitting sg entries.

This new API generally turns out to be a good idea since it's harder to
misuse: at least in one case the existing one was used incorrectly.

This will still fail if there's no space left in the sg, but luckily max
queue size in use is currently 256, while max sg size is 1024, so we
should be OK even is all entries happen to cross a single DIMM boundary.

Won't work well with very small DIMM sizes, unfortunately:
e.g. this will fail with 4K DIMMs where a single
request might span a large number of DIMMs.

Let's hope these are uncommon - at least we are not breaking things.

Note: virtio-scsi calls virtio_map_sg on data loaded from network, and
validates input, asserting on failure.  Copy the validating code here -
it will be dropped from virtio-scsi in a follow-up patch.

Reported-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
2015-10-29 11:05:24 +02:00
..
dataplane virtio dataplane: adapt dataplane for virtio Version 1 2015-10-12 11:16:45 +01:00
Makefile.objs dataplane: endianness-aware accesses 2015-02-16 15:07:16 +00:00
vhost-backend.c vhost: use a function for each call 2015-10-22 14:34:49 +03:00
vhost-user.c vhost-user: cleanup msg size math 2015-10-29 11:05:24 +02:00
vhost.c vhost: set the correct queue index in case of migration with multiqueue 2015-10-22 14:34:50 +03:00
virtio-balloon.c virtio: avoid leading underscores for helpers 2015-09-10 11:06:05 +03:00
virtio-bus.c virtio: get_features() can fail 2015-07-27 18:11:53 +03:00
virtio-mmio.c virtio: allow virtio-1 queue layout 2015-06-10 18:15:04 +02:00
virtio-pci.c kvm: Pass PCI device pointer to MSI routing functions 2015-10-19 10:13:07 +02:00
virtio-pci.h virtio-input: Fix device introspection on non-Linux hosts 2015-10-09 15:25:56 +02:00
virtio-rng.c virtio: get_features() can fail 2015-07-27 18:11:53 +03:00
virtio.c virtio: introduce virtio_map 2015-10-29 11:05:24 +02:00