From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) by mx.groups.io with SMTP id smtpd.web11.10796.1680307089097611358 for ; Fri, 31 Mar 2023 16:58:09 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=YT4Q2mK2; spf=pass (domain: gmail.com, ip: 209.85.160.181, mailfrom: benjamin.doron00@gmail.com) Received: by mail-qt1-f181.google.com with SMTP id n14so23202499qta.10 for ; Fri, 31 Mar 2023 16:58:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680307088; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=07wG0aTaNdFzX2Chvtl0xAdvepBDwcFdld8kmBxlUek=; b=YT4Q2mK2pZ1PQatfUk772xu7SY9k2lNKqiM+wEFJSRq+BgBrfE/5XUt9CfDNIvARVy cSSvqTHlwN0PWFtJUT0uw3/LOjjj8yM9VJvmrcey65RODUmMFn8LKxoJIZZDA73rPusS /MHEVopKqfQ8vnAcoqW39F3mtEAhs9tRNxIsQHaEofR6gsQXXF2CEd2B7+Eq2ovKzZwO 286pC9bE/nNU1yPHyp6N053Reiv29JOlS4vgQawbV8G31RSMFFqzKJhrX+V0fVUNa2jd DIFX5ASv5JijhT7A6cJIpqFiH+0SrPmle3lznfxD87cZgFYeWTeHQfMwiGyAy9ZQLOBy EjEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680307088; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=07wG0aTaNdFzX2Chvtl0xAdvepBDwcFdld8kmBxlUek=; b=odDkh9+prnOZ2eVCnlLlUkXOkYdd1b3M42Q93ZpI4YRKTzIcA+XIRXT6E46pEagnJk Y+YQR3py4NK3wKv1d8nfb6VTBmjQy/mP5+yD6txzrEOHDFGvJD4tvZfFxXmGrXXW+H9x iUEPialKnI/f9/R7yLKyaS3ZSmV+w2kHHyBD+aB5OcJ+Uj8pm/HXDMQ1eBhL2I6bkmjb lW9vcVjgTBTQGiiNGvh3Brt/0bKy5vq79HKtHptLwFy/Twy91YLR0sV8FoxdOXbgISC2 7T5f5gaieLe3BFIODAyLvCmbTrpJEbZI7LGhp2Zr4HVsthZ5M/x2TlsXXT6jPjaraBDw s36w== X-Gm-Message-State: AAQBX9eHty5p1zEfhFK/7z4VetYvAZ8is9VgwbrC9g8f5Q4fYgl69uqc ULr/bgp85jH7oeP0Un8gUW8g2crtisM= X-Google-Smtp-Source: AKy350ar6i4brWvqkqOrCG6ZI1v2/LzoT5RtWZyqw+EFQWi9ijYB9ye40t7NmeeZDjX/GPIO3xmQNg== X-Received: by 2002:a05:622a:130e:b0:3e4:e58c:d322 with SMTP id v14-20020a05622a130e00b003e4e58cd322mr36722002qtk.35.1680307087971; Fri, 31 Mar 2023 16:58:07 -0700 (PDT) Return-Path: Received: from aturtleortwo-benjamindomain.sec.9e.network ([2607:f2c0:e98c:e:d426:a305:cfa6:a510]) by smtp.gmail.com with ESMTPSA id y3-20020a37f603000000b007468733cd1fsm1013243qkj.58.2023.03.31.16.58.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Mar 2023 16:58:07 -0700 (PDT) From: "Benjamin Doron" To: devel@edk2.groups.io Cc: Guo Dong , Ray Ni , Sean Rhodes , James Lu , Gua Guo Subject: [edk2-devel][PATCH v1 1/2] UefiPayloadPkg: Always build MemoryTypeInformation HOB for DXE GCD Date: Fri, 31 Mar 2023 19:57:35 -0400 Message-Id: <629e75402eb21750d9e536aac6c6b30cd346ae47.1680306925.git.benjamin.doron00@gmail.com> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable MemoryType information assists GCD with defragmenting the memory map. When the DXE core starts, GCD adds memory descriptors for the resource descriptors HOBs. This allocates heap space which can be reused later as the bins by memory type. It seems memory allocation prefers low ranges. It seems "below 4G" is an artifact of this heap reuse. However, the memory type information determines the DXE core's `MinimalMemorySizeNeeded`, determining which system memory descriptor HOB may be used by DXE. Furthermore, it's important that the memory type information be correct, for an S4 memory map. Therefore, follow other bootloaders, such as [MinPlatform][1], and do this unconditionally. As of [edk2-stable202011][2], it was. [1]: https://github.com/tianocore/edk2-platforms/blob/b6f96743891be51541184= bf61dd2970c008e2c43/Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInit= Pei/PlatformInitPreMem.c#L164-L201 [2]: https://github.com/tianocore/edk2/blob/edk2-stable202011/UefiPayloadPk= g/BlSupportPei/BlSupportPei.c#L462-L466 Cc: Guo Dong Cc: Ray Ni Cc: Sean Rhodes Cc: James Lu Cc: Gua Guo Signed-off-by: Benjamin Doron --- .../UefiPayloadEntry/UefiPayloadEntry.c | 36 +++++-------------- .../UefiPayloadEntry/UefiPayloadEntry.inf | 2 -- UefiPayloadPkg/UefiPayloadPkg.dec | 3 -- UefiPayloadPkg/UefiPayloadPkg.dsc | 2 -- 4 files changed, 8 insertions(+), 35 deletions(-) diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c b/UefiPaylo= adPkg/UefiPayloadEntry/UefiPayloadEntry.c index 780348eadfa8..030a5baed914 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c @@ -19,30 +19,6 @@ EFI_MEMORY_TYPE_INFORMATION mDefaultMemoryTypeInformati= on[] =3D { { EfiMaxMemoryType, 0 = }=0D };=0D =0D -/**=0D - Function to reserve memory below 4GB for EDKII Modules.=0D -=0D - This causes the DXE to dispatch everything under 4GB and allows Operati= ng=0D - System's that require EFI_LOADED_IMAGE to be under 4GB to start.=0D - e.g. Xen hypervisor used in Qubes.=0D -**/=0D -VOID=0D -ForceModulesBelow4G (=0D - VOID=0D - )=0D -{=0D - DEBUG ((DEBUG_INFO, "Building hob to restrict memory resorces to below 4= G.\n"));=0D -=0D - //=0D - // Create Memory Type Information HOB=0D - //=0D - BuildGuidDataHob (=0D - &gEfiMemoryTypeInformationGuid,=0D - mDefaultMemoryTypeInformation,=0D - sizeof (mDefaultMemoryTypeInformation)=0D - );=0D -}=0D -=0D /**=0D Callback function to build resource descriptor HOB=0D =0D @@ -472,10 +448,14 @@ _ModuleEntryPoint ( // Build other HOBs required by DXE=0D BuildGenericHob ();=0D =0D - // Create a HOB to make resources for EDKII modules below 4G=0D - if (!FixedPcdGetBool (PcdDispatchModuleAbove4GMemory)) {=0D - ForceModulesBelow4G ();=0D - }=0D + //=0D + // Create Memory Type Information HOB=0D + //=0D + BuildGuidDataHob (=0D + &gEfiMemoryTypeInformationGuid,=0D + mDefaultMemoryTypeInformation,=0D + sizeof (mDefaultMemoryTypeInformation)=0D + );=0D =0D // Load the DXE Core=0D Status =3D LoadDxeCore (&DxeCoreEntryPoint);=0D diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf b/UefiPay= loadPkg/UefiPayloadEntry/UefiPayloadEntry.inf index d47e8e76cf4c..e2af8a4b7c1b 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf @@ -96,5 +96,3 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy ## SOMETIM= ES_CONSUMES=0D gEfiMdeModulePkgTokenSpaceGuid.PcdImageProtectionPolicy ## SOMETIM= ES_CONSUMES=0D =0D - gUefiPayloadPkgTokenSpaceGuid.PcdDispatchModuleAbove4GMemory=0D -=0D diff --git a/UefiPayloadPkg/UefiPayloadPkg.dec b/UefiPayloadPkg/UefiPayload= Pkg.dec index 7d61d6eeae6c..2ed73513700d 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dec +++ b/UefiPayloadPkg/UefiPayloadPkg.dec @@ -82,9 +82,6 @@ gUefiPayloadPkgTokenSpaceGuid.PcdSystemMemoryUefiRegionSi= ze|0x04000000|UINT32|0x =0D gUefiPayloadPkgTokenSpaceGuid.PcdPcdDriverFile|{ 0x57, 0x72, 0xcf, 0x80, 0= xab, 0x87, 0xf9, 0x47, 0xa3, 0xfe, 0xD5, 0x0B, 0x76, 0xd8, 0x95, 0x41 }|VOI= D*|0x00000018=0D =0D -# Above 4G Memory=0D -gUefiPayloadPkgTokenSpaceGuid.PcdDispatchModuleAbove4GMemory|TRUE|BOOLEAN|= 0x00000019=0D -=0D # Boot Manager Key=0D gUefiPayloadPkgTokenSpaceGuid.PcdBootManagerEscape|FALSE|BOOLEAN|0x0000002= 0=0D =0D diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayload= Pkg.dsc index bca5d3f335bc..9847f189fff5 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dsc +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc @@ -34,7 +34,6 @@ DEFINE SECURITY_STUB_ENABLE =3D TRUE=0D DEFINE SMM_SUPPORT =3D FALSE=0D DEFINE PLATFORM_BOOT_TIMEOUT =3D 3=0D - DEFINE ABOVE_4G_MEMORY =3D TRUE=0D DEFINE BOOT_MANAGER_ESCAPE =3D FALSE=0D DEFINE ATA_ENABLE =3D TRUE=0D DEFINE SD_ENABLE =3D TRUE=0D @@ -442,7 +441,6 @@ !endif=0D gEfiMdeModulePkgTokenSpaceGuid.PcdSdMmcGenericTimeoutValue|$(SD_MMC_TIME= OUT)=0D =0D - gUefiPayloadPkgTokenSpaceGuid.PcdDispatchModuleAbove4GMemory|$(ABOVE_4G_= MEMORY)=0D gUefiPayloadPkgTokenSpaceGuid.PcdBootManagerEscape|$(BOOT_MANAGER_ESCAPE= )=0D =0D gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength|1800000=0D --=20 2.39.1