Skip to content

Commit

Permalink
Merge pull request #448 from rust-osdev/fix/always-cover-4g
Browse files Browse the repository at this point in the history
always cover at least the first 4 GiB of physical memory
  • Loading branch information
phil-opp authored Jul 11, 2024
2 parents bf950a4 + bf104bd commit 96f58f2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions common/src/legacy_memory_region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,17 @@ where
///
/// Useful for creating a mapping for all physical memory.
pub fn max_phys_addr(&self) -> PhysAddr {
self.original
let max = self
.original
.clone()
.map(|r| r.start() + r.len())
.max()
.unwrap()
.unwrap();

// Always cover at least the first 4 GiB of physical memory. That area
// contains useful MMIO regions (local APIC, I/O APIC, PCI bars) that
// we want to make accessible to the kernel even if no DRAM exists >4GiB.
cmp::max(max, PhysAddr::new(0x1_0000_0000))
}

/// Calculate the maximum number of regions produced by [Self::construct_memory_map]
Expand Down

0 comments on commit 96f58f2

Please sign in to comment.