Sean Rhodes has uploaded this change for review. ( https://review.coreboot.org/c/edk2/+/58802 )
Change subject: UefiPayloadPkg: Allow below 4GB memory ......................................................................
UefiPayloadPkg: Allow below 4GB memory
Add 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
Signed-off-by: Sean Rhodes sean@starlabs.systems Change-Id: Ic600e08c9d46d0a291b8b119a3c268e432267cdf --- M UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c M UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf M UefiPayloadPkg/UefiPayloadPkg.dec M UefiPayloadPkg/UefiPayloadPkg.dsc 4 files changed, 54 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/edk2 refs/changes/02/58802/1
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c index ae16f25..4aa3e21 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c @@ -5,11 +5,39 @@
**/
+#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 +618,12 @@ // 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..852dd80 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf @@ -89,7 +89,15 @@ 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..2e7af81 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dec +++ b/UefiPayloadPkg/UefiPayloadPkg.dec @@ -76,4 +76,7 @@ # Size of the region used by UEFI in permanent memory gUefiPayloadPkgTokenSpaceGuid.PcdSystemMemoryUefiRegionSize|0x02000000|UINT32|0x00000017
+# Above 4G Memory +gUefiPayloadPkgTokenSpaceGuid.PcdAbove4GMemory|1|UINT32|0x00000018 + gUefiPayloadPkgTokenSpaceGuid.PcdPcdDriverFile|{ 0x57, 0x72, 0xcf, 0x80, 0xab, 0x87, 0xf9, 0x47, 0xa3, 0xfe, 0xD5, 0x0B, 0x76, 0xd8, 0x95, 0x41 }|VOID*|0x00000018 diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayloadPkg.dsc index 856d5ea..a4d07be 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 = FALSE + # # 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_MEMORY) == 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