From b3388c343d43dbe45084c7e05ef2e8a172421ee8 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Tue, 5 Nov 2019 09:37:34 +0000 Subject: [PATCH] vmm: device_manager: Ensure I/O ports are allocated Ensure that we tell the allocator about all the I/O ports that we are using for I/O bus attached devices (serial, i8042, ACPI device.) Signed-off-by: Rob Bradford --- vmm/src/device_manager.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index 3b261ae74..b24222481 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -166,6 +166,9 @@ pub enum DeviceManagerError { /// Cannot add legacy device to Bus. BusError(devices::BusError), + + /// Failed to allocate IO port + AllocateIOPort, } pub type DeviceManagerResult = result::Result; @@ -457,6 +460,10 @@ impl DeviceManager { serial_writer, ))); + allocator + .allocate_io_addresses(Some(GuestAddress(0x3f8)), 0x8, None) + .ok_or(DeviceManagerError::AllocateIOPort)?; + io_bus .insert(serial.clone(), 0x3f8, 0x8) .map_err(DeviceManagerError::BusError)?; @@ -470,6 +477,11 @@ impl DeviceManager { let i8042 = Arc::new(Mutex::new(devices::legacy::I8042Device::new( reset_evt.try_clone().map_err(DeviceManagerError::EventFd)?, ))); + + allocator + .allocate_io_addresses(Some(GuestAddress(0x61)), 0x4, None) + .ok_or(DeviceManagerError::AllocateIOPort)?; + io_bus .insert(i8042.clone(), 0x61, 0x4) .map_err(DeviceManagerError::BusError)?; @@ -494,6 +506,11 @@ impl DeviceManager { _exit_evt.try_clone().map_err(DeviceManagerError::EventFd)?, reset_evt.try_clone().map_err(DeviceManagerError::EventFd)?, ))); + + allocator + .allocate_io_addresses(Some(GuestAddress(0x3c0)), 0x4, None) + .ok_or(DeviceManagerError::AllocateIOPort)?; + io_bus .insert(acpi_device.clone(), 0x3c0, 0x4) .map_err(DeviceManagerError::BusError)?;