mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-03 11:25:20 +00:00
vfio: pci: Mask multi function device bit
In order to support VFIO for devices supporting multiple functions, we need to mask the multi-function bit (bit 7 from Header Type byte). Otherwise, the guest kernel ends up tryng to enumerate those devices. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
b6ae2ccda4
commit
347f8a036b
@ -694,8 +694,6 @@ impl BusDevice for VfioPciDevice {
|
|||||||
|
|
||||||
// First BAR offset in the PCI config space.
|
// First BAR offset in the PCI config space.
|
||||||
const PCI_CONFIG_BAR_OFFSET: u32 = 0x10;
|
const PCI_CONFIG_BAR_OFFSET: u32 = 0x10;
|
||||||
// First BAR register index
|
|
||||||
const PCI_CONFIG_BAR0_INDEX: usize = 4;
|
|
||||||
// Capability register offset in the PCI config space.
|
// Capability register offset in the PCI config space.
|
||||||
const PCI_CONFIG_CAPABILITY_OFFSET: u32 = 0x34;
|
const PCI_CONFIG_CAPABILITY_OFFSET: u32 = 0x34;
|
||||||
// IO BAR when first BAR bit is 1.
|
// IO BAR when first BAR bit is 1.
|
||||||
@ -708,6 +706,10 @@ const PCI_CONFIG_MEMORY_BAR_64BIT: u32 = 0x4;
|
|||||||
const PCI_CONFIG_REGISTER_SIZE: usize = 4;
|
const PCI_CONFIG_REGISTER_SIZE: usize = 4;
|
||||||
// Number of BARs for a PCI device
|
// Number of BARs for a PCI device
|
||||||
const BAR_NUMS: usize = 6;
|
const BAR_NUMS: usize = 6;
|
||||||
|
// PCI Header Type register index
|
||||||
|
const PCI_HEADER_TYPE_REG_INDEX: usize = 3;
|
||||||
|
// First BAR register index
|
||||||
|
const PCI_CONFIG_BAR0_INDEX: usize = 4;
|
||||||
// PCI ROM expansion BAR register index
|
// PCI ROM expansion BAR register index
|
||||||
const PCI_ROM_EXP_BAR_INDEX: usize = 12;
|
const PCI_ROM_EXP_BAR_INDEX: usize = 12;
|
||||||
// PCI interrupt pin and line register index
|
// PCI interrupt pin and line register index
|
||||||
@ -915,8 +917,14 @@ impl PciDevice for VfioPciDevice {
|
|||||||
// mask in case the register being read correspond to the interrupt
|
// mask in case the register being read correspond to the interrupt
|
||||||
// register, this code makes sure to always expose an Interrupt Pin
|
// register, this code makes sure to always expose an Interrupt Pin
|
||||||
// value of 0, which stands for no interrupt pin support.
|
// value of 0, which stands for no interrupt pin support.
|
||||||
|
//
|
||||||
|
// Since we don't support passing multi-functions devices, we should
|
||||||
|
// mask the multi-function bit, bit 7 of the Header Type byte on the
|
||||||
|
// register 3.
|
||||||
let mask = if reg_idx == PCI_INTX_REG_INDEX {
|
let mask = if reg_idx == PCI_INTX_REG_INDEX {
|
||||||
0xffff_00ff
|
0xffff_00ff
|
||||||
|
} else if reg_idx == PCI_HEADER_TYPE_REG_INDEX {
|
||||||
|
0xff7f_ffff
|
||||||
} else {
|
} else {
|
||||||
0xffff_ffff
|
0xffff_ffff
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user