Skip to content

Bootloader marks frames used for bootloader page tables as reserved #318

@tsoutsman

Description

@tsoutsman
Contributor

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @phil-opp@tsoutsman

        Issue actions

          Bootloader marks frames used for bootloader page tables as reserved · Issue #318 · rust-osdev/bootloader