From cf68f03ab65fd07fa40db891e7698acf7fc51e53 Mon Sep 17 00:00:00 2001 From: Henry Wang Date: Tue, 18 Jan 2022 06:20:26 -0500 Subject: [PATCH] pci: vfio: Skip IOBAR allocation on AArch64 AArch64 does not use IOBAR, and current code of panics the whole VMM if we need to allocate the IOBAR. This commit checks if IOBAR is enabled before the arch conditional code of IOBAR allocation and if the IOBAR is not enabled, we can just skip the IOBAR allocation and do nothing. Fixes: https://github.com/cloud-hypervisor/cloud-hypervisor/issues/3479 Signed-off-by: Henry Wang --- pci/src/vfio.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pci/src/vfio.rs b/pci/src/vfio.rs index 8b11b045b..7f942ba10 100644 --- a/pci/src/vfio.rs +++ b/pci/src/vfio.rs @@ -411,20 +411,20 @@ impl VfioCommon { let mut lower = vfio_wrapper.read_config_dword(bar_offset); if io_bar { + // Mask flag bits (lowest 2 for I/O bars) + lower &= !0b11; + + // BAR is not enabled + if lower == 0 { + bar_id += 1; + continue; + } + #[cfg(target_arch = "x86_64")] { // IO BAR region_type = PciBarRegionType::IoRegion; - // Mask flag bits (lowest 2 for I/O bars) - lower &= !0b11; - - // BAR is not enabled - if lower == 0 { - bar_id += 1; - continue; - } - // Invert bits and add 1 to calculate size region_size = (!lower + 1) as u64;