mirror of https://github.com/acidanthera/audk.git
UefiPayloadPkg: Always build MemoryTypeInformation HOB for DXE GCD
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]: b6f9674389/Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInitPei/PlatformInitPreMem.c (L164-L201)
[2]: https://github.com/tianocore/edk2/blob/edk2-stable202011/UefiPayloadPkg/BlSupportPei/BlSupportPei.c#L462-L466
Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Cc: James Lu <james.lu@intel.com>
Cc: Gua Guo <gua.guo@intel.com>
Reviewed-by: Sean Rhodes <sean@starlabs.systems>
Signed-off-by: Benjamin Doron <benjamin.doron00@gmail.com>
This commit is contained in:
parent
b991aec050
commit
dc5f2905eb
|
@ -19,30 +19,6 @@ EFI_MEMORY_TYPE_INFORMATION mDefaultMemoryTypeInformation[] = {
|
||||||
{ EfiMaxMemoryType, 0 }
|
{ 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
|
Callback function to build resource descriptor HOB
|
||||||
|
|
||||||
|
@ -472,10 +448,14 @@ _ModuleEntryPoint (
|
||||||
// Build other HOBs required by DXE
|
// Build other HOBs required by DXE
|
||||||
BuildGenericHob ();
|
BuildGenericHob ();
|
||||||
|
|
||||||
// Create a HOB to make resources for EDKII modules below 4G
|
//
|
||||||
if (!FixedPcdGetBool (PcdDispatchModuleAbove4GMemory)) {
|
// Create Memory Type Information HOB
|
||||||
ForceModulesBelow4G ();
|
//
|
||||||
}
|
BuildGuidDataHob (
|
||||||
|
&gEfiMemoryTypeInformationGuid,
|
||||||
|
mDefaultMemoryTypeInformation,
|
||||||
|
sizeof (mDefaultMemoryTypeInformation)
|
||||||
|
);
|
||||||
|
|
||||||
// Load the DXE Core
|
// Load the DXE Core
|
||||||
Status = LoadDxeCore (&DxeCoreEntryPoint);
|
Status = LoadDxeCore (&DxeCoreEntryPoint);
|
||||||
|
|
|
@ -96,5 +96,3 @@
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy ## SOMETIMES_CONSUMES
|
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy ## SOMETIMES_CONSUMES
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdImageProtectionPolicy ## SOMETIMES_CONSUMES
|
gEfiMdeModulePkgTokenSpaceGuid.PcdImageProtectionPolicy ## SOMETIMES_CONSUMES
|
||||||
|
|
||||||
gUefiPayloadPkgTokenSpaceGuid.PcdDispatchModuleAbove4GMemory
|
|
||||||
|
|
||||||
|
|
|
@ -82,9 +82,6 @@ gUefiPayloadPkgTokenSpaceGuid.PcdSystemMemoryUefiRegionSize|0x04000000|UINT32|0x
|
||||||
|
|
||||||
gUefiPayloadPkgTokenSpaceGuid.PcdPcdDriverFile|{ 0x57, 0x72, 0xcf, 0x80, 0xab, 0x87, 0xf9, 0x47, 0xa3, 0xfe, 0xD5, 0x0B, 0x76, 0xd8, 0x95, 0x41 }|VOID*|0x00000018
|
gUefiPayloadPkgTokenSpaceGuid.PcdPcdDriverFile|{ 0x57, 0x72, 0xcf, 0x80, 0xab, 0x87, 0xf9, 0x47, 0xa3, 0xfe, 0xD5, 0x0B, 0x76, 0xd8, 0x95, 0x41 }|VOID*|0x00000018
|
||||||
|
|
||||||
# Above 4G Memory
|
|
||||||
gUefiPayloadPkgTokenSpaceGuid.PcdDispatchModuleAbove4GMemory|TRUE|BOOLEAN|0x00000019
|
|
||||||
|
|
||||||
# Boot Manager Key
|
# Boot Manager Key
|
||||||
gUefiPayloadPkgTokenSpaceGuid.PcdBootManagerEscape|FALSE|BOOLEAN|0x00000020
|
gUefiPayloadPkgTokenSpaceGuid.PcdBootManagerEscape|FALSE|BOOLEAN|0x00000020
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
DEFINE SECURITY_STUB_ENABLE = TRUE
|
DEFINE SECURITY_STUB_ENABLE = TRUE
|
||||||
DEFINE SMM_SUPPORT = FALSE
|
DEFINE SMM_SUPPORT = FALSE
|
||||||
DEFINE PLATFORM_BOOT_TIMEOUT = 3
|
DEFINE PLATFORM_BOOT_TIMEOUT = 3
|
||||||
DEFINE ABOVE_4G_MEMORY = TRUE
|
|
||||||
DEFINE BOOT_MANAGER_ESCAPE = FALSE
|
DEFINE BOOT_MANAGER_ESCAPE = FALSE
|
||||||
DEFINE ATA_ENABLE = TRUE
|
DEFINE ATA_ENABLE = TRUE
|
||||||
DEFINE SD_ENABLE = TRUE
|
DEFINE SD_ENABLE = TRUE
|
||||||
|
@ -442,7 +441,6 @@
|
||||||
!endif
|
!endif
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdSdMmcGenericTimeoutValue|$(SD_MMC_TIMEOUT)
|
gEfiMdeModulePkgTokenSpaceGuid.PcdSdMmcGenericTimeoutValue|$(SD_MMC_TIMEOUT)
|
||||||
|
|
||||||
gUefiPayloadPkgTokenSpaceGuid.PcdDispatchModuleAbove4GMemory|$(ABOVE_4G_MEMORY)
|
|
||||||
gUefiPayloadPkgTokenSpaceGuid.PcdBootManagerEscape|$(BOOT_MANAGER_ESCAPE)
|
gUefiPayloadPkgTokenSpaceGuid.PcdBootManagerEscape|$(BOOT_MANAGER_ESCAPE)
|
||||||
|
|
||||||
gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength|1800000
|
gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength|1800000
|
||||||
|
|
Loading…
Reference in New Issue