Skip to content

Commit a98dd8a

Browse files
committed
add experimental feature flag
1 parent 2dfd921 commit a98dd8a

File tree

5 files changed

+73
-18
lines changed

5 files changed

+73
-18
lines changed

Cargo.toml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,8 @@ authors = [
99
]
1010
description = "Support for x86_64 specific instructions, registers, and structures."
1111
documentation = "https://docs.rs/x86_64"
12-
keywords = [
13-
"amd64",
14-
"x86",
15-
"x86_64",
16-
"no_std",
17-
]
18-
categories = [
19-
"no-std",
20-
]
12+
keywords = ["amd64", "x86", "x86_64", "no_std"]
13+
categories = ["no-std"]
2114
license = "MIT/Apache-2.0"
2215
name = "x86_64"
2316
readme = "README.md"
@@ -34,10 +27,10 @@ volatile = "0.4.4"
3427
cc = { version = "1.0.37", optional = true }
3528

3629
[features]
37-
default = [ "nightly", "instructions" ]
30+
default = ["nightly", "instructions"]
3831
instructions = []
39-
external_asm = [ "cc" ]
40-
nightly = [ "inline_asm", "const_fn", "abi_x86_interrupt", "doc_cfg" ]
32+
external_asm = ["cc"]
33+
nightly = ["inline_asm", "const_fn", "abi_x86_interrupt", "doc_cfg"]
4134
inline_asm = []
4235
abi_x86_interrupt = []
4336
const_fn = []
@@ -46,7 +39,7 @@ doc_cfg = []
4639
[package.metadata.release]
4740
no-dev-version = true
4841
pre-release-replacements = [
49-
{ file="Changelog.md", search="# Unreleased", replace="# Unreleased\n\n# {{version}} – {{date}}", exactly=1 },
42+
{ file = "Changelog.md", search = "# Unreleased", replace = "# Unreleased\n\n# {{version}} – {{date}}", exactly = 1 },
5043
]
5144
pre-release-commit-message = "Bump version to {{version}}"
5245
disable-push = true

src/structures/paging/mapper/mapped_page_table.rs

Lines changed: 22 additions & 1 deletion
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, Size1GiB, Size2MiB, Size4KiB},
68
page_table::{FrameError, PageTable, PageTableEntry, PageTableFlags},
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

Lines changed: 13 additions & 3 deletions
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, FrameDeallocator};
1113
use crate::structures::paging::{
12-
frame::PhysFrameRange, frame_alloc::FrameAllocator, page::PageRange,
13-
page_table::PageTableFlags, FrameDeallocator, Page, PageSize, PhysFrame, Size1GiB, Size2MiB,
14-
Size4KiB,
14+
frame_alloc::FrameAllocator, page_table::PageTableFlags, Page, PageSize, PhysFrame, Size1GiB,
15+
Size2MiB, Size4KiB,
1516
};
1617
use crate::{PhysAddr, VirtAddr};
1718

@@ -196,6 +197,7 @@ pub trait Mapper<S: PageSize> {
196197
self.map_to_with_table_flags(page, frame, flags, parent_table_flags, frame_allocator)
197198
}
198199

200+
#[cfg(feature = "experimental")]
199201
/// Maps the given range of frames to the range of virtual pages.
200202
///
201203
/// ## Safety
@@ -318,6 +320,7 @@ pub trait Mapper<S: PageSize> {
318320
Self: Sized,
319321
A: FrameAllocator<Size4KiB> + ?Sized;
320322

323+
#[cfg(feature = "experimental")]
321324
/// Maps the given range of frames to the range of virtual pages.
322325
///
323326
/// ## Safety
@@ -370,6 +373,7 @@ pub trait Mapper<S: PageSize> {
370373
.map(|_| MapperFlushRange::new(pages))
371374
}
372375

376+
#[cfg(feature = "experimental")]
373377
/// Maps frames from the allocator to the given range of virtual pages.
374378
///
375379
/// ## Safety
@@ -422,6 +426,7 @@ pub trait Mapper<S: PageSize> {
422426
})
423427
}
424428

