fix(paging): load back original P4 instead of temporary page frame in InactivePageTable::under
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: Julien CLEMENT <julien.clement@epita.fr>
This commit is contained in:
Julien CLEMENT 2021-12-08 02:23:46 +01:00
parent a5ba50f0aa
commit fcf2f7f439
2 changed files with 5 additions and 4 deletions

@ -10,6 +10,7 @@ SECTIONS {
. = ALIGN(4K); . = ALIGN(4K);
} }
. = ALIGN(4K);
.text : .text :
{ {
*(.text .text.*) *(.text .text.*)

@ -27,13 +27,13 @@ pub fn kernel_remap<A>(allocator: &mut A, boot_info: &BootInformation)
// section is not loaded to memory // section is not loaded to memory
continue; continue;
} }
println!("mapping section at addr: {:#x}, size: {:#x}",
section.addr, section.size);
assert!(section.start_address() % PAGE_SIZE == 0, assert!(section.start_address() % PAGE_SIZE == 0,
"sections need to be page aligned"); "sections need to be page aligned");
println!("mapping section at addr: {:#x}, size: {:#x}",
section.addr, section.size);
let flags = Flags::WRITABLE; let flags = Flags::WRITABLE | Flags::PRESENT;
let start_frame = Frame::<Size4KiB>::containing_address(PhysAddr::new(section.start_address() as u64)); let start_frame = Frame::<Size4KiB>::containing_address(PhysAddr::new(section.start_address() as u64));
let end_frame = Frame::containing_address(PhysAddr::new(section.end_address() as u64 - 1)); let end_frame = Frame::containing_address(PhysAddr::new(section.end_address() as u64 - 1));
@ -74,7 +74,7 @@ impl InactivePageTable {
f(active_table); f(active_table);
p4_table[511].set_frame(self.p4_frame, Flags::PRESENT | Flags::WRITABLE); p4_table[511].set_frame(backup, Flags::PRESENT | Flags::WRITABLE);
x86_64::instructions::tlb::flush_all(); x86_64::instructions::tlb::flush_all();
temporary_page.unmap(active_table); temporary_page.unmap(active_table);