Matt DeVillier has uploaded this change for review. ( https://review.coreboot.org/c/edk2/+/58801 )
Change subject: UefiPayloadPkg: Add build option to disable Above 4G Decode ......................................................................
UefiPayloadPkg: Add build option to disable Above 4G Decode
Dovetails with coreboot commit 766e481a: "payloads/external/tianocore: Add build argument for 4G Decode"
Signed-off-by: Sean Rhodes sean@starlabs.systems Change-Id: I50e9d9052b344519f46419a01b27b2ca43047943 --- M UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c M UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf M UefiPayloadPkg/UefiPayloadPkg.dec M UefiPayloadPkg/UefiPayloadPkg.dsc 4 files changed, 52 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/edk2 refs/changes/01/58801/1
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c index ae16f25..b3e06df 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c @@ -5,11 +5,40 @@
**/
+#include <Guid/MemoryTypeInformation.h> #include "UefiPayloadEntry.h"
STATIC UINT32 mTopOfLowerUsableDram = 0;
/** + Function to reserve memory below 4GB for EDKII Modules. This causes the + DXE to dispatch everything under 4GB and allows Operating 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 4G.\n")); + EFI_MEMORY_TYPE_INFORMATION mDefaultMemoryTypeInformation[] = { + { EfiACPIReclaimMemory, FixedPcdGet32 (PcdMemoryTypeEfiACPIReclaimMemory) }, + { EfiACPIMemoryNVS, FixedPcdGet32 (PcdMemoryTypeEfiACPIMemoryNVS) }, + { EfiReservedMemoryType, FixedPcdGet32 (PcdMemoryTypeEfiReservedMemoryType) }, + { EfiRuntimeServicesData, FixedPcdGet32 (PcdMemoryTypeEfiRuntimeServicesData) }, + { EfiRuntimeServicesCode, FixedPcdGet32 (PcdMemoryTypeEfiRuntimeServicesCode) }, + { EfiMaxMemoryType, 0 } + }; + // + // Create Memory Type Information HOB + // + BuildGuidDataHob ( + &gEfiMemoryTypeInformationGuid, + mDefaultMemoryTypeInformation, + sizeof(mDefaultMemoryTypeInformation) + ); +} + +/** Callback function to build resource descriptor HOB
This function build a HOB based on the memory map entry info. @@ -590,6 +619,11 @@ // Build other HOBs required by DXE BuildGenericHob ();
+ // Create a HOB to make resources for EDKII modules below 4G + if (FixedPcdGetBool (PcdAbove4GMemory) == FALSE) { + ForceModulesBelow4G (); + } + // Load the DXE Core Status = LoadDxeCore (&DxeCoreEntryPoint); ASSERT_EFI_ERROR (Status); diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf index 8d42925..cf07f0b 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf @@ -88,8 +88,14 @@ gUefiPayloadPkgTokenSpaceGuid.PcdPayloadFdMemSize gUefiPayloadPkgTokenSpaceGuid.PcdPayloadStackTop gUefiPayloadPkgTokenSpaceGuid.PcdSystemMemoryUefiRegionSize + gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS + gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory + gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiReservedMemoryType + gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData + gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode
gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack ## SOMETIMES_CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy ## SOMETIMES_CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdImageProtectionPolicy ## SOMETIMES_CONSUMES
+ gUefiPayloadPkgTokenSpaceGuid.PcdAbove4GMemory diff --git a/UefiPayloadPkg/UefiPayloadPkg.dec b/UefiPayloadPkg/UefiPayloadPkg.dec index 8f0a7e3..cb3375a 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dec +++ b/UefiPayloadPkg/UefiPayloadPkg.dec @@ -77,3 +77,6 @@ gUefiPayloadPkgTokenSpaceGuid.PcdSystemMemoryUefiRegionSize|0x02000000|UINT32|0x00000017
gUefiPayloadPkgTokenSpaceGuid.PcdPcdDriverFile|{ 0x57, 0x72, 0xcf, 0x80, 0xab, 0x87, 0xf9, 0x47, 0xa3, 0xfe, 0xD5, 0x0B, 0x76, 0xd8, 0x95, 0x41 }|VOID*|0x00000018 + +# Above 4G Decode +gUefiPayloadPkgTokenSpaceGuid.PcdAbove4GMemory|1|UINT32|0x00000019 diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayloadPkg.dsc index 856d5ea..abbf4d8 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dsc +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc @@ -30,6 +30,8 @@ DEFINE PS2_KEYBOARD_ENABLE = FALSE DEFINE UNIVERSAL_PAYLOAD = FALSE
+ DEFINE ABOVE_4G_MEMORY = TRUE + # # SBL: UEFI payload for Slim Bootloader # COREBOOT: UEFI payload for coreboot @@ -321,6 +323,13 @@ gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugLoadImageMethod|0x2 !endif
+ # Above 4G Decode +!if $(ABOVE_4G_DECODE) == TRUE + gUefiPayloadPkgTokenSpaceGuid.PcdAbove4GMemory|TRUE +!else + gUefiPayloadPkgTokenSpaceGuid.PcdAbove4GMemory|FALSE +!endif + [PcdsPatchableInModule.common] gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0x31 } gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x7