summary refs log tree commit diff
path: root/arch
diff options
context:
space:
mode:
authorDaniel Prilik <prilik@google.com>2019-03-26 14:28:19 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-04-20 03:58:40 -0700
commitd92f81a249cdeacdd1b37574b479d35c09dc5e55 (patch)
tree87795f27b432f2c9b8d8d65bdb8db57e2c09a658 /arch
parentcfb6f70d1c3038ab3db3d92dce8016351b2d257c (diff)
downloadcrosvm-d92f81a249cdeacdd1b37574b479d35c09dc5e55.tar
crosvm-d92f81a249cdeacdd1b37574b479d35c09dc5e55.tar.gz
crosvm-d92f81a249cdeacdd1b37574b479d35c09dc5e55.tar.bz2
crosvm-d92f81a249cdeacdd1b37574b479d35c09dc5e55.tar.lz
crosvm-d92f81a249cdeacdd1b37574b479d35c09dc5e55.tar.xz
crosvm-d92f81a249cdeacdd1b37574b479d35c09dc5e55.tar.zst
crosvm-d92f81a249cdeacdd1b37574b479d35c09dc5e55.zip
resources+pci: allocator rework (allocation tags)
AddressAllocator now maintains a HashMap<Alloc, (u64, u64, u64)>,
which uniquely maps a Allocation enum (e.g: PciBar(bus, dev, bar),
GpuRenderNode, etc...) to it's address, size, and human-readable tag
/ description.

The interface has also been modified to use Error instead of Option.

Aside from improving debugging, tracking allocations will have
numerous uses in the future. For example, when allocating guest memory
over VmControl sockets, it will be possible to restrict allocations to
pre-allocated slices of memory owned by the requesting device.

To plumb through PCI information to PCI devices, this CL necessitated
the addition of a PciDevice method called `assign_bus_dev`, which
notifies PCI devices of their uniquely assigned Bus and Device numbers.

BUG=chromium:936567
TEST=cargo test -p resources && cargo build --features="gpu gpu-forward"

Change-Id: I8b4b0e32c6f3168138739249ede53d03143ee5c3
Reviewed-on: https://chromium-review.googlesource.com/1536207
Commit-Ready: Daniel Prilik <prilik@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/src/lib.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/arch/src/lib.rs b/arch/src/lib.rs
index 01c16a0..032170f 100644
--- a/arch/src/lib.rs
+++ b/arch/src/lib.rs
@@ -146,6 +146,9 @@ pub fn generate_pci_root(
     let mut pci_irqs = Vec::new();
     let mut pid_labels = BTreeMap::new();
     for (dev_idx, (mut device, jail)) in devices.into_iter().enumerate() {
+        // Only support one bus.
+        device.assign_bus_dev(0, dev_idx as u8);
+
         let mut keep_fds = device.keep_fds();
         syslog::push_fds(&mut keep_fds);