vmbase: Support 16KiB MMIO_GUARD granule
Now that the MMIO_GUARD sharing/unsharing is decoupled from the page
tables, add support for 16KiB (and possibly beyond) by getting rid of
the hard-coded assumption that MMIO_GUARD happens with 4KiB granularity
by expecting potentially more than one page fault per MMIO_GUARD region
with MMIO lazy mapping.
Address the special case of the UART separately (see comment there).
Remove the now-obsolete hard-coded MMIO_GUARD_GRANULE_SIZE.
Bug: 336563593
Test: m libpvmfw libvmbase_example librialto
Change-Id: I5d8e169d9c2ad022208de3d33f346f5034d13393
diff --git a/vmbase/src/memory/shared.rs b/vmbase/src/memory/shared.rs
index 457e6f2..5a25d9f 100644
--- a/vmbase/src/memory/shared.rs
+++ b/vmbase/src/memory/shared.rs
@@ -21,7 +21,7 @@
use crate::console;
use crate::dsb;
use crate::exceptions::HandleExceptionError;
-use crate::hyp::{self, get_mem_sharer, get_mmio_guard, MMIO_GUARD_GRANULE_SIZE};
+use crate::hyp::{self, get_mem_sharer, get_mmio_guard};
use crate::util::unchecked_align_down;
use crate::util::RangeExt as _;
use aarch64_paging::paging::{
@@ -42,7 +42,6 @@
use log::{debug, error, trace};
use once_cell::race::OnceBox;
use spin::mutex::SpinMutex;
-use static_assertions::const_assert_eq;
use tinyvec::ArrayVec;
/// A global static variable representing the system memory tracker, protected by a spin mutex.
@@ -397,12 +396,11 @@
}
fn get_granule() -> Result<usize> {
- const_assert_eq!(MMIO_GUARD_GRANULE_SIZE, PAGE_SIZE); // For good measure.
let Some(mmio_guard) = get_mmio_guard() else {
return Ok(PAGE_SIZE);
};
match mmio_guard.granule()? {
- MMIO_GUARD_GRANULE_SIZE => Ok(MMIO_GUARD_GRANULE_SIZE),
+ granule if granule % PAGE_SIZE == 0 => Ok(granule), // For good measure.
granule => Err(MemoryTrackerError::UnsupportedMmioGuardGranule(granule)),
}
}