Skip to content

Commit

Permalink
feat: add guard page
Browse files Browse the repository at this point in the history
  • Loading branch information
marekvospel committed Nov 26, 2023
1 parent 4ca6684 commit 1dc5fb2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/memory/frames/bump_alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use core::ops::RangeInclusive;

use multiboot2::{MemoryArea, MemoryAreaType};

use crate::println;

use super::{FrameAlloc, PhysicalFrame, PAGE_SIZE};

pub struct BumpAllocator<'a> {
Expand Down Expand Up @@ -70,6 +72,7 @@ impl<'a> FrameAlloc for BumpAllocator<'a> {
}

fn deallocate_frame(&mut self, _frame: PhysicalFrame) {
unimplemented!()
println!("[WARN] Trying to deallocate a frame, BumpAllocator doesn't support that");
// unimplemented!()
}
}
5 changes: 3 additions & 2 deletions src/memory/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@ fn remap_kernel<A: FrameAlloc>(
mapper.identity_map(vga_text, EntryFlags::WRITABLE, allocator);
});

active_table.switch(new_table);
let old_table = active_table.switch(new_table);

// TODO: guard page
let old_page = Page::containing_address(old_table.p4_frame.start_address());
active_table.unmap(old_page, allocator);
}

fn enable_write_protect_bit() {
Expand Down
4 changes: 1 addition & 3 deletions src/memory/paging/mapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,7 @@ impl ActivePageTable {
let old = Cr3::read();

let old_table = InactivePageTable {
p4_frame: PhysicalFrame {
number: old.0.start_address().as_u64(),
},
p4_frame: PhysicalFrame::by_addr(old.0.start_address().as_u64()),
};
unsafe {
Cr3::write(
Expand Down

0 comments on commit 1dc5fb2

Please sign in to comment.