From e37ec26ccf229bc527b26c127fc69063c7d84c82 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Tue, 22 Nov 2022 16:13:52 +0000 Subject: [PATCH] vmm: Remove PCI PIO optimisation This optimisation provided some peformance improvement when measured by perf however when considered in terms of boot time peformance this optimisation doesn't have any impact measurable using our peformance-metrics tooling. Removing this optimisation helps simplify the VMM internals as it allows the reordering of the VM creation process permitting refactoring of the restore code path. Signed-off-by: Rob Bradford --- vmm/src/device_manager.rs | 8 -------- vmm/src/vm.rs | 31 ------------------------------- 2 files changed, 39 deletions(-) diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index abb207c8d..818fdcbf5 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -54,8 +54,6 @@ use libc::{ cfmakeraw, isatty, tcgetattr, tcsetattr, termios, MAP_NORESERVE, MAP_PRIVATE, MAP_SHARED, O_TMPFILE, PROT_READ, PROT_WRITE, TCSANOW, }; -#[cfg(target_arch = "x86_64")] -use pci::PciConfigIo; use pci::{ DeviceRelocation, PciBarRegionType, PciBdf, PciDevice, VfioPciDevice, VfioUserDmaMapping, VfioUserPciDevice, VfioUserPciDeviceError, @@ -3564,12 +3562,6 @@ impl DeviceManager { .map(|ic| ic.clone() as Arc>) } - #[cfg(target_arch = "x86_64")] - // Used to provide a fast path for handling PIO exits - pub fn pci_config_io(&self) -> Arc> { - Arc::clone(self.pci_segments[0].pci_config_io.as_ref().unwrap()) - } - pub(crate) fn pci_segments(&self) -> &Vec { &self.pci_segments } diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index f4907def1..700c63adf 100644 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -87,8 +87,6 @@ use std::{result, str, thread}; use thiserror::Error; use tracer::trace_scoped; use vm_device::Bus; -#[cfg(target_arch = "x86_64")] -use vm_device::BusDevice; #[cfg(feature = "tdx")] use vm_memory::{Address, ByteValued, GuestMemory, GuestMemoryRegion}; use vm_memory::{Bytes, GuestAddress, GuestAddressSpace, GuestMemoryAtomic}; @@ -365,8 +363,6 @@ struct VmOpsHandler { #[cfg(target_arch = "x86_64")] io_bus: Arc, mmio_bus: Arc, - #[cfg(target_arch = "x86_64")] - pci_config_io: Arc>, } impl VmOps for VmOpsHandler { @@ -408,17 +404,6 @@ impl VmOps for VmOpsHandler { #[cfg(target_arch = "x86_64")] fn pio_read(&self, port: u64, data: &mut [u8]) -> result::Result<(), HypervisorVmError> { - use pci::{PCI_CONFIG_IO_PORT, PCI_CONFIG_IO_PORT_SIZE}; - - if (PCI_CONFIG_IO_PORT..(PCI_CONFIG_IO_PORT + PCI_CONFIG_IO_PORT_SIZE)).contains(&port) { - self.pci_config_io.lock().unwrap().read( - PCI_CONFIG_IO_PORT, - port - PCI_CONFIG_IO_PORT, - data, - ); - return Ok(()); - } - if let Err(vm_device::BusError::MissingAddressRange) = self.io_bus.read(port, data) { info!("Guest PIO read to unregistered address 0x{:x}", port); } @@ -427,17 +412,6 @@ impl VmOps for VmOpsHandler { #[cfg(target_arch = "x86_64")] fn pio_write(&self, port: u64, data: &[u8]) -> result::Result<(), HypervisorVmError> { - use pci::{PCI_CONFIG_IO_PORT, PCI_CONFIG_IO_PORT_SIZE}; - - if (PCI_CONFIG_IO_PORT..(PCI_CONFIG_IO_PORT + PCI_CONFIG_IO_PORT_SIZE)).contains(&port) { - self.pci_config_io.lock().unwrap().write( - PCI_CONFIG_IO_PORT, - port - PCI_CONFIG_IO_PORT, - data, - ); - return Ok(()); - } - match self.io_bus.write(port, data) { Err(vm_device::BusError::MissingAddressRange) => { info!("Guest PIO write to unregistered address 0x{:x}", port); @@ -557,16 +531,11 @@ impl Vm { let io_bus = Arc::clone(device_manager.lock().unwrap().io_bus()); let mmio_bus = Arc::clone(device_manager.lock().unwrap().mmio_bus()); - #[cfg(target_arch = "x86_64")] - let pci_config_io = - device_manager.lock().unwrap().pci_config_io() as Arc>; let vm_ops: Arc = Arc::new(VmOpsHandler { memory, #[cfg(target_arch = "x86_64")] io_bus, mmio_bus, - #[cfg(target_arch = "x86_64")] - pci_config_io, }); let exit_evt_clone = exit_evt.try_clone().map_err(Error::EventFdClone)?;