Skip to content

Commit 740d205

Browse files
committed
make map_range_with_table_flags and map_range unsafe
1 parent 9c30270 commit 740d205

File tree

4 files changed

+21
-11
lines changed

4 files changed

+21
-11
lines changed

src/structures/paging/mapper/mapped_page_table.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ impl<'a, P: PageTableFrameMapping> Mapper<Size1GiB> for MappedPageTable<'a, P> {
598598
}
599599

600600
#[inline]
601-
fn map_range_with_table_flags<A>(
601+
unsafe fn map_range_with_table_flags<A>(
602602
&mut self,
603603
pages: PageRange<Size1GiB>,
604604
flags: PageTableFlags,
@@ -801,7 +801,7 @@ impl<'a, P: PageTableFrameMapping> Mapper<Size2MiB> for MappedPageTable<'a, P> {
801801
}
802802

803803
#[inline]
804-
fn map_range_with_table_flags<A>(
804+
unsafe fn map_range_with_table_flags<A>(
805805
&mut self,
806806
pages: PageRange<Size2MiB>,
807807
flags: PageTableFlags,
@@ -1024,7 +1024,7 @@ impl<'a, P: PageTableFrameMapping> Mapper<Size4KiB> for MappedPageTable<'a, P> {
10241024
}
10251025

10261026
#[inline]
1027-
fn map_range_with_table_flags<A>(
1027+
unsafe fn map_range_with_table_flags<A>(
10281028
&mut self,
10291029
pages: PageRange<Size4KiB>,
10301030
flags: PageTableFlags,

src/structures/paging/mapper/mod.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,10 +380,15 @@ pub trait Mapper<S: PageSize> {
380380

381381
/// Maps frames from the allocator to the given range of virtual pages.
382382
///
383+
/// ## Safety
384+
///
385+
/// This function invokes [`Mapper::map_to_with_table_flags`] internally, so
386+
/// all safety requirements of it also apply for this function.
387+
///
383388
/// ## Errors
384389
///
385390
/// If an error occurs half-way through a [`MapperFlushRange<S>`] is returned that contains the frames that were successfully mapped.
386-
fn map_range_with_table_flags<A>(
391+
unsafe fn map_range_with_table_flags<A>(
387392
&mut self,
388393
mut pages: PageRange<S>,
389394
flags: PageTableFlags,
@@ -427,11 +432,16 @@ pub trait Mapper<S: PageSize> {
427432

428433
/// Maps frames from the allocator to the given range of virtual pages.
429434
///
435+
/// ## Safety
436+
///
437+
/// This function invokes [`Mapper::map_to_with_table_flags`] internally, so
438+
/// all safety requirements of it also apply for this function.
439+
///
430440
/// ## Errors
431441
///
432442
/// If an error occurs half-way through a [`MapperFlushRange<S>`] is returned that contains the frames that were successfully mapped.
433443
#[inline]
434-
fn map_range<A>(
444+
unsafe fn map_range<A>(
435445
&mut self,
436446
pages: PageRange<S>,
437447
flags: PageTableFlags,

src/structures/paging/mapper/offset_page_table.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ impl<'a> Mapper<Size1GiB> for OffsetPageTable<'a> {
102102
}
103103

104104
#[inline]
105-
fn map_range_with_table_flags<A>(
105+
unsafe fn map_range_with_table_flags<A>(
106106
&mut self,
107107
pages: PageRange<Size1GiB>,
108108
flags: PageTableFlags,
@@ -225,7 +225,7 @@ impl<'a> Mapper<Size2MiB> for OffsetPageTable<'a> {
225225
}
226226

227227
#[inline]
228-
fn map_range_with_table_flags<A>(
228+
unsafe fn map_range_with_table_flags<A>(
229229
&mut self,
230230
pages: PageRange<Size2MiB>,
231231
flags: PageTableFlags,
@@ -348,7 +348,7 @@ impl<'a> Mapper<Size4KiB> for OffsetPageTable<'a> {
348348
}
349349

350350
#[inline]
351-
fn map_range_with_table_flags<A>(
351+
unsafe fn map_range_with_table_flags<A>(
352352
&mut self,
353353
pages: PageRange<Size4KiB>,
354354
flags: PageTableFlags,

src/structures/paging/mapper/recursive_page_table.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ impl<'a> Mapper<Size1GiB> for RecursivePageTable<'a> {
767767
}
768768

769769
#[inline]
770-
fn map_range_with_table_flags<A>(
770+
unsafe fn map_range_with_table_flags<A>(
771771
&mut self,
772772
pages: PageRange<Size1GiB>,
773773
flags: PageTableFlags,
@@ -984,7 +984,7 @@ impl<'a> Mapper<Size2MiB> for RecursivePageTable<'a> {
984984
}
985985

986986
#[inline]
987-
fn map_range_with_table_flags<A>(
987+
unsafe fn map_range_with_table_flags<A>(
988988
&mut self,
989989
pages: PageRange<Size2MiB>,
990990
flags: PageTableFlags,
@@ -1236,7 +1236,7 @@ impl<'a> Mapper<Size4KiB> for RecursivePageTable<'a> {
12361236
}
12371237

12381238
#[inline]
1239-
fn map_range_with_table_flags<A>(
1239+
unsafe fn map_range_with_table_flags<A>(
12401240
&mut self,
12411241
pages: PageRange<Size4KiB>,
12421242
flags: PageTableFlags,

0 commit comments

Comments
 (0)