bootloader icon indicating copy to clipboard operation
bootloader copied to clipboard

Bootloader marks frames used for bootloader page tables as reserved

Open tsoutsman opened this issue 2 years ago • 0 comments

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.

tsoutsman avatar Jan 06 '23 07:01 tsoutsman