Skip to content

Commit 6995024

Browse files
committed
add experimental feature flag
1 parent 3fc7687 commit 6995024

File tree

5 files changed

+67
-4
lines changed

5 files changed

+67
-4
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ nightly = [ "const_fn", "step_trait", "abi_x86_interrupt", "doc_cfg" ]
3939
abi_x86_interrupt = []
4040
const_fn = []
4141
step_trait = []
42+
experimental = []
4243
doc_cfg = []
4344

4445
# These features are no longer used and only there for backwards compatibility.

src/structures/paging/mapper/mapped_page_table.rs

+22-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
#[cfg(feature = "experimental")]
2+
use crate::structures::paging::PageTableIndex;
13
use crate::structures::paging::{
24
frame::PhysFrame,
35
frame_alloc::{FrameAllocator, FrameDeallocator},
46
mapper::*,
57
page::{AddressNotAligned, Page, PageRangeInclusive, Size1GiB, Size2MiB, Size4KiB},
68
page_table::{FrameError, PageTable, PageTableEntry, PageTableFlags, PageTableLevel},
7-
PageTableIndex,
89
};
910

1011
/// A Mapper implementation that relies on a PhysAddr to VirtAddr conversion function.
@@ -142,6 +143,7 @@ impl<'a, P: PageTableFrameMapping> MappedPageTable<'a, P> {
142143
Ok(MapperFlush::new(page))
143144
}
144145

146+
#[cfg(feature = "experimental")]
145147
#[inline]
146148
fn next_table_fn_create_next_table<'b, A>(
147149
(flags, allocator): &mut (PageTableFlags, &mut A),
@@ -156,6 +158,7 @@ impl<'a, P: PageTableFrameMapping> MappedPageTable<'a, P> {
156158
.map_err(Into::into)
157159
}
158160

161+
#[cfg(feature = "experimental")]
159162
#[inline]
160163
fn next_table_fn_next_table_mut<'b, T>(
161164
_: &mut T,
@@ -165,6 +168,7 @@ impl<'a, P: PageTableFrameMapping> MappedPageTable<'a, P> {
165168
walker.next_table_mut(entry)
166169
}
167170

171+
#[cfg(feature = "experimental")]
168172
fn modify_range_1gib<ModifyFn, ModifyInfo, Err, NextTableFn, NextTableFnErr>(
169173
&mut self,
170174
pages: PageRange<Size1GiB>,
@@ -230,6 +234,7 @@ impl<'a, P: PageTableFrameMapping> MappedPageTable<'a, P> {
230234
})
231235
}
232236

237+
#[cfg(feature = "experimental")]
233238
#[inline]
234239
fn map_to_range_1gib<F, A>(
235240
&mut self,
@@ -258,6 +263,7 @@ impl<'a, P: PageTableFrameMapping> MappedPageTable<'a, P> {
258263
)
259264
}
260265

266+
#[cfg(feature = "experimental")]
261267
fn modify_range_2mib<ModifyFn, ModifyInfo, Err, NextTableFn, NextTableFnErr>(
262268
&mut self,
263269
pages: PageRange<Size2MiB>,
@@ -360,6 +366,7 @@ impl<'a, P: PageTableFrameMapping> MappedPageTable<'a, P> {
360366
})
361367
}
362368

369+
#[cfg(feature = "experimental")]
363370
#[inline]
364371
fn map_to_range_2mib<F, A>(
365372
&mut self,
@@ -388,6 +395,7 @@ impl<'a, P: PageTableFrameMapping> MappedPageTable<'a, P> {
388395
)
389396
}
390397

398+
#[cfg(feature = "experimental")]
391399
fn modify_range_4kib<ModifyFn, ModifyInfo, Err, NextTableFn, NextTableFnErr>(
392400
&mut self,
393401
pages: PageRange<Size4KiB>,
@@ -526,6 +534,7 @@ impl<'a, P: PageTableFrameMapping> MappedPageTable<'a, P> {
526534
})
527535
}
528536

