Page 1 of 1

EFI_BOOT_SERVICES.AllocatePages issue

Posted: Fri Jan 24, 2025 1:21 am
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?

Re: EFI_BOOT_SERVICES.AllocatePages issue

Posted: Fri Jan 24, 2025 9:23 am
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.

Re: EFI_BOOT_SERVICES.AllocatePages issue

Posted: Fri Jan 24, 2025 9:31 am
by iansjack
The significance of that IN OUT parameter depends upon the Type parameter.

Re: EFI_BOOT_SERVICES.AllocatePages issue

Posted: Fri Jan 24, 2025 11:20 am
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.

Re: EFI_BOOT_SERVICES.AllocatePages issue

Posted: Sun Jan 26, 2025 1:50 am
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.