diff options
author | Sean Rhodes <sean@starlabs.systems> | 2022-02-23 15:59:33 -0700 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2022-03-04 22:17:49 +0000 |
commit | 091b6a11970a447106aadb6538046a85d3f29df5 (patch) | |
tree | 208e535e1936330ba5dab5ff9efa72aa8e5cd6d4 /UefiPayloadPkg/UefiPayloadEntry | |
parent | 949b8a3d97ce1ff01f1f29959a4b33aed742c024 (diff) | |
download | edk2-091b6a11970a447106aadb6538046a85d3f29df5.zip edk2-091b6a11970a447106aadb6538046a85d3f29df5.tar.gz edk2-091b6a11970a447106aadb6538046a85d3f29df5.tar.bz2 |
UefiPayloadPkg: Add build option for Above 4G Memory
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 <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Signed-off-by: Sean Rhodes <sean@starlabs.systems>
Reviewed-by: Guo Dong <guo.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Diffstat (limited to 'UefiPayloadPkg/UefiPayloadEntry')
-rw-r--r-- | UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c | 39 | ||||
-rw-r--r-- | UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf | 7 |
2 files changed, 46 insertions, 0 deletions
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c index 0fed1e3..780348e 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c @@ -5,10 +5,44 @@ **/
+#include <Guid/MemoryTypeInformation.h>
#include "UefiPayloadEntry.h"
STATIC UINT32 mTopOfLowerUsableDram = 0;
+EFI_MEMORY_TYPE_INFORMATION mDefaultMemoryTypeInformation[] = {
+ { EfiACPIReclaimMemory, FixedPcdGet32 (PcdMemoryTypeEfiACPIReclaimMemory) },
+ { EfiACPIMemoryNVS, FixedPcdGet32 (PcdMemoryTypeEfiACPIMemoryNVS) },
+ { EfiReservedMemoryType, FixedPcdGet32 (PcdMemoryTypeEfiReservedMemoryType) },
+ { EfiRuntimeServicesData, FixedPcdGet32 (PcdMemoryTypeEfiRuntimeServicesData) },
+ { EfiRuntimeServicesCode, FixedPcdGet32 (PcdMemoryTypeEfiRuntimeServicesCode) },
+ { EfiMaxMemoryType, 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"));
+
+ //
+ // Create Memory Type Information HOB
+ //
+ BuildGuidDataHob (
+ &gEfiMemoryTypeInformationGuid,
+ mDefaultMemoryTypeInformation,
+ sizeof (mDefaultMemoryTypeInformation)
+ );
+}
+
/**
Callback function to build resource descriptor HOB
@@ -438,6 +472,11 @@ _ModuleEntryPoint ( // Build other HOBs required by DXE
BuildGenericHob ();
+ // Create a HOB to make resources for EDKII modules below 4G
+ if (!FixedPcdGetBool (PcdDispatchModuleAbove4GMemory)) {
+ 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 1847d64..c4e4339 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
gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdImageProtectionPolicy ## SOMETIMES_CONSUMES
+ gUefiPayloadPkgTokenSpaceGuid.PcdDispatchModuleAbove4GMemory
+
|