From nobody Sun Nov 24 13:43:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+86820+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+86820+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1645393283; cv=none; d=zohomail.com; s=zohoarc; b=c6wIfuJdAF2qOnYvcf4TJw54Zoftp0S4fKskwyyCoam672MmvtlTF6t1aWnr5i+Sj3AF9jgQxtrVekn5gwQ/tZH/x/iUuRMqV73n7jOuVgapLl54E3sPvABZNXm5OsNk18+VoFK96Pteue7s8odtWjayzxzNrVwgmCdQWv5HkxY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1645393283; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=uCuzUPPs0lu8q52l6ZVUPnxnbEFAOAT9zWGCM87Vn/w=; b=ixD/UBHayRNO9MV6tyNd9NNWdaFV0+IBWUgvUybQdfUVoRsQVnmzziXRvJcAmuTHl/eXqVGFJmp11jv/Jjix4BNNl0IRxUYJyn3ql3edKToqMOeiWCSYfsIEGxLk7Z48RlMS07xAOChH+uiB+2BtsInVfe8f41kSKmBpP+xI9hw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+86820+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1645393283444364.40723162999643; Sun, 20 Feb 2022 13:41:23 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id xTKlYY1788612xmCOIC6Srvx; Sun, 20 Feb 2022 13:41:23 -0800 X-Received: from smarthost01b.ixn.mail.zen.net.uk (smarthost01b.ixn.mail.zen.net.uk [212.23.1.21]) by mx.groups.io with SMTP id smtpd.web12.3501.1645393281915474052 for ; Sun, 20 Feb 2022 13:41:22 -0800 X-Received: from [217.155.46.38] (helo=sean-StarBook.lan) by smarthost01b.ixn.mail.zen.net.uk with esmtp (Exim 4.90_1) (envelope-from ) id 1nLtxI-0000p8-1i; Sun, 20 Feb 2022 21:41:20 +0000 From: "Sean Rhodes" To: devel@edk2.groups.io Cc: guo.dong@intel.com, Sean Rhodes , Ray Ni , Maurice Ma , Benjamin You Subject: [edk2-devel] [PATCH] UefiPayloadPkg: Add build option for Above 4G Memory Date: Sun, 20 Feb 2022 21:41:18 +0000 Message-Id: <27c3e79bb0a770392e6aa573afd0ebc0a377e133.1645393278.git.sean@starlabs.systems> MIME-Version: 1.0 X-Originating-smarthost01b-IP: [217.155.46.38] Feedback-ID: 217.155.46.38 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sean@starlabs.systems X-Gm-Message-State: BuzyToUsaodArjhnBgzOHImUx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1645393283; bh=zD0dbvJWagi+WFJx6/jNkH8mXNgezv+kr9pfWqHGKEU=; h=Cc:Date:From:Reply-To:Subject:To; b=DQ39cmJJ6Y1/U1wUGCZRq0hzHxiVFlyqwTWGe0P9lzrGxRp7Ufse6qblDjcSas8A1AI 89eX8UP/IKR+yTbvFXE/vS2WAuq+iXdQOEKDjBGSr+XkXQr0bhYsOkMp1BJx+EXMbWehS KlDEdqDwYplYnUCaHmUbpcd1xwgsVRq/enA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1645393285542100001 Content-Type: text/plain; charset="utf-8" When build option ABOVE_4G_MEMORY is set to true, nothing will change and EDKII will use all available memory. Setting it to false will create memory type information HOB in payload entry, so that EDKII will reserve enough memory below 4G for EDKII modules. This option is useful for bootloaders that are not fully 64-bit aware such as Qubes R4.0.4 bootloader, Zorin and Proxmox. Cc: Guo Dong Cc: Ray Ni Cc: Maurice Ma Cc: Benjamin You Signed-off-by: Sean Rhodes --- .../Library/BrotliCustomDecompressLib/brotli | 2 +- .../UefiPayloadEntry/UefiPayloadEntry.c | 39 +++++++++++++++++++ .../UefiPayloadEntry/UefiPayloadEntry.inf | 7 ++++ UefiPayloadPkg/UefiPayloadPkg.dec | 3 ++ UefiPayloadPkg/UefiPayloadPkg.dsc | 3 ++ 5 files changed, 53 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli b/MdeMod= ulePkg/Library/BrotliCustomDecompressLib/brotli index f4153a09f8..666c3280cc 160000 --- a/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli +++ b/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli @@ -1 +1 @@ -Subproject commit f4153a09f87cbb9c826d8fc12c74642bb2d879ea +Subproject commit 666c3280cc11dc433c303d79a83d4ffbdd12cc8d diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c b/UefiPaylo= adPkg/UefiPayloadEntry/UefiPayloadEntry.c index 0fed1e3691..998895e201 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c @@ -5,10 +5,44 @@ =20 **/ =20 +#include #include "UefiPayloadEntry.h" =20 STATIC UINT32 mTopOfLowerUsableDram =3D 0; =20 +EFI_MEMORY_TYPE_INFORMATION mDefaultMemoryTypeInformation[] =3D { + { EfiACPIReclaimMemory, FixedPcdGet32 (PcdMemoryTypeEfiACPIReclaimMemo= ry) }, + { EfiACPIMemoryNVS, FixedPcdGet32 (PcdMemoryTypeEfiACPIMemoryNVS) = }, + { EfiReservedMemoryType, FixedPcdGet32 (PcdMemoryTypeEfiReservedMemoryT= ype) }, + { EfiRuntimeServicesData, FixedPcdGet32 (PcdMemoryTypeEfiRuntimeServices= Data) }, + { EfiRuntimeServicesCode, FixedPcdGet32 (PcdMemoryTypeEfiRuntimeServices= Code) }, + { EfiMaxMemoryType, 0 = } +}; + +/** + Function to reserve memory below 4GB for EDKII Modules. + + This causes the DXE to dispatch everything under 4GB and allows Operati= ng + System's that require EFI_LOADED_IMAGE to be under 4GB to start. + e.g. Xen hypervisor used in Qubes. +**/ +VOID +ForceModulesBelow4G ( + VOID + ) +{ + DEBUG ((DEBUG_INFO, "Building hob to restrict memory resorces to below 4= G.\n")); + + // + // Create Memory Type Information HOB + // + BuildGuidDataHob ( + &gEfiMemoryTypeInformationGuid, + mDefaultMemoryTypeInformation, + sizeof (mDefaultMemoryTypeInformation) + ); +} + /** Callback function to build resource descriptor HOB =20 @@ -438,6 +472,11 @@ _ModuleEntryPoint ( // Build other HOBs required by DXE BuildGenericHob (); =20 + // Create a HOB to make resources for EDKII modules below 4G + if (!FixedPcdGetBool (PcdAbove4GMemory)) { + ForceModulesBelow4G (); + } + // Load the DXE Core Status =3D LoadDxeCore (&DxeCoreEntryPoint); ASSERT_EFI_ERROR (Status); diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf b/UefiPay= loadPkg/UefiPayloadEntry/UefiPayloadEntry.inf index 1847d6481a..2ca47e3bb5 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf @@ -86,8 +86,15 @@ gUefiPayloadPkgTokenSpaceGuid.PcdPayloadFdMemSize gUefiPayloadPkgTokenSpaceGuid.PcdBootloaderParameter gUefiPayloadPkgTokenSpaceGuid.PcdSystemMemoryUefiRegionSize + gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS + gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory + gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiReservedMemoryType + gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData + gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode =20 gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack ## SOMETIM= ES_CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy ## SOMETIM= ES_CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdImageProtectionPolicy ## SOMETIM= ES_CONSUMES =20 + gUefiPayloadPkgTokenSpaceGuid.PcdAbove4GMemory + diff --git a/UefiPayloadPkg/UefiPayloadPkg.dec b/UefiPayloadPkg/UefiPayload= Pkg.dec index 551f0a4915..653a52b5a7 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dec +++ b/UefiPayloadPkg/UefiPayloadPkg.dec @@ -83,6 +83,9 @@ gUefiPayloadPkgTokenSpaceGuid.PcdSystemMemoryUefiRegionSi= ze|0x04000000|UINT32|0x =20 gUefiPayloadPkgTokenSpaceGuid.PcdPcdDriverFile|{ 0x57, 0x72, 0xcf, 0x80, 0= xab, 0x87, 0xf9, 0x47, 0xa3, 0xfe, 0xD5, 0x0B, 0x76, 0xd8, 0x95, 0x41 }|VOI= D*|0x00000018 =20 +# Above 4G Memory +gUefiPayloadPkgTokenSpaceGuid.PcdAbove4GMemory|TRUE|BOOLEAN|0x00000019 + ## FFS filename to find the default variable initial data file. # @Prompt FFS Name of variable initial data file gUefiPayloadPkgTokenSpaceGuid.PcdNvsDataFile |{ 0x1a, 0xf1, 0xb1, 0xae, 0= x42, 0xcc, 0xcf, 0x4e, 0xac, 0x60, 0xdb, 0xab, 0xf6, 0xca, 0x69, 0xe6 }|VOI= D*|0x00000025 diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayload= Pkg.dsc index 1ce96a51c1..dad14be343 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dsc +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc @@ -33,6 +33,7 @@ DEFINE UNIVERSAL_PAYLOAD =3D FALSE DEFINE SECURITY_STUB_ENABLE =3D TRUE DEFINE SMM_SUPPORT =3D FALSE + DEFINE ABOVE_4G_MEMORY =3D TRUE # # SBL: UEFI payload for Slim Bootloader # COREBOOT: UEFI payload for coreboot @@ -399,6 +400,8 @@ gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask | 0x1 !endif =20 + gUefiPayloadPkgTokenSpaceGuid.PcdAbove4GMemory|$(ABOVE_4G_MEMORY) + [PcdsPatchableInModule.X64] gPcAtChipsetPkgTokenSpaceGuid.PcdRtcIndexRegister|$(RTC_INDEX_REGISTER) gPcAtChipsetPkgTokenSpaceGuid.PcdRtcTargetRegister|$(RTC_TARGET_REGISTER) --=20 2.32.0 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#86820): https://edk2.groups.io/g/devel/message/86820 Mute This Topic: https://groups.io/mt/89281420/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-