Skip to content

Commit

Permalink
x86/kvm: Make VirtIO use DMA API in KVM guest
Browse files Browse the repository at this point in the history
VirtIO for KVM is a primary way to provide IO. All memory that used for
communication with the host has to be marked as shared.

The easiest way to archive that is to use DMA API that already knows how
to deal with shared memory.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
  • Loading branch information
kiryl authored and intel-lab-lkp committed Oct 20, 2020
1 parent 0bdb6c3 commit e3df08a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/virtio/virtio_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <linux/hrtimer.h>
#include <linux/dma-mapping.h>
#include <xen/xen.h>
#include <asm/kvm_para.h>

#ifdef DEBUG
/* For development, we want to crash whenever the ring is screwed. */
Expand Down Expand Up @@ -255,6 +256,9 @@ static bool vring_use_dma_api(struct virtio_device *vdev)
if (xen_domain())
return true;

if (kvm_mem_protected())
return true;

return false;
}

Expand Down

0 comments on commit e3df08a

Please sign in to comment.