On 26 May 2015 at 11:40, Laszlo Ersek <ler...@redhat.com> wrote:
> Ard,
>
> On 05/25/15 05:27, Heyi Guo wrote:
>> Hi folks,
>>
>> I noticed that the number of pages will be extended to 64KB aligned for
>> AARCH64 runtime services memory, like EfiRuntimeServicesCode/Data,
>> AcpiReclaimMemory, etc. However, the caller does not know the real page
>> number that was allocated; if some error occurs and the caller wants to
>> free the runtime memory which was allocated earlier, he can only use
>> EFI_SIZE_TO_PAGES to get the page number of 4KB aligned and up to 15
>> pages (60KB) memory might be leaked.
>>
>> This is not a critical issue for it is not common to free runtime type
>> memory. But I think it will be better to fix it in some way, e.g. using
>> another macro to calculate page number for runtime memory, documented in
>> UEFI spec, etc.
>>
>> Please let me know your comments, thanks!
>
> is this perhaps related to the recent-ish patches that adapt allocations
> to the 64KB page size?
>

Yes, it looks that way. But the relevant free path in
MdeModulePkg/Core/Dxe/Mem/Page.c is

"""
  Alignment = EFI_DEFAULT_PAGE_ALLOCATION_ALIGNMENT;

  ASSERT (Entry != NULL);
  if  (Entry->Type == EfiACPIReclaimMemory   ||
       Entry->Type == EfiACPIMemoryNVS       ||
       Entry->Type == EfiRuntimeServicesCode ||
       Entry->Type == EfiRuntimeServicesData) {

    Alignment = EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT;

  }

  if ((Memory & (Alignment - 1)) != 0) {
    Status = EFI_INVALID_PARAMETER;
    goto Done;
  }

  NumberOfPages += EFI_SIZE_TO_PAGES (Alignment) - 1;
  NumberOfPages &= ~(EFI_SIZE_TO_PAGES (Alignment) - 1);

  Status = CoreConvertPages (Memory, NumberOfPages, EfiConventionalMemory);

"""

so the number of pages being freed is internally rounded up to the
same granularity that was used to do the allocation.

@Heyi: can you confirm that the FreePages() call returns without an
error in your case?

-- 
Ard.

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to