Skip to content

Commit 7a00802

Browse files
committed
make map_range_with_table_flags and map_range unsafe
1 parent c1f380e commit 7a00802

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

373373
/// Maps frames from the allocator to the given range of virtual pages.
374374
///
375+
/// ## Safety
376+
///
377+
/// This function invokes [`Mapper::map_to_with_table_flags`] internally, so
378+
/// all safety requirements of it also apply for this function.
379+
///
375380
/// ## Errors
376381
///
377382
/// If an error occurs half-way through a [`MapperFlushRange<S>`] is returned that contains the frames that were successfully mapped.
378-
fn map_range_with_table_flags<A>(
383+
unsafe fn map_range_with_table_flags<A>(
379384
&mut self,
380385
mut pages: PageRange<S>,
381386
flags: PageTableFlags,
@@ -419,11 +424,16 @@ pub trait Mapper<S: PageSize> {
419424

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

src/structures/paging/mapper/offset_page_table.rs

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

9999
#[inline]
100-
fn map_range_with_table_flags<A>(
100+
unsafe fn map_range_with_table_flags<A>(
101101
&mut self,
102102
pages: PageRange<Size1GiB>,
103103
flags: PageTableFlags,
@@ -214,7 +214,7 @@ impl<'a> Mapper<Size2MiB> for OffsetPageTable<'a> {
214214
}
215215

216216
#[inline]
217-
fn map_range_with_table_flags<A>(
217+
unsafe fn map_range_with_table_flags<A>(
218218
&mut self,
219219
pages: PageRange<Size2MiB>,
220220
flags: PageTableFlags,
@@ -331,7 +331,7 @@ impl<'a> Mapper<Size4KiB> for OffsetPageTable<'a> {
331331
}
332332

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