From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web11.129091.1672018441335739938 for ; Sun, 25 Dec 2022 17:34:01 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=nD80ewLq; spf=pass (domain: intel.com, ip: 192.55.52.88, mailfrom: min.m.xu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672018441; x=1703554441; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8l/9d0rvrax7pN9V4CkdXyQtcnaTkJcYXf1aJ/l++6U=; b=nD80ewLqEZ60sqG39jUEPhrNRWWbd7pXg08Ic7dukVL6ClxjWcnASeEI i/hFMOU9a1x5xEX/5WaWMNTDgH76wAZie3Nbn9V3JYSDt680m3m8KJk50 qjijsqHA67lNc/FYdQH5M4oJxaReucaXJUIkjE+okK1oj6gvHtYoc6WKJ Lj6P0FobeMqLg/zae/Z5RYJLSFGYvodE5bxP7Sa1FPuFvVLi2U9Feq3mU RUXMxhedON3PLoKCxbtkNilWX7uyb7/2IhyQxDyqlOWP4LxbDkWQOfZ3c 7qViqgovPi30DjsU+C6rTo74HELWl8dng7tjmy4FVGO+su881vxGPCXT+ w==; X-IronPort-AV: E=McAfee;i="6500,9779,10571"; a="347697069" X-IronPort-AV: E=Sophos;i="5.96,274,1665471600"; d="scan'208";a="347697069" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Dec 2022 17:34:00 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10571"; a="826755462" X-IronPort-AV: E=Sophos;i="5.96,274,1665471600"; d="scan'208";a="826755462" Received: from mxu9-mobl1.ccr.corp.intel.com ([10.249.169.98]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Dec 2022 17:33:53 -0800 From: "Min Xu" To: devel@edk2.groups.io Cc: Min M Xu , Erdem Aktas , Gerd Hoffmann , James Bottomley , Jiewen Yao , Tom Lendacky Subject: [PATCH V1 2/3] OvmfPkg/PeilessStartupLib: Update ConstructFwHobList for lazy-accept Date: Mon, 26 Dec 2022 09:33:37 +0800 Message-Id: <20221226013338.1924-3-min.m.xu@intel.com> X-Mailer: git-send-email 2.29.2.windows.2 In-Reply-To: <20221226013338.1924-1-min.m.xu@intel.com> References: <20221226013338.1924-1-min.m.xu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Min M Xu 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 Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Signed-off-by: Min Xu --- 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