Use statically typed callback function in modify_range
All users of walk_range and modify_range pass compile time constant
references to callback functions, and so using a dynamic function type
PteUpdater is unnecessary, and may result in pointless overhead or
complexity, given that dynamic function calls are dispatched via vtables
rather than directly.
So use a bound on the generic function type F instead.
Test: build tested only
Change-Id: Ic7550bce24c7992b9ddc35c7b9bae8163fe9d511
diff --git a/vmbase/src/memory/page_table.rs b/vmbase/src/memory/page_table.rs
index 060d2d8..dab801a 100644
--- a/vmbase/src/memory/page_table.rs
+++ b/vmbase/src/memory/page_table.rs
@@ -16,7 +16,7 @@
use crate::read_sysreg;
use aarch64_paging::idmap::IdMap;
-use aarch64_paging::paging::{Attributes, Descriptor, MemoryRegion, PteUpdater};
+use aarch64_paging::paging::{Attributes, Descriptor, MemoryRegion};
use aarch64_paging::MapError;
use core::result;
@@ -124,7 +124,10 @@
/// Applies the provided updater function to a number of PTEs corresponding to a given memory
/// range.
- pub fn modify_range(&mut self, range: &MemoryRegion, f: &PteUpdater) -> Result<()> {
+ pub fn modify_range<F>(&mut self, range: &MemoryRegion, f: &F) -> Result<()>
+ where
+ F: Fn(&MemoryRegion, &mut Descriptor, usize) -> result::Result<(), ()>,
+ {
self.idmap.modify_range(range, f)
}