No need to allocate PCI BARs after all.
Apparently crosvm does this for us, so we can save a bunch of code.
Bug: 237249743
Test: Ran vmbase and pVM firmware manually
Test: atest vmbase_example.integration_test
Change-Id: I3efde5ad1af554a8a1c50fb23d6d1d1de082d25d
diff --git a/pvmfw/src/main.rs b/pvmfw/src/main.rs
index 2f1b42a..9c5fb60 100644
--- a/pvmfw/src/main.rs
+++ b/pvmfw/src/main.rs
@@ -37,7 +37,7 @@
avb::PUBLIC_KEY,
entry::RebootReason,
memory::MemoryTracker,
- pci::{allocate_all_virtio_bars, PciError, PciInfo, PciMemory32Allocator},
+ pci::{find_virtio_devices, PciError, PciInfo},
};
use ::avb::verify_image;
use dice::bcc;
@@ -65,12 +65,10 @@
let pci_info = PciInfo::from_fdt(fdt).map_err(handle_pci_error)?;
debug!("PCI: {:#x?}", pci_info);
pci_info.map(memory)?;
- let mut bar_allocator = PciMemory32Allocator::new(&pci_info);
- debug!("Allocator: {:#x?}", bar_allocator);
// Safety: This is the only place where we call make_pci_root, and this main function is only
// called once.
let mut pci_root = unsafe { pci_info.make_pci_root() };
- allocate_all_virtio_bars(&mut pci_root, &mut bar_allocator).map_err(handle_pci_error)?;
+ find_virtio_devices(&mut pci_root).map_err(handle_pci_error)?;
verify_image(signed_kernel, PUBLIC_KEY).map_err(|e| {
error!("Failed to verify the payload: {e}");
@@ -95,8 +93,5 @@
| PciError::FdtMissingRanges
| PciError::RangeAddressMismatch { .. }
| PciError::NoSuitableRange => RebootReason::InvalidFdt,
- PciError::BarInfoFailed(_)
- | PciError::BarAllocationFailed { .. }
- | PciError::UnsupportedBarType(_) => RebootReason::PciError,
}
}