pci: vfio: Don't assume MSI-X is enabled

The fixup_msix_region() function added in
a718716831
made the assumption that MSI-X was always available. This is the case
with many VFIO devices and all our virtio devices but created regression
with MSI devices.

Simply return the existing region size if MSI-X is not supported by the
device.

Fixes: #5649

Signed-off-by: Rob Bradford <rbradford@rivosinc.com>
This commit is contained in:
Rob Bradford 2023-08-05 09:33:24 +01:00 committed by Rob Bradford
parent a00d29867c
commit 363b478040

View File

@ -505,7 +505,7 @@ impl VfioCommon {
/// In case msix table offset is not page size aligned, we need do some fixup to achive it. /// In case msix table offset is not page size aligned, we need do some fixup to achive it.
/// Becuse we don't want the MMIO RW region and trap region overlap each other. /// Becuse we don't want the MMIO RW region and trap region overlap each other.
fn fixup_msix_region(&mut self, bar_id: u32, region_size: u64) -> u64 { fn fixup_msix_region(&mut self, bar_id: u32, region_size: u64) -> u64 {
let msix = self.interrupt.msix.as_mut().unwrap(); if let Some(msix) = self.interrupt.msix.as_mut() {
let msix_cap = &mut msix.cap; let msix_cap = &mut msix.cap;
// Suppose table_bir equals to pba_bir here. Am I right? // Suppose table_bir equals to pba_bir here. Am I right?
@ -523,6 +523,10 @@ impl VfioCommon {
msix_cap.pba_set_offset((size / 2 + pba_offset - table_offset) as u32); msix_cap.pba_set_offset((size / 2 + pba_offset - table_offset) as u32);
size size
} else {
// MSI-X not supported for this device
region_size
}
} }
pub(crate) fn allocate_bars( pub(crate) fn allocate_bars(