rust-osdev / rust-osdev/bootloader

Bootloader marks frames used for bootloader page tables as reserved

Open
#318 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Rust
Stars
1.7k
Forks
240
PR merge metrics
No merged PRs in 30d

Description

When allocating frames to copy the bootloader page table, we allocate them using the default frame allocator meaning the kernel will see those regions as reserved. It also happens when mapping the boot info.

This is wrong, as the kernel should be free to overwrite the bootloader's page tables.

Solution

I think a newtype like so:

pub struct BootloaderLegacyFrameAllocator<'a>(pub &'a mut LegacyFrameAllocator);

with a custom FrameAllocator implementation would be the way to go. e.g. when mapping the boot info in the bootloader's page tables, we would do something like this:

page_tables.bootloader.map_to(
    page,
    frame,
    flags,
    &mut BootloaderLegacyFrameAllocator(&mut frame_allocator),
);

Even then, it's not a pretty solution, as we'd need to rework LegacyFrameAllocator to support allocating frames that will be marked as Usable in the memory map.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with frame allocation in uefi/src/main.rs around lines 317-319 and boot-info mapping in common/src/lib.rs around line 431. Read LegacyFrameAllocator and the FrameAllocator implementation to understand how allocated frames enter the memory map. Done means frames used only for bootloader page tables are reported as Usable so the kernel may overwrite them.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.