From: "Min Xu" <min.m.xu@intel.com>
To: devel@edk2.groups.io
Cc: Min M Xu <min.m.xu@intel.com>,
Erdem Aktas <erdemaktas@google.com>,
Gerd Hoffmann <kraxel@redhat.com>,
James Bottomley <jejb@linux.ibm.com>,
Jiewen Yao <jiewen.yao@intel.com>,
Tom Lendacky <thomas.lendacky@amd.com>
Subject: [PATCH V1 2/3] OvmfPkg/PeilessStartupLib: Update ConstructFwHobList for lazy-accept
Date: Mon, 26 Dec 2022 09:33:37 +0800 [thread overview]
Message-ID: <20221226013338.1924-3-min.m.xu@intel.com> (raw)
In-Reply-To: <20221226013338.1924-1-min.m.xu@intel.com>
From: Min M Xu <min.m.xu@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 <erdemaktas@google.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Min Xu <min.m.xu@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
next prev parent reply other threads:[~2022-12-26 1:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-26 1:33 [PATCH V1 0/3] Customize lazy-accepted memory size for TDVF Min Xu
2022-12-26 1:33 ` [PATCH V1 1/3] OvmfPkg: Customize lazy-accept's end address Min Xu
2022-12-26 1:33 ` Min Xu [this message]
2022-12-26 1:33 ` [PATCH V1 3/3] OvmfPkg/PlatformPei: Adjust LowerMemorySize in PublishPeiMemory Min Xu
2023-01-02 10:36 ` [PATCH V1 0/3] Customize lazy-accepted memory size for TDVF Gerd Hoffmann
2023-01-16 12:01 ` [edk2-devel] " Min Xu
2023-01-17 9:43 ` Gerd Hoffmann
2023-01-03 15:39 ` Lendacky, Thomas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221226013338.1924-3-min.m.xu@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox