From: Min M Xu <min.m...@intel.com> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4181
ConstructFwHobList once searched the accepted memory under 4G. This need to be updated because of PcdAcceptMemoryEndAddress. If PcdAcceptMemoryEndAddress is less than 4G, we should search the memory under PcdAcceptMemoryEndAddress. Cc: Erdem Aktas <erdemak...@google.com> Cc: Gerd Hoffmann <kra...@redhat.com> Cc: James Bottomley <j...@linux.ibm.com> Cc: Jiewen Yao <jiewen....@intel.com> Cc: Tom Lendacky <thomas.lenda...@amd.com> Signed-off-by: Min Xu <min.m...@intel.com> --- OvmfPkg/Library/PeilessStartupLib/Hob.c | 25 +++++++++++++------ .../PeilessStartupLib/PeilessStartupLib.inf | 1 + 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/OvmfPkg/Library/PeilessStartupLib/Hob.c b/OvmfPkg/Library/PeilessStartupLib/Hob.c index 630ce445ebec..8ea7a68343ed 100644 --- a/OvmfPkg/Library/PeilessStartupLib/Hob.c +++ b/OvmfPkg/Library/PeilessStartupLib/Hob.c @@ -74,17 +74,23 @@ ConstructFwHobList ( ) { EFI_PEI_HOB_POINTERS Hob; + EFI_PHYSICAL_ADDRESS PhysicalStart; EFI_PHYSICAL_ADDRESS PhysicalEnd; UINT64 ResourceLength; EFI_PHYSICAL_ADDRESS LowMemoryStart; UINT64 LowMemoryLength; + EFI_PHYSICAL_ADDRESS AcceptMemoryEndAddress; ASSERT (VmmHobList != NULL); Hob.Raw = (UINT8 *)VmmHobList; - LowMemoryLength = 0; - LowMemoryStart = 0; + LowMemoryLength = 0; + LowMemoryStart = 0; + AcceptMemoryEndAddress = FixedPcdGet64 (PcdAcceptMemoryEndAddress); + if ((AcceptMemoryEndAddress == 0) || (AcceptMemoryEndAddress > SIZE_4GB)) { + AcceptMemoryEndAddress = SIZE_4GB; + } // // Parse the HOB list until end of list or matching type is found. @@ -92,16 +98,21 @@ ConstructFwHobList ( while (!END_OF_HOB_LIST (Hob)) { if (Hob.Header->HobType == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) { if (Hob.ResourceDescriptor->ResourceType == BZ3937_EFI_RESOURCE_MEMORY_UNACCEPTED) { - PhysicalEnd = Hob.ResourceDescriptor->PhysicalStart + Hob.ResourceDescriptor->ResourceLength; + PhysicalStart = Hob.ResourceDescriptor->PhysicalStart; + PhysicalEnd = PhysicalStart + Hob.ResourceDescriptor->ResourceLength; ResourceLength = Hob.ResourceDescriptor->ResourceLength; - if (PhysicalEnd <= BASE_4GB) { + if (PhysicalEnd >= AcceptMemoryEndAddress) { + ResourceLength = AcceptMemoryEndAddress - PhysicalStart; + } + + if (PhysicalStart >= AcceptMemoryEndAddress) { + break; + } else { if (ResourceLength > LowMemoryLength) { LowMemoryStart = Hob.ResourceDescriptor->PhysicalStart; LowMemoryLength = ResourceLength; } - } else { - break; } } } @@ -110,7 +121,7 @@ ConstructFwHobList ( } if (LowMemoryLength == 0) { - DEBUG ((DEBUG_ERROR, "Cannot find a memory region under 4GB for Fw hoblist.\n")); + DEBUG ((DEBUG_ERROR, "Cannot find a memory region under 0x%llx for Fw hoblist.\n", AcceptMemoryEndAddress)); return EFI_NOT_FOUND; } diff --git a/OvmfPkg/Library/PeilessStartupLib/PeilessStartupLib.inf b/OvmfPkg/Library/PeilessStartupLib/PeilessStartupLib.inf index def50b4b019e..644facb60074 100644 --- a/OvmfPkg/Library/PeilessStartupLib/PeilessStartupLib.inf +++ b/OvmfPkg/Library/PeilessStartupLib/PeilessStartupLib.inf @@ -88,3 +88,4 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask ## CONSUMES gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize + gUefiOvmfPkgTokenSpaceGuid.PcdAcceptMemoryEndAddress -- 2.29.2.windows.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#97751): https://edk2.groups.io/g/devel/message/97751 Mute This Topic: https://groups.io/mt/95882248/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-