Skip to content

Commit

Permalink
MdeModulePkg/DxeCore: Allow relocation of images with large address
Browse files Browse the repository at this point in the history
Add PCD to control if modules with start addresses in PE/COFF > 0x100000
attempt to load at specified address.
If a module has an address in this range and there is untested memory
DxeCore will attempt to promote all memory to tested which bypasses any
memory testing that would occur later in boot.

There are several existing AARCH64 option roms that have base addresses
of 0x180000000.

Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
Reviewed-by: Ashish Singhal <ashishsingha@nvidia.com>
Message-Id: <bd36c9c24158590db2226ede05cb8c2f50c93a37.1684194452.git.jbrasen@nvidia.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
  • Loading branch information
jbrasen authored and mergify[bot] committed Oct 31, 2023
1 parent a671a14 commit aa84318
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions MdeModulePkg/Core/Dxe/DxeMain.inf
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFwVolDxeMaxEncapsulationDepth ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdImageLargeAddressLoad ## CONSUMES

# [Hob]
# RESOURCE_DESCRIPTOR ## CONSUMES
Expand Down
4 changes: 3 additions & 1 deletion MdeModulePkg/Core/Dxe/Image/Image.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,9 @@ CoreLoadPeImage (
);
}
} else {
if ((Image->ImageContext.ImageAddress >= 0x100000) || Image->ImageContext.RelocationsStripped) {
if ((PcdGetBool (PcdImageLargeAddressLoad) && ((Image->ImageContext.ImageAddress) >= 0x100000)) ||
Image->ImageContext.RelocationsStripped)
{
Status = CoreAllocatePages (
AllocateAddress,
(EFI_MEMORY_TYPE)(Image->ImageContext.ImageCodeMemoryType),
Expand Down
7 changes: 7 additions & 0 deletions MdeModulePkg/MdeModulePkg.dec
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,13 @@
# @Prompt Output MMIO address of Trace Hub message.
gEfiMdeModulePkgTokenSpaceGuid.PcdTraceHubDebugMmioAddress|0|UINT64|0x30001058

## Indicates if images with large load address (>0x100000) should attempted to load at specified location.
# If enabled, attempt to allocate at specfied location will be attempted with a fall back to any address.
# TRUE - UEFI will attempt to load at specified location.<BR>
# FALSE - UEFI will load at any address<BR>
# @Prompt Enable large address image loading.
gEfiMdeModulePkgTokenSpaceGuid.PcdImageLargeAddressLoad|TRUE|BOOLEAN|0x30001059

[PcdsFixedAtBuild, PcdsPatchableInModule]
## Dynamic type PCD can be registered callback function for Pcd setting action.
# PcdMaxPeiPcdCallBackNumberPerPcdEntry indicates the maximum number of callback function
Expand Down

0 comments on commit aa84318

Please sign in to comment.