Skip to content

Commit cd9ee43

Browse files
committed
make map_range_with_table_flags and map_range unsafe
1 parent 9f58301 commit cd9ee43

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
@@ -374,10 +374,15 @@ pub trait Mapper<S: PageSize> {
374374

375375
/// Maps frames from the allocator to the given range of virtual pages.
376376
///
377+
/// ## Safety
378+
///
379+
/// This function invokes [`Mapper::map_to_with_table_flags`] internally, so
380+
/// all safety requirements of it also apply for this function.
381+
///
377382
/// ## Errors
378383
///
379384
/// If an error occurs half-way through a [`MapperFlushRange<S>`] is returned that contains the frames that were successfully mapped.
380-
fn map_range_with_table_flags<A>(
385+
unsafe fn map_range_with_table_flags<A>(
381386
&mut self,
382387
mut pages: PageRange<S>,
383388
flags: PageTableFlags,
@@ -421,11 +426,16 @@ pub trait Mapper<S: PageSize> {
421426

422427
/// Maps frames from the allocator to the given range of virtual pages.
423428
///
429+
/// ## Safety
430+
///
431+
/// This function invokes [`Mapper::map_to_with_table_flags`] internally, so
432+
/// all safety requirements of it also apply for this function.
433+
///
424434
/// ## Errors
425435
///
426436
/// If an error occurs half-way through a [`MapperFlushRange<S>`] is returned that contains the frames that were successfully mapped.
427437
#[inline]
428-
fn map_range<A>(
438+
unsafe fn map_range<A>(
429439
&mut self,
430440
pages: PageRange<S>,
431441
flags: PageTableFlags,

src/structures/paging/mapper/offset_page_table.rs

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

100100
#[inline]
101-
fn map_range_with_table_flags<A>(
101+
unsafe fn map_range_with_table_flags<A>(
102102
&mut self,
103103
pages: PageRange<Size1GiB>,
104104
flags: PageTableFlags,
@@ -215,7 +215,7 @@ impl<'a> Mapper<Size2MiB> for OffsetPageTable<'a> {
215215
}
216216

217217
#[inline]
218-
fn map_range_with_table_flags<A>(
218+
unsafe fn map_range_with_table_flags<A>(
219219
&mut self,
220220
pages: PageRange<Size2MiB>,
221221
flags: PageTableFlags,
@@ -332,7 +332,7 @@ impl<'a> Mapper<Size4KiB> for OffsetPageTable<'a> {
332332
}
333333

334334
#[inline]
335-
fn map_range_with_table_flags<A>(
335+
unsafe fn map_range_with_table_flags<A>(
336336
&mut self,
337337
pages: PageRange<Size4KiB>,
338338
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)