Page 1 of 1

UEFI Memory Allocation Page Flags

Posted: Sat Jan 25, 2025 6:30 am
by chicken
When using UEFI to make a bootloader, the AllocatePages function can be used to allocate a certain set of pages of a specific memory type. Before memory can be used in long mode, it must be mapped. Is there a way to set/know which page table entry flags are used for when the memory for these allocations is mapped?

Re: UEFI Memory Allocation Page Flags

Posted: Sat Jan 25, 2025 1:47 pm
by Octocontrabass
I don't think there's any way to know what will be used before you allocate it, but afterwards you should see the page attributes reflected in the memory map.

If you're worried about it, use EfiLoaderData for everything and switch to your own set of page tables between calling ExitBootServices and jumping to your kernel's entry point. (Or use a bootloader that handles it for you, like Limine.)