diff --git a/kernel/src/vm/vmar/dyn_cap.rs b/kernel/src/vm/vmar/dyn_cap.rs index 7cc6a8150..e6c98ee2d 100644 --- a/kernel/src/vm/vmar/dyn_cap.rs +++ b/kernel/src/vm/vmar/dyn_cap.rs @@ -58,8 +58,7 @@ impl Vmar { /// which ensures that any updated memory permissions do not go beyond /// the access rights of the underlying VMOs. pub fn new_map(&self, size: usize, perms: VmPerms) -> Result> { - let dup_self = self.dup()?; - Ok(VmarMapOptions::new(dup_self, size, perms)) + Ok(VmarMapOptions::new(self, size, perms)) } /// Changes the permissions of the memory mappings in the specified range. diff --git a/kernel/src/vm/vmar/mod.rs b/kernel/src/vm/vmar/mod.rs index ed033811a..af23e8bd2 100644 --- a/kernel/src/vm/vmar/mod.rs +++ b/kernel/src/vm/vmar/mod.rs @@ -480,8 +480,8 @@ impl Vmar { /// Options for creating a new mapping. The mapping is not allowed to overlap /// with any child VMARs. And unless specified otherwise, it is not allowed /// to overlap with any existing mapping, either. -pub struct VmarMapOptions { - parent: Vmar, +pub struct VmarMapOptions<'a, R1, R2> { + parent: &'a Vmar, vmo: Option>, perms: VmPerms, vmo_offset: usize, @@ -496,14 +496,14 @@ pub struct VmarMapOptions { handle_page_faults_around: bool, } -impl VmarMapOptions { +impl<'a, R1, R2> VmarMapOptions<'a, R1, R2> { /// Creates a default set of options with the VMO and the memory access /// permissions. /// /// The VMO must have access rights that correspond to the memory /// access permissions. For example, if `perms` contains `VmPerms::Write`, /// then `vmo.rights()` should contain `Rights::WRITE`. - pub fn new(parent: Vmar, size: usize, perms: VmPerms) -> Self { + pub fn new(parent: &'a Vmar, size: usize, perms: VmPerms) -> Self { Self { parent, vmo: None, diff --git a/kernel/src/vm/vmar/static_cap.rs b/kernel/src/vm/vmar/static_cap.rs index 5f273cc71..ba905f3a8 100644 --- a/kernel/src/vm/vmar/static_cap.rs +++ b/kernel/src/vm/vmar/static_cap.rs @@ -68,8 +68,7 @@ impl Vmar> { size: usize, perms: VmPerms, ) -> Result, Rights>> { - let dup_self = self.dup()?; - Ok(VmarMapOptions::new(dup_self, size, perms)) + Ok(VmarMapOptions::new(self, size, perms)) } /// Change the permissions of the memory mappings in the specified range.