Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize from_page_table_indices #456

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 12 additions & 18 deletions src/structures/paging/page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,13 @@
}

// FIXME: Move this into the `Step` impl, once `Step` is stabilized.
pub(crate) fn steps_between_impl(start: &Self, end: &Self) -> Option<usize> {

Check warning on line 153 in src/structures/paging/page.rs

View workflow job for this annotation

GitHub Actions / Test MSRV and Stable Features (nightly)

associated functions `steps_between_impl` and `forward_checked_impl` are never used

Check warning on line 153 in src/structures/paging/page.rs

View workflow job for this annotation

GitHub Actions / Test MSRV and Stable Features (nightly)

associated functions `steps_between_impl` and `forward_checked_impl` are never used

Check warning on line 153 in src/structures/paging/page.rs

View workflow job for this annotation

GitHub Actions / Test MSRV and Stable Features (1.57)

associated function is never used: `steps_between_impl`

Check warning on line 153 in src/structures/paging/page.rs

View workflow job for this annotation

GitHub Actions / Test MSRV and Stable Features (1.57)

associated function is never used: `steps_between_impl`

Check warning on line 153 in src/structures/paging/page.rs

View workflow job for this annotation

GitHub Actions / Test MSRV and Stable Features (1.59)

associated function is never used: `steps_between_impl`

Check warning on line 153 in src/structures/paging/page.rs

View workflow job for this annotation

GitHub Actions / Test MSRV and Stable Features (1.59)

associated function is never used: `steps_between_impl`
VirtAddr::steps_between_impl(&start.start_address, &end.start_address)
.map(|steps| steps / S::SIZE as usize)
}

// FIXME: Move this into the `Step` impl, once `Step` is stabilized.
pub(crate) fn forward_checked_impl(start: Self, count: usize) -> Option<Self> {

Check warning on line 159 in src/structures/paging/page.rs

View workflow job for this annotation

GitHub Actions / Test MSRV and Stable Features (1.57)

associated function is never used: `forward_checked_impl`

Check warning on line 159 in src/structures/paging/page.rs

View workflow job for this annotation

GitHub Actions / Test MSRV and Stable Features (1.57)

associated function is never used: `forward_checked_impl`

Check warning on line 159 in src/structures/paging/page.rs

View workflow job for this annotation

GitHub Actions / Test MSRV and Stable Features (1.59)

associated function is never used: `forward_checked_impl`

Check warning on line 159 in src/structures/paging/page.rs

View workflow job for this annotation

GitHub Actions / Test MSRV and Stable Features (1.59)

associated function is never used: `forward_checked_impl`
let count = count.checked_mul(S::SIZE as usize)?;
let start_address = VirtAddr::forward_checked_impl(start.start_address, count)?;
Some(Self {
Expand All @@ -182,12 +182,10 @@
p4_index: PageTableIndex,
p3_index: PageTableIndex,
) -> Self {
use bit_field::BitField;

let mut addr = 0;
addr.set_bits(39..48, u64::from(p4_index));
addr.set_bits(30..39, u64::from(p3_index));
Page::containing_address(VirtAddr::new(addr))
addr |= u64::from(p4_index) << 39;
addr |= u64::from(p3_index) << 30;
Page::containing_address(VirtAddr::new_truncate(addr))
}
}

Expand All @@ -199,13 +197,11 @@
p3_index: PageTableIndex,
p2_index: PageTableIndex,
) -> Self {
use bit_field::BitField;

let mut addr = 0;
addr.set_bits(39..48, u64::from(p4_index));
addr.set_bits(30..39, u64::from(p3_index));
addr.set_bits(21..30, u64::from(p2_index));
Page::containing_address(VirtAddr::new(addr))
addr |= u64::from(p4_index) << 39;
addr |= u64::from(p3_index) << 30;
addr |= u64::from(p2_index) << 21;
Page::containing_address(VirtAddr::new_truncate(addr))
}
}

Expand All @@ -218,14 +214,12 @@
p2_index: PageTableIndex,
p1_index: PageTableIndex,
) -> Self {
use bit_field::BitField;

let mut addr = 0;
addr.set_bits(39..48, u64::from(p4_index));
addr.set_bits(30..39, u64::from(p3_index));
addr.set_bits(21..30, u64::from(p2_index));
addr.set_bits(12..21, u64::from(p1_index));
Page::containing_address(VirtAddr::new(addr))
addr |= u64::from(p4_index) << 39;
addr |= u64::from(p3_index) << 30;
addr |= u64::from(p2_index) << 21;
addr |= u64::from(p1_index) << 12;
Page::containing_address(VirtAddr::new_truncate(addr))
}

/// Returns the level 1 page table index of this page.
Expand Down