linux: Reserve direct mmio in mmio allocator

Direct mmio range couldn't be assigned to any device, so this commit
exclude them from mmio allocator before build_vm().

BUG=None
TEST=tools/presubimt and boot manatee

Change-Id: I71414de1d44545e2c490ce75f5ced5545752858f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3605163
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
Xiong Zhang 2022-04-24 22:47:44 +08:00 committed by Chromeos LUCI
parent 496bcbe8bf
commit 3be45af929

View file

@ -1310,6 +1310,22 @@ where
irqs.push(direct_irq);
}
// Reserve direct mmio range in advance.
#[cfg(feature = "direct")]
if let Some(mmio) = &cfg.direct_mmio {
for range in mmio.ranges.iter() {
sys_allocator
.reserve_mmio(range.base, range.len)
.with_context(|| {
format!(
"failed to reserved direct mmio: {:x}-{:x}",
range.base,
range.base + range.len - 1,
)
})?;
}
};
let mut iommu_attached_endpoints: BTreeMap<u32, Arc<Mutex<Box<dyn MemoryMapperTrait>>>> =
BTreeMap::new();
let mut iova_max_addr: Option<u64> = None;