Skip to content

Commit f317b0d

Browse files
committed
Don't error if a kernel page is already mapped to the correct frame
This can happen if one frame contains two loadable sections.
1 parent 9a915f1 commit f317b0d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/page_table.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,15 @@ pub(crate) fn map_segment(
9696
for frame in PhysFrame::range_inclusive(start_frame, end_frame) {
9797
let offset = frame - start_frame;
9898
let page = start_page + offset;
99-
unsafe { map_page(page, frame, page_table_flags, page_table, frame_allocator)? }
100-
.flush();
99+
match unsafe {
100+
map_page(page, frame, page_table_flags, page_table, frame_allocator)
101+
} {
102+
Ok(flusher) => flusher.flush(),
103+
Err(MapToError::PageAlreadyMapped(to)) if to == frame => {
104+
// nothing to do, page is already mapped to the correct frame
105+
}
106+
Err(err) => return Err(err),
107+
}
101108
}
102109

103110
if mem_size > file_size {

0 commit comments

Comments
 (0)