OSDN Git Service

virtio-ring: store DMA metadata in desc_extra for split virtqueue
authorJason Wang <jasowang@redhat.com>
Fri, 4 Jun 2021 05:53:50 +0000 (13:53 +0800)
committerMichael S. Tsirkin <mst@redhat.com>
Thu, 8 Jul 2021 11:49:01 +0000 (07:49 -0400)
commit72b5e8958738aaa453db5149e6ca3bcf416023b9
tree68fa57d49883f293e04dc4cfff5f340618280655
parent5bc72234f7c65830e60806dbb73ae76bacd8a061
virtio-ring: store DMA metadata in desc_extra for split virtqueue

For split virtqueue, we used to depend on the address, length and
flags stored in the descriptor ring for DMA unmapping. This is unsafe
for the case since the device can manipulate the behavior of virtio
driver, IOMMU drivers and swiotlb.

For safety, maintain the DMA address, DMA length, descriptor flags and
next filed of the non indirect descriptors in vring_desc_state_extra
when DMA API is used for virtio as we did for packed virtqueue and use
those metadata for performing DMA operations. Indirect descriptors
should be safe since they are using streaming mappings.

With this the descriptor ring is write only form the view of the
driver.

This slight increase the footprint of the drive but it's not noticed
through pktgen (64B) test and netperf test in the case of virtio-net.

Signed-off-by: Jason Wang <jasowang@redhat.com>
Link: https://lore.kernel.org/r/20210604055350.58753-8-jasowang@redhat.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/virtio/virtio_ring.c