From 3be45af929f3a9f6fc35925936920da36356f6dc Mon Sep 17 00:00:00 2001 From: Xiong Zhang Date: Sun, 24 Apr 2022 22:47:44 +0800 Subject: [PATCH] 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 Tested-by: kokoro Commit-Queue: Daniel Verkamp --- src/linux/mod.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/linux/mod.rs b/src/linux/mod.rs index a243ed649f..554c2f11e6 100644 --- a/src/linux/mod.rs +++ b/src/linux/mod.rs @@ -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>>> = BTreeMap::new(); let mut iova_max_addr: Option = None;