From nobody Fri May 17 10:34:30 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+86930+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+86930+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1645657178; cv=none; d=zohomail.com; s=zohoarc; b=aEXUBwSs1pP/OSXDIOTRHUPTvr26AXopQnzZYXooa7UunffUK4/BnZPGgZKzCdHngYjNuB2OC0a3qsDmF/8nTA3q4JL8srZpxY6k3BYE8daLkjQfd0UWkqQS8d3YrMVpoh4YEe6EBMUidUqNUxO+eXV/BqVF3p/imSjK8+9csFE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1645657178; 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=Q2/ekEfPxQuy+O8Ysgb6s7KxVGz96vBWJ72+jOUvhQM=; b=X48rAHAedLA9Jfknob8l2FEoHa7NNBTJr9bnFqTlWT16df8qNTvq901/lnU2JWluBqxFBbaqPkQ1Mowk/KvhcCma+uuFrHVfUurQ1zJvAfc7E280SfpN7+3Gu58+QIOIHUtWe0tVcPAZLGpZjBEC/dcXyLa5nWaHJOyIfc/Qauo= 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+86930+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1645657178884758.5010017531627; Wed, 23 Feb 2022 14:59:38 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id vzMJYY1788612xA2aw3GNzym; Wed, 23 Feb 2022 14:59:38 -0800 X-Received: from smarthost01b.sbp.mail.zen.net.uk (smarthost01b.sbp.mail.zen.net.uk [212.23.1.3]) by mx.groups.io with SMTP id smtpd.web11.3098.1645657177185608984 for ; Wed, 23 Feb 2022 14:59:38 -0800 X-Received: from [217.155.46.38] (helo=sean-StarBook.lan) by smarthost01b.sbp.mail.zen.net.uk with esmtp (Exim 4.90_1) (envelope-from ) id 1nN0be-0006GB-Dp; Wed, 23 Feb 2022 22:59:34 +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: Wed, 23 Feb 2022 22:59:33 +0000 Message-Id: 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: FDsE7pWNqR9SSh0LGD5KaFt4x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1645657178; bh=d86VjUY0SBNOW2dpRX+L08ZNwxDeO+m3eDBnMCvw0fU=; h=Cc:Date:From:Reply-To:Subject:To; b=cyh5ROzuPXtVF9dQ1rjsrsu229AAJNn8RJbWWDzoknsfHyiySQJZ8+2oJ0//RseTtid 2JSf3KDMYLJjTX0T7ZnYJ6aeRRBkm/bKplbo9LMdePkXJwNc19PjRR4fYVmvhePndFWDc NqDUo8DZB1dmg2ChG6rYRimaME9TlGLcYz0= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1645657180348100003 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 Reviewed-by: Guo Dong Reviewed-by: Ray Ni --- .../UefiPayloadEntry/UefiPayloadEntry.c | 39 +++++++++++++++++++ .../UefiPayloadEntry/UefiPayloadEntry.inf | 7 ++++ UefiPayloadPkg/UefiPayloadPkg.dec | 3 ++ UefiPayloadPkg/UefiPayloadPkg.dsc | 3 ++ 4 files changed, 52 insertions(+) diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c b/UefiPaylo= adPkg/UefiPayloadEntry/UefiPayloadEntry.c index 0fed1e3691..780348eadf 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 (PcdDispatchModuleAbove4GMemory)) { + 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..c4e4339ede 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.PcdDispatchModuleAbove4GMemory + diff --git a/UefiPayloadPkg/UefiPayloadPkg.dec b/UefiPayloadPkg/UefiPayload= Pkg.dec index 551f0a4915..e9204d1168 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.PcdDispatchModuleAbove4GMemory|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..4fe81a61d6 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.PcdDispatchModuleAbove4GMemory|$(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 (#86930): https://edk2.groups.io/g/devel/message/86930 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-