Skip to content

Commit 528b52c

Browse files
committed
check if entry contains a frame
1 parent ef311ce commit 528b52c

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

src/structures/paging/mapper/mod.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ use crate::structures::paging::{
1818
};
1919
use crate::{PhysAddr, VirtAddr};
2020

21+
use super::page_table::FrameError;
22+
2123
mod mapped_page_table;
2224
mod offset_page_table;
2325
#[cfg(feature = "instructions")]
@@ -793,6 +795,15 @@ pub enum UnmapError {
793795
InvalidFrameAddress(PhysAddr),
794796
}
795797

798+
impl From<FrameError> for UnmapError {
799+
fn from(e: FrameError) -> Self {
800+
match e {
801+
FrameError::FrameNotPresent => Self::PageNotMapped,
802+
FrameError::HugeFrame => Self::ParentEntryHugePage,
803+
}
804+
}
805+
}
806+
796807
impl From<Infallible> for UnmapError {
797808
fn from(i: Infallible) -> Self {
798809
match i {}
@@ -809,6 +820,15 @@ pub enum FlagUpdateError {
809820
ParentEntryHugePage,
810821
}
811822

823+
impl From<FrameError> for FlagUpdateError {
824+
fn from(e: FrameError) -> Self {
825+
match e {
826+
FrameError::FrameNotPresent => Self::PageNotMapped,
827+
FrameError::HugeFrame => Self::ParentEntryHugePage,
828+
}
829+
}
830+
}
831+
812832
impl From<Infallible> for FlagUpdateError {
813833
fn from(i: Infallible) -> Self {
814834
match i {}

src/structures/paging/mapper/recursive_page_table.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,10 @@ impl<'a> RecursivePageTable<'a> {
305305
#[cfg(feature = "experimental")]
306306
unsafe fn next_table_fn_next_table_mut<'b, I>(
307307
_: &mut I,
308-
_: &'b mut PageTableEntry,
308+
e: &'b mut PageTableEntry,
309309
page: Page,
310-
) -> Result<&'b mut PageTable, Infallible> {
310+
) -> Result<&'b mut PageTable, FrameError> {
311+
e.frame()?;
311312
Ok(&mut *page.start_address().as_mut_ptr())
312313
}
313314

0 commit comments

Comments
 (0)