537+
#[cfg(feature = "experimental")]
529538
#[inline]
530539
fn map_to_range_4kib<F, A>(
531540
&mut self,
@@ -571,6 +580,7 @@ impl<'a, P: PageTableFrameMapping> Mapper<Size1GiB> for MappedPageTable<'a, P> {
571580
self.map_to_1gib(page, frame, flags, parent_table_flags, allocator)
572581
}
573582

583+
#[cfg(feature = "experimental")]
574584
#[inline]
575585
unsafe fn map_to_range_with_table_flags<A>(
576586
&mut self,
@@ -597,6 +607,7 @@ impl<'a, P: PageTableFrameMapping> Mapper<Size1GiB> for MappedPageTable<'a, P> {
597607
)
598608
}
599609

610+
#[cfg(feature = "experimental")]
600611
#[inline]
601612
unsafe fn map_range_with_table_flags<A>(
602613
&mut self,
@@ -644,6 +655,7 @@ impl<'a, P: PageTableFrameMapping> Mapper<Size1GiB> for MappedPageTable<'a, P> {
644655
Ok((frame, MapperFlush::new(page)))
645656
}
646657

658+
#[cfg(feature = "experimental")]
647659
#[inline]
648660
unsafe fn unmap_range<D>(
649661
&mut self,
@@ -689,6 +701,7 @@ impl<'a, P: PageTableFrameMapping> Mapper<Size1GiB> for MappedPageTable<'a, P> {
689701
Ok(MapperFlush::new(page))
690702
}
691703

704+
#[cfg(feature = "experimental")]
692705
#[inline]
693706
unsafe fn update_flags_range(
694707
&mut self,
@@ -774,6 +787,7 @@ impl<'a, P: PageTableFrameMapping> Mapper<Size2MiB> for MappedPageTable<'a, P> {
774787
self.map_to_2mib(page, frame, flags, parent_table_flags, allocator)
775788
}
776789

790+
#[cfg(feature = "experimental")]
777791
#[inline]
778792
unsafe fn map_to_range_with_table_flags<A>(
779793
&mut self,
@@ -800,6 +814,7 @@ impl<'a, P: PageTableFrameMapping> Mapper<Size2MiB> for MappedPageTable<'a, P> {
800814
)
801815
}
802816

817+
#[cfg(feature = "experimental")]
803818
#[inline]
804819
unsafe fn map_range_with_table_flags<A>(
805820
&mut self,
@@ -850,6 +865,7 @@ impl<'a, P: PageTableFrameMapping> Mapper<Size2MiB> for MappedPageTable<'a, P> {
850865
Ok((frame, MapperFlush::new(page)))
851866
}
852867

868+
#[cfg(feature = "experimental")]
853869
#[inline]
854870
unsafe fn unmap_range<D>(
855871
&mut self,
@@ -899,6 +915,7 @@ impl<'a, P: PageTableFrameMapping> Mapper<Size2MiB> for MappedPageTable<'a, P> {
899915
Ok(MapperFlush::new(page))
900916
}
901917

918+
#[cfg(feature = "experimental")]
902919
#[inline]
903920
unsafe fn update_flags_range(
904921
&mut self,
@@ -997,6 +1014,7 @@ impl<'a, P: PageTableFrameMapping> Mapper<Size4KiB> for MappedPageTable<'a, P> {
9971014
self.map_to_4kib(page, frame, flags, parent_table_flags, allocator)
9981015
}
9991016

1017+
#[cfg(feature = "experimental")]
10001018
#[inline]
10011019
unsafe fn map_to_range_with_table_flags<A>(
10021020
&mut self,
@@ -1023,6 +1041,7 @@ impl<'a, P: PageTableFrameMapping> Mapper<Size4KiB> for MappedPageTable<'a, P> {
10231041
)
10241042
}
10251043

1044+
#[cfg(feature = "experimental")]
10261045
#[inline]
10271046
unsafe fn map_range_with_table_flags<A>(
10281047
&mut self,
@@ -1069,6 +1088,7 @@ impl<'a, P: PageTableFrameMapping> Mapper<Size4KiB> for MappedPageTable<'a, P> {
10691088
Ok((frame, MapperFlush::new(page)))
10701089
}
10711090

1091+
#[cfg(feature = "experimental")]
10721092
#[inline]
10731093
unsafe fn unmap_range<D>(
10741094
&mut self,
@@ -1123,6 +1143,7 @@ impl<'a, P: PageTableFrameMapping> Mapper<Size4KiB> for MappedPageTable<'a, P> {
11231143
Ok(MapperFlush::new(page))
11241144
}
11251145

1146+
#[cfg(feature = "experimental")]
11261147
#[inline]
11271148
unsafe fn update_flags_range(
11281149
&mut self,

src/structures/paging/mapper/mod.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ pub use self::recursive_page_table::{InvalidPageTable, RecursivePageTable};
88

99
use core::convert::Infallible;
1010

11+
#[cfg(feature = "experimental")]
12+
use crate::structures::paging::{frame::PhysFrameRange, page::PageRange};
1113
use crate::structures::paging::{
12-
frame::PhysFrameRange,
1314
frame_alloc::{FrameAllocator, FrameDeallocator},
14-
page::{PageRange, PageRangeInclusive},
15+
page::PageRangeInclusive,
1516
page_table::PageTableFlags,
1617
Page, PageSize, PhysFrame, Size1GiB, Size2MiB, Size4KiB,
1718
};
@@ -200,6 +201,7 @@ pub trait Mapper<S: PageSize> {
200201
}
201202
}
202203

204+
#[cfg(feature = "experimental")]
203205
/// Maps the given range of frames to the range of virtual pages.
204206
///
205207
/// ## Safety
@@ -324,6 +326,7 @@ pub trait Mapper<S: PageSize> {
324326
Self: Sized,
325327
A: FrameAllocator<Size4KiB> + ?Sized;
326328

329+
#[cfg(feature = "experimental")]
327330
/// Maps the given range of frames to the range of virtual pages.
328331
///
329332
/// ## Safety
@@ -378,6 +381,7 @@ pub trait Mapper<S: PageSize> {
378381
.map(|_| MapperFlushRange::new(pages))
379382
}
380383

384+
#[cfg(feature = "experimental")]
381385
/// Maps frames from the allocator to the given range of virtual pages.
382386
///
383387
/// ## Safety
@@ -430,6 +434,7 @@ pub trait Mapper<S: PageSize> {
430434
})
431435
}
432436

437+
#[cfg(feature = "experimental")]
433438
/// Maps frames from the allocator to the given range of virtual pages.
434439
///
435440
/// ## Safety
@@ -466,6 +471,7 @@ pub trait Mapper<S: PageSize> {
466471
/// Note that no page tables or pages are deallocated.
467472
fn unmap(&mut self, page: Page<S>) -> Result<(PhysFrame<S>, MapperFlush<S>), UnmapError>;
468473

474+
#[cfg(feature = "experimental")]
469475
/// Removes a range of mapping from the page table and deallocate the frames that used to be mapped.
470476
///
471477
/// Note that no page tables or pages are deallocated.
@@ -521,6 +527,7 @@ pub trait Mapper<S: PageSize> {
521527
flags: PageTableFlags,
522528
) -> Result<MapperFlush<S>, FlagUpdateError>;
523529

530+
#[cfg(feature = "experimental")]
524531
/// Updates the flags of a range of existing mappings.
525532
///
526533
/// ## Safety
@@ -630,6 +637,7 @@ pub trait Mapper<S: PageSize> {
630637
unsafe { self.map_to(page, frame, flags, frame_allocator) }
631638
}
632639

640+
#[cfg(feature = "experimental")]
633641
/// Maps the given range of frames to the range of virtual pages with the same address.
634642
///
635643
/// ## Safety
@@ -687,6 +695,7 @@ impl<S: PageSize> MapperFlush<S> {
687695
pub fn ignore(self) {}
688696
}
689697

698+
#[cfg(feature = "experimental")]
690699
/// This type represents a range of pages whose mappings have changed in the page table.
691700
///
692701
/// The old mappings might be still cached in the translation lookaside buffer (TLB), so they need
@@ -696,6 +705,7 @@ impl<S: PageSize> MapperFlush<S> {
696705
#[must_use = "Page Table changes must be flushed or ignored."]
697706
pub struct MapperFlushRange<S: PageSize>(PageRange<S>);
698707

708+
#[cfg(feature = "experimental")]
699709
impl<S: PageSize> MapperFlushRange<S> {
700710
/// Create a new flush promise
701711
#[inline]

src/structures/paging/mapper/offset_page_table.rs

+9
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ impl<'a> Mapper<Size1GiB> for OffsetPageTable<'a> {
7777
}
7878
}
7979

80+
#[cfg(feature = "experimental")]
8081
#[inline]
8182
unsafe fn map_to_range_with_table_flags<A>(
8283
&mut self,
@@ -101,6 +102,7 @@ impl<'a> Mapper<Size1GiB> for OffsetPageTable<'a> {
101102
}
102103
}
103104

105+
#[cfg(feature = "experimental")]
104106
#[inline]
105107
unsafe fn map_range_with_table_flags<A>(
106108
&mut self,
@@ -126,6 +128,7 @@ impl<'a> Mapper<Size1GiB> for OffsetPageTable<'a> {
126128
self.inner.unmap(page)
127129
}
128130

131+
#[cfg(feature = "experimental")]
129132
#[inline]
130133
unsafe fn unmap_range<D>(
131134
&mut self,
@@ -200,6 +203,7 @@ impl<'a> Mapper<Size2MiB> for OffsetPageTable<'a> {
200203
}
201204
}
202205

206+
#[cfg(feature = "experimental")]
203207
#[inline]
204208
unsafe fn map_to_range_with_table_flags<A>(
205209
&mut self,
@@ -224,6 +228,7 @@ impl<'a> Mapper<Size2MiB> for OffsetPageTable<'a> {
224228
}
225229
}
226230

231+
#[cfg(feature = "experimental")]
227232
#[inline]
228233
unsafe fn map_range_with_table_flags<A>(
229234
&mut self,
@@ -249,6 +254,7 @@ impl<'a> Mapper<Size2MiB> for OffsetPageTable<'a> {
249254
self.inner.unmap(page)
250255
}
251256

257+
#[cfg(feature = "experimental")]
252258
#[inline]
253259
unsafe fn unmap_range<D>(
254260
&mut self,
@@ -323,6 +329,7 @@ impl<'a> Mapper<Size4KiB> for OffsetPageTable<'a> {
323329
}
324330
}
325331

332+
#[cfg(feature = "experimental")]
326333
#[inline]
327334
unsafe fn map_to_range_with_table_flags<A>(
328335
&mut self,
@@ -347,6 +354,7 @@ impl<'a> Mapper<Size4KiB> for OffsetPageTable<'a> {
347354
}
348355
}
349356

357+
#[cfg(feature = "experimental")]
350358
#[inline]
351359
unsafe fn map_range_with_table_flags<A>(
352360
&mut self,
@@ -372,6 +380,7 @@ impl<'a> Mapper<Size4KiB> for OffsetPageTable<'a> {
372380
self.inner.unmap(page)
373381
}
374382

383+
#[cfg(feature = "experimental")]
375384
#[inline]
376385
unsafe fn unmap_range<D>(
377386
&mut self,

0 commit comments

Comments
 (0)