From 87a3b44d9e6caa82ab521a5dd9bafdb56e8b6ed1 Mon Sep 17 00:00:00 2001 From: Xiong Zhang Date: Tue, 29 Oct 2019 17:32:44 +0800 Subject: 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 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1895233 Tested-by: kokoro Reviewed-by: Zach Reizner Reviewed-by: Daniel Verkamp --- vm_control/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'vm_control/src') 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(), -- cgit 1.4.1