Skip to content

Commit

Permalink
mark more entries as used
Browse files Browse the repository at this point in the history
The bootloader maps some of the memory used by the kernel into its own
address space as well. In order for that to work we must ensure that
the bootloader doesn't already have memory mapped there. Mark regions
that are likely to be used by the bootloader as unusable.
  • Loading branch information
Freax13 committed Oct 26, 2024
1 parent e9c92ec commit 67f3194
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion common/src/level_4_entries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,17 @@ impl UsedLevel4Entries {
rng: config.mappings.aslr.then(entropy::build_rng),
};

used.entry_state[0] = true; // TODO: Can we do this dynamically?
// The bootloader maps of the kernel's memory into its own page tables.
// We need to prevent overlaps, so mark all memory that could already
// be used by the bootload as inaccessible.

// All memory in this range is identity mapped.
used.mark_range_as_used(0, max_phys_addr.as_u64());

// The bootload needs to access the frame buffer.
if let Some(frame_buffer) = framebuffer {
used.mark_range_as_used(frame_buffer.addr.as_u64(), frame_buffer.info.byte_len);
}

// Mark the statically configured ranges from the config as used.

Expand Down

0 comments on commit 67f3194

Please sign in to comment.