summary refs log tree commit diff
path: root/devices/src/pci/vfio_pci.rs
diff options
context:
space:
mode:
authorXiong Zhang <xiong.y.zhang@intel.corp-partner.google.com>2019-04-23 17:14:55 +0800
committerCommit Bot <commit-bot@chromium.org>2019-10-01 03:59:49 +0000
commitc554fff2064cf04fe89121ec86889b32a56bf195 (patch)
tree401d34e0e0927158c45feb8ba7252ec82504b025 /devices/src/pci/vfio_pci.rs
parent17b0daf88c97be0ace69d4b19b3352053668e96b (diff)
downloadcrosvm-c554fff2064cf04fe89121ec86889b32a56bf195.tar
crosvm-c554fff2064cf04fe89121ec86889b32a56bf195.tar.gz
crosvm-c554fff2064cf04fe89121ec86889b32a56bf195.tar.bz2
crosvm-c554fff2064cf04fe89121ec86889b32a56bf195.tar.lz
crosvm-c554fff2064cf04fe89121ec86889b32a56bf195.tar.xz
crosvm-c554fff2064cf04fe89121ec86889b32a56bf195.tar.zst
crosvm-c554fff2064cf04fe89121ec86889b32a56bf195.zip
vfio: Setup dma map for vfio device
For each guest memory region, setup the corresponding gpa to hva map
in the kernel vfio iommu table. Then the kernel vfio driver could
get the hpa through gpa. Device could use this gpa for dma also.

BUG=chromium:992270
TEST=none

Change-Id: I04008d68ab2ed182a789d6ee8c97a0ed9e1e4756
Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1581141
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Diffstat (limited to 'devices/src/pci/vfio_pci.rs')
-rw-r--r--devices/src/pci/vfio_pci.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/devices/src/pci/vfio_pci.rs b/devices/src/pci/vfio_pci.rs
index cdb253c..9073312 100644
--- a/devices/src/pci/vfio_pci.rs
+++ b/devices/src/pci/vfio_pci.rs
@@ -8,7 +8,7 @@ use std::u32;
 
 use kvm::Datamatch;
 use resources::{Alloc, SystemAllocator};
-use sys_util::EventFd;
+use sys_util::{error, EventFd};
 
 use vfio_sys::*;
 
@@ -230,6 +230,14 @@ impl PciDevice for VfioPciDevice {
                 i += 1;
             }
         }
+
+        if let Err(e) = self.device.setup_dma_map() {
+            error!(
+                "failed to add all guest memory regions into iommu table: {}",
+                e
+            );
+        }
+
         Ok(ranges)
     }