EFI_BOOT_SERVICES.AllocatePages issue

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
wishedtobe
Member
Member
Posts: 34
Joined: Sat May 04, 2024 7:48 am
Libera.chat IRC: wishedtobe

EFI_BOOT_SERVICES.AllocatePages issue

Post by wishedtobe »

Having the function called, I was confused to find that the base address it returned cannot be divisible by 0x1000. Is the so-called 'page allocation' actually just allocating 4kb of space in integer multiples?
nullplan
Member
Member
Posts: 1819
Joined: Wed Aug 30, 2017 8:24 am

Re: EFI_BOOT_SERVICES.AllocatePages issue

Post by nullplan »

Reading the spec (https://uefi.org/specs/UEFI/2.11/07_Ser ... ocatepages), it seems that the memory address is an in/out parameter, i.e. it must be initialized on input. Not seeing your code, I can only guess that this is a mistake you may have made. Other than that, yes, AllocatePages should return a page-aligned address.
Carpe diem!
User avatar
iansjack
Member
Member
Posts: 4733
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: EFI_BOOT_SERVICES.AllocatePages issue

Post by iansjack »

The significance of that IN OUT parameter depends upon the Type parameter.
Octocontrabass
Member
Member
Posts: 5655
Joined: Mon Mar 25, 2013 7:01 pm

Re: EFI_BOOT_SERVICES.AllocatePages issue

Post by Octocontrabass »

wishedtobe wrote: Fri Jan 24, 2025 1:21 amIs the so-called 'page allocation' actually just allocating 4kb of space in integer multiples?
No, it really does allocate pages. There must be a problem with your code.
wishedtobe
Member
Member
Posts: 34
Joined: Sat May 04, 2024 7:48 am
Libera.chat IRC: wishedtobe

Re: EFI_BOOT_SERVICES.AllocatePages issue

Post by wishedtobe »

nullplan wrote: Fri Jan 24, 2025 9:23 am Reading the spec (https://uefi.org/specs/UEFI/2.11/07_Ser ... ocatepages), it seems that the memory address is an in/out parameter, i.e. it must be initialized on input. Not seeing your code, I can only guess that this is a mistake you may have made. Other than that, yes, AllocatePages should return a page-aligned address.
I'm allocating with an EFI_ALLOCATE_TYPE of AllocateAnyPages, which indicates that the inputting Memory is ignored.
Post Reply