Skip to content

Commit

Permalink
Don't error if a kernel page is already mapped to the correct frame
Browse files Browse the repository at this point in the history
This can happen if one frame contains two loadable sections.
  • Loading branch information
phil-opp committed Feb 16, 2024
1 parent 9a915f1 commit f317b0d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/page_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,15 @@ pub(crate) fn map_segment(
for frame in PhysFrame::range_inclusive(start_frame, end_frame) {
let offset = frame - start_frame;
let page = start_page + offset;
unsafe { map_page(page, frame, page_table_flags, page_table, frame_allocator)? }
.flush();
match unsafe {
map_page(page, frame, page_table_flags, page_table, frame_allocator)
} {
Ok(flusher) => flusher.flush(),
Err(MapToError::PageAlreadyMapped(to)) if to == frame => {
// nothing to do, page is already mapped to the correct frame
}
Err(err) => return Err(err),
}
}

if mem_size > file_size {
Expand Down

0 comments on commit f317b0d

Please sign in to comment.