429+
#[cfg(feature = "experimental")]
425430
/// Maps frames from the allocator to the given range of virtual pages.
426431
///
427432
/// ## Safety
@@ -455,6 +460,7 @@ pub trait Mapper<S: PageSize> {
455460
/// Note that no page tables or pages are deallocated.
456461
fn unmap(&mut self, page: Page<S>) -> Result<(PhysFrame<S>, MapperFlush<S>), UnmapError>;
457462

463+
#[cfg(feature = "experimental")]
458464
/// Removes a range of mapping from the page table and deallocate the frames that used to be mapped.
459465
///
460466
/// Note that no page tables or pages are deallocated.
@@ -510,6 +516,7 @@ pub trait Mapper<S: PageSize> {
510516
flags: PageTableFlags,
511517
) -> Result<MapperFlush<S>, FlagUpdateError>;
512518

519+
#[cfg(feature = "experimental")]
513520
/// Updates the flags of a range of existing mappings.
514521
///
515522
/// ## Safety
@@ -617,6 +624,7 @@ pub trait Mapper<S: PageSize> {
617624
self.map_to(page, frame, flags, frame_allocator)
618625
}
619626

627+
#[cfg(feature = "experimental")]
620628
/// Maps the given range of frames to the range of virtual pages with the same address.
621629
///
622630
/// ## Safety
@@ -674,6 +682,7 @@ impl<S: PageSize> MapperFlush<S> {
674682
pub fn ignore(self) {}
675683
}
676684

685+
#[cfg(feature = "experimental")]
677686
/// This type represents a range of pages whose mappings have changed in the page table.
678687
///
679688
/// The old mappings might be still cached in the translation lookaside buffer (TLB), so they need
@@ -683,6 +692,7 @@ impl<S: PageSize> MapperFlush<S> {
683692
#[must_use = "Page Table changes must be flushed or ignored."]
684693
pub struct MapperFlushRange<S: PageSize>(PageRange<S>);
685694

695+
#[cfg(feature = "experimental")]
686696
impl<S: PageSize> MapperFlushRange<S> {
687697
/// Create a new flush promise
688698
#[inline]

src/structures/paging/mapper/offset_page_table.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ impl<'a> Mapper<Size1GiB> for OffsetPageTable<'a> {
7575
.map_to_with_table_flags(page, frame, flags, parent_table_flags, allocator)
7676
}
7777

78+
#[cfg(feature = "experimental")]
7879
#[inline]
7980
unsafe fn map_to_range_with_table_flags<A>(
8081
&mut self,
@@ -97,6 +98,7 @@ impl<'a> Mapper<Size1GiB> for OffsetPageTable<'a> {
9798
)
9899
}
99100

101+
#[cfg(feature = "experimental")]
100102
#[inline]
101103
unsafe fn map_range_with_table_flags<A>(
102104
&mut self,
@@ -120,6 +122,7 @@ impl<'a> Mapper<Size1GiB> for OffsetPageTable<'a> {
120122
self.inner.unmap(page)
121123
}
122124

125+
#[cfg(feature = "experimental")]
123126
#[inline]
124127
unsafe fn unmap_range<D>(
125128
&mut self,
@@ -192,6 +195,7 @@ impl<'a> Mapper<Size2MiB> for OffsetPageTable<'a> {
192195
.map_to_with_table_flags(page, frame, flags, parent_table_flags, allocator)
193196
}
194197

198+
#[cfg(feature = "experimental")]
195199
#[inline]
196200
unsafe fn map_to_range_with_table_flags<A>(
197201
&mut self,
@@ -214,6 +218,7 @@ impl<'a> Mapper<Size2MiB> for OffsetPageTable<'a> {
214218
)
215219
}
216220

221+
#[cfg(feature = "experimental")]
217222
#[inline]
218223
unsafe fn map_range_with_table_flags<A>(
219224
&mut self,
@@ -237,6 +242,7 @@ impl<'a> Mapper<Size2MiB> for OffsetPageTable<'a> {
237242
self.inner.unmap(page)
238243
}
239244

245+
#[cfg(feature = "experimental")]
240246
#[inline]
241247
unsafe fn unmap_range<D>(
242248
&mut self,
@@ -309,6 +315,7 @@ impl<'a> Mapper<Size4KiB> for OffsetPageTable<'a> {
309315
.map_to_with_table_flags(page, frame, flags, parent_table_flags, allocator)
310316
}
311317

318+
#[cfg(feature = "experimental")]
312319
#[inline]
313320
unsafe fn map_to_range_with_table_flags<A>(
314321
&mut self,
@@ -331,6 +338,7 @@ impl<'a> Mapper<Size4KiB> for OffsetPageTable<'a> {
331338
)
332339
}
333340

341+
#[cfg(feature = "experimental")]
334342
#[inline]
335343
unsafe fn map_range_with_table_flags<A>(
336344
&mut self,
@@ -354,6 +362,7 @@ impl<'a> Mapper<Size4KiB> for OffsetPageTable<'a> {
354362
self.inner.unmap(page)
355363
}
356364

365+
#[cfg(feature = "experimental")]
357366
#[inline]
358367
unsafe fn unmap_range<D>(
359368
&mut self,

0 commit comments

Comments
 (0)