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 <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf 2019-07-24 22:00:29 -07:00 committed by Rob Bradford
parent e18052120a
commit 2f802880c0

View File

@ -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)