Skip to content

Commit

Permalink
x86_64: fix r/w bit on intermediate page table entries
Browse files Browse the repository at this point in the history
  • Loading branch information
Qix- committed Aug 3, 2024
1 parent c226b7a commit 8009fcc
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion oro-arch-x86_64/src/mem/segment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,18 @@ impl AddressSegment {
translator.to_virtual_addr(entry.address())
} else {
let frame_phys_addr = alloc.allocate().ok_or(MapError::OutOfMemory)?;
*entry = self.entry_template.with_address(frame_phys_addr);

// SAFETY(qix-): We set writable here since if two L4/L3/L2 regions
// SAFETY(qix-): overlap and one is writable, mapping the unwritable
// SAFETY(qix-): first would otherwise cause a fault for any writes
// SAFETY(qix-): to the overlapping region. Since the leaf pages
// SAFETY(qix-): ultimately have their R/W bits set correctly, we set
// SAFETY(qix-): the intermediate pages to writable to avoid this.
*entry = self
.entry_template
.with_address(frame_phys_addr)
.with_writable();

let frame_virt_addr = translator.to_virtual_addr(frame_phys_addr);
crate::asm::invlpg(frame_virt_addr);

Expand Down

0 comments on commit 8009fcc

Please sign in to comment.