summary refs log tree commit diff
path: root/vm_control/src
diff options
context:
space:
mode:
authorXiong Zhang <xiong.y.zhang@intel.corp-partner.google.com>2019-10-29 17:32:44 +0800
committerCommit Bot <commit-bot@chromium.org>2019-11-10 06:39:31 +0000
commit87a3b44d9e6caa82ab521a5dd9bafdb56e8b6ed1 (patch)
tree29bc942019a2cdb32d292c4650eccb5cf0deaddf /vm_control/src
parent279248255f9f65c6baf044f1fbff0011bcd9938a (diff)
downloadcrosvm-87a3b44d9e6caa82ab521a5dd9bafdb56e8b6ed1.tar
crosvm-87a3b44d9e6caa82ab521a5dd9bafdb56e8b6ed1.tar.gz
crosvm-87a3b44d9e6caa82ab521a5dd9bafdb56e8b6ed1.tar.bz2
crosvm-87a3b44d9e6caa82ab521a5dd9bafdb56e8b6ed1.tar.lz
crosvm-87a3b44d9e6caa82ab521a5dd9bafdb56e8b6ed1.tar.xz
crosvm-87a3b44d9e6caa82ab521a5dd9bafdb56e8b6ed1.tar.zst
crosvm-87a3b44d9e6caa82ab521a5dd9bafdb56e8b6ed1.zip
Resource: Unify mmio allocator
Current mmio and device two allocators exist, the purpose to define
two allocator is:
Accessing to gpa from mmio allocator cause vm exit, while gpa from
device allocator doesn't cause vm exit.

Whether vm exits exist or not, dependency on whether
vm->add_device_memory() is called with gpa from allocator or not.Even
if gpa is from mmio alloator, and vm->add_device_memory() is called
with this gpa, accessing this gpa won't cause vm exit. So mmio allocator
and device allocator couldn't guarantee the original purpose.

This patch unify mmio allocator and device allocator into one mmio
allocator.

BUG=chromium:992270
TEST=this patch doesn't change function, so just run build_test

Change-Id: If87d5c2838eb122ef627fa45c394b1b3ccfafeb0
Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1895233
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Diffstat (limited to 'vm_control/src')
-rw-r--r--vm_control/src/lib.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/vm_control/src/lib.rs b/vm_control/src/lib.rs
index f25ab20..71bb193 100644
--- a/vm_control/src/lib.rs
+++ b/vm_control/src/lib.rs
@@ -19,7 +19,7 @@ use libc::{EINVAL, EIO, ENODEV};
 
 use kvm::{IrqRoute, IrqSource, Vm};
 use msg_socket::{MsgOnSocket, MsgReceiver, MsgResult, MsgSender, MsgSocket};
-use resources::{Alloc, GpuMemoryDesc, SystemAllocator};
+use resources::{Alloc, GpuMemoryDesc, MmioType, SystemAllocator};
 use sys_util::{error, Error as SysError, EventFd, GuestAddress, MemoryMapping, MmapError, Result};
 
 /// A file descriptor either borrowed or owned by this.
@@ -404,7 +404,7 @@ fn register_memory(
     let addr = match allocation {
         Some((Alloc::PciBar { bus, dev, bar }, address)) => {
             match allocator
-                .device_allocator()
+                .mmio_allocator(MmioType::Device)
                 .get(&Alloc::PciBar { bus, dev, bar })
             {
                 Some((start_addr, length, _)) => {
@@ -420,7 +420,7 @@ fn register_memory(
         }
         None => {
             let alloc = allocator.get_anon_alloc();
-            match allocator.device_allocator().allocate(
+            match allocator.mmio_allocator(MmioType::Device).allocate(
                 size as u64,
                 alloc,
                 "vmcontrol_register_memory".to_string(),