diff --git a/src/structures/paging/mapper/mapped_page_table.rs b/src/structures/paging/mapper/mapped_page_table.rs index 4e706fa83..9a0486ec7 100644 --- a/src/structures/paging/mapper/mapped_page_table.rs +++ b/src/structures/paging/mapper/mapped_page_table.rs @@ -161,7 +161,7 @@ impl<'a, P: PhysToVirt> Mapper for MappedPageTable<'a, P> { Ok((frame, MapperFlush::new(page))) } - fn update_flags( + unsafe fn update_flags( &mut self, page: Page, flags: PageTableFlags, @@ -237,7 +237,7 @@ impl<'a, P: PhysToVirt> Mapper for MappedPageTable<'a, P> { Ok((frame, MapperFlush::new(page))) } - fn update_flags( + unsafe fn update_flags( &mut self, page: Page, flags: PageTableFlags, @@ -315,7 +315,7 @@ impl<'a, P: PhysToVirt> Mapper for MappedPageTable<'a, P> { Ok((frame, MapperFlush::new(page))) } - fn update_flags( + unsafe fn update_flags( &mut self, page: Page, flags: PageTableFlags, diff --git a/src/structures/paging/mapper/mod.rs b/src/structures/paging/mapper/mod.rs index 01c15cb36..85b6ac856 100644 --- a/src/structures/paging/mapper/mod.rs +++ b/src/structures/paging/mapper/mod.rs @@ -128,7 +128,15 @@ pub trait Mapper { fn unmap(&mut self, page: Page) -> Result<(PhysFrame, MapperFlush), UnmapError>; /// Updates the flags of an existing mapping. - fn update_flags( + /// + /// ## Safety + /// + /// This method is unsafe because changing the flags of a mapping + /// might result in undefined behavior. For example, setting the + /// `GLOBAL` and `MUTABLE` flags for a page might result in the corruption + /// of values stored in that page from processes running in other address + /// spaces. + unsafe fn update_flags( &mut self, page: Page, flags: PageTableFlags, diff --git a/src/structures/paging/mapper/offset_page_table.rs b/src/structures/paging/mapper/offset_page_table.rs index a646c93c1..23e4da4d2 100644 --- a/src/structures/paging/mapper/offset_page_table.rs +++ b/src/structures/paging/mapper/offset_page_table.rs @@ -75,7 +75,7 @@ impl<'a> Mapper for OffsetPageTable<'a> { } #[inline] - fn update_flags( + unsafe fn update_flags( &mut self, page: Page, flags: PageTableFlags, @@ -113,7 +113,7 @@ impl<'a> Mapper for OffsetPageTable<'a> { } #[inline] - fn update_flags( + unsafe fn update_flags( &mut self, page: Page, flags: PageTableFlags, @@ -151,7 +151,7 @@ impl<'a> Mapper for OffsetPageTable<'a> { } #[inline] - fn update_flags( + unsafe fn update_flags( &mut self, page: Page, flags: PageTableFlags, diff --git a/src/structures/paging/mapper/recursive_page_table.rs b/src/structures/paging/mapper/recursive_page_table.rs index 7c1c7f37f..53901031c 100644 --- a/src/structures/paging/mapper/recursive_page_table.rs +++ b/src/structures/paging/mapper/recursive_page_table.rs @@ -267,7 +267,9 @@ impl<'a> Mapper for RecursivePageTable<'a> { Ok((frame, MapperFlush::new(page))) } - fn update_flags( + // allow unused_unsafe until https://github.com/rust-lang/rust/pull/69245 lands + #[allow(unused_unsafe)] + unsafe fn update_flags( &mut self, page: Page, flags: PageTableFlags, @@ -359,7 +361,9 @@ impl<'a> Mapper for RecursivePageTable<'a> { Ok((frame, MapperFlush::new(page))) } - fn update_flags( + // allow unused_unsafe until https://github.com/rust-lang/rust/pull/69245 lands + #[allow(unused_unsafe)] + unsafe fn update_flags( &mut self, page: Page, flags: PageTableFlags, @@ -465,7 +469,9 @@ impl<'a> Mapper for RecursivePageTable<'a> { Ok((frame, MapperFlush::new(page))) } - fn update_flags( + // allow unused_unsafe until https://github.com/rust-lang/rust/pull/69245 lands + #[allow(unused_unsafe)] + unsafe fn update_flags( &mut self, page: Page, flags: PageTableFlags,