Skip to content

Commit

Permalink
[CHERRY_PICK] AdvLoggerPkg: Use BootServicesData for PreMem Alloc
Browse files Browse the repository at this point in the history
This is a very small portion cherry-picked from
be9a3d2. This fixes a breakage
for ARM64 platforms that initialize AdvLogger in PeiCore, which
has a hardcoded assumption that memory is not available at its
start (not true for ARM64 platforms) and so allocating a minimum
of 16 pages for the runtime granularity will fail. This "pre-mem"
buffer gets freed as soon as permanent memory is installed, so we
can allocate it as EfiBootServicesData (which does not use the
runtime allocation granularity of 64k). This also works on x86.
If PcdAdvancedLoggerPeiInRAM is true, we can allocate the full
amount and need the correct runtime type (I do not think this
feature works, for the reason listed above, but that is outside
the scope of this commit).
  • Loading branch information
os-d committed Jul 12, 2024
1 parent dd13250 commit 2603491
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ AdvancedLoggerGetLoggerInfo (
UINTN Pages;
CONST EFI_PEI_SERVICES **PeiServices;
EFI_STATUS Status;
EFI_MEMORY_TYPE Type;

// Try to do the minimum work at the start of this function as this
// is called quite often.
Expand Down Expand Up @@ -513,14 +514,17 @@ AdvancedLoggerGetLoggerInfo (

if (FeaturePcdGet (PcdAdvancedLoggerPeiInRAM)) {
Pages = FixedPcdGet32 (PcdAdvancedLoggerPages);
Type = EfiRuntimeServicesData;
} else {
Pages = FixedPcdGet32 (PcdAdvancedLoggerPreMemPages);
// This is to avoid the interim buffer being allocated to consume 64KB on ARM64 platforms.
Type = EfiBootServicesData;
}

BufferSize = EFI_PAGES_TO_SIZE (Pages);

Status = PeiServicesAllocatePages (
EfiReservedMemoryType,
Type,
Pages,
&NewLoggerInfo
);
Expand Down

0 comments on commit 2603491

Please sign in to comment.