From 2f802880c0dd4835283d4d3eee1a804b3dbb04be Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Wed, 24 Jul 2019 22:00:29 -0700 Subject: [PATCH] vfio: Disable the ROM expansion BAR Until the codebase can properly expose the ROM BAR into the guest, it is better to disable it for now, returning always 0 when the register is being read. Signed-off-by: Sebastien Boeuf --- vfio/src/vfio_pci.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/vfio/src/vfio_pci.rs b/vfio/src/vfio_pci.rs index 86e9a4c35..d6c2793c0 100644 --- a/vfio/src/vfio_pci.rs +++ b/vfio/src/vfio_pci.rs @@ -706,6 +706,8 @@ const PCI_CONFIG_MEMORY_BAR_64BIT: u32 = 0x4; const PCI_CONFIG_REGISTER_SIZE: usize = 4; // Number of BARs for a PCI device const BAR_NUMS: usize = 6; +// PCI ROM expansion BAR register index +const PCI_ROM_EXP_BAR_INDEX: usize = 12; impl PciDevice for VfioPciDevice { fn allocate_bars( @@ -896,6 +898,12 @@ impl PciDevice for VfioPciDevice { return self.configuration.read_reg(reg_idx); } + // Since the ROM expansion BAR is not yet handled by the code, it is + // more proper to expose it to the guest as being disabled. + if reg_idx == PCI_ROM_EXP_BAR_INDEX { + return 0; + } + // The config register read comes from the VFIO device itself. self.vfio_pci_configuration .read_config_dword((reg_idx * 4) as u32)