Subject: Re: [edk2] AllocatePages returns EFI_NOT_FOUND
From: Andrew Fish <firstname.lastname@example.org>
Date: 2013-09-05 17:54:25
Sorin,Depending on the APIs that are called between each call to AllocatePages(), memory may be allocated or freed which may cause the memory map to change.You need to make sure there are no API calls that either directly or indirectly allocate memory between the call to GetMemoryMap() and the call(s) to AllocatePages().Even doing an action like printing a message to the console could allocate some memory.If actions that allocate memory can not be avoided, you might consider calling GetMemoryMap() again right before each call to AllocatePages().
Liming,I am allocating memory iterative in each of the free memory blocks retrieved from the memory map, including 8000, 59000, 100000, 1100000, 14610000, 20200000, and allocation succeeds. The only problem is at 131D0000 address.From what I observed, every new memory request is allocated starting with 131D0000 address. So the problem might be due to a memory leak or an allocated buffer which was allocated after the memory map was retrieved and not yet freed. This is why the AllocatePages function returns EFI_NOT_FOUND, because the requested page is not free/available anymore.Thanks,SorinSorin:When your Shell Application is loaded, it will take some memory. Its taken memory may conflict with your allocated memory.Have you tried to allocate other free memory range, such as 14610000, 20200000?ThanksLimingHi Liming,Yes, GetMemoryMap function sees that memory pointed by PhysicaAddress as free - marked as EfiConventionalMemory -,but when trying to allocate memory there, using the AllocatePages function, it fails with EFI_NOT_FOUND status.Here is the memory map I am retrieving:PhysicalAddress NoOfPages80008059000 6100000 38401100000 28416131D0000 45414610000 4760020200000 13056440005000 564399100000000 189952The problem appears when I try to allocate memory at 131D0000 address.Thanks,SorinHi:Allocation requests of Type AllocateAddress means allocate pages at the address pointed to by Memory on input. If the requested pages could not be found, EFI_NOT_FOUND will return.For your issue, the memory described by PhysicalAddress should not be available. So, EFI_NOT_FOUND returns. Do you mean that you call GetMemoryMap() and see the memory pointed by PhysicalAddress is free? If yes, could you show the free memory layout and PhysicalAddress value?ThanksLimingHi all,I have an UEFI application in which I try to allocate memory of type EfiBootServicesData, using the AllocatePages function. In order to find the next available (unallocated) memory space - of type EfiConventionalMemory - I use the GetMemoryMap function. The problem which I'm facing is that when I try to allocate memory at one particular address, the AllocatePages function returns EFI_NOT_FOUND. This issue happens every time, when the application is executed, and at the exact memory address; for all remaining free memory blocks the allocation performs without problems.I am calling the allocation function as follows:gBS->AllocatePages ( AllocateAddress, EfiBootServicesData, NumberOfPages, &PhysicalAddress );Is this scenario a memory access error?How should I interpret this?Thanks,Sorin
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
edk2-devel mailing list