* [edk2-devel][PATCH v1 1/2] UefiPayloadPkg: Always build MemoryTypeInformation HOB for DXE GCD
@ 2023-03-31 23:57 Benjamin Doron
2023-03-31 23:57 ` [edk2-devel][PATCH v1 2/2] UefiPayloadPkg: Update default memory type information for S4 Benjamin Doron
2023-04-03 7:31 ` [edk2-devel][PATCH v1 1/2] UefiPayloadPkg: Always build MemoryTypeInformation HOB for DXE GCD Sean Rhodes
0 siblings, 2 replies; 5+ messages in thread
From: Benjamin Doron @ 2023-03-31 23:57 UTC (permalink / raw)
To: devel; +Cc: Guo Dong, Ray Ni, Sean Rhodes, James Lu, Gua Guo
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/b6f96743891be51541184bf61dd2970c008e2c43/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>
Signed-off-by: Benjamin Doron <benjamin.doron00@gmail.com>
---
.../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/UefiPayloadPkg/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 mDefaultMemoryTypeInformation[] = {
{ 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
@@ -472,10 +448,14 @@ _ModuleEntryPoint (
// Build other HOBs required by DXE
BuildGenericHob ();
- // Create a HOB to make resources for EDKII modules below 4G
- if (!FixedPcdGetBool (PcdDispatchModuleAbove4GMemory)) {
- ForceModulesBelow4G ();
- }
+ //
+ // Create Memory Type Information HOB
+ //
+ BuildGuidDataHob (
+ &gEfiMemoryTypeInformationGuid,
+ mDefaultMemoryTypeInformation,
+ sizeof (mDefaultMemoryTypeInformation)
+ );
// Load the DXE Core
Status = LoadDxeCore (&DxeCoreEntryPoint);
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
index d47e8e76cf4c..e2af8a4b7c1b 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
@@ -96,5 +96,3 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdImageProtectionPolicy ## SOMETIMES_CONSUMES
- gUefiPayloadPkgTokenSpaceGuid.PcdDispatchModuleAbove4GMemory
-
diff --git a/UefiPayloadPkg/UefiPayloadPkg.dec b/UefiPayloadPkg/UefiPayloadPkg.dec
index 7d61d6eeae6c..2ed73513700d 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dec
+++ b/UefiPayloadPkg/UefiPayloadPkg.dec
@@ -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
-# Above 4G Memory
-gUefiPayloadPkgTokenSpaceGuid.PcdDispatchModuleAbove4GMemory|TRUE|BOOLEAN|0x00000019
-
# Boot Manager Key
gUefiPayloadPkgTokenSpaceGuid.PcdBootManagerEscape|FALSE|BOOLEAN|0x00000020
diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayloadPkg.dsc
index bca5d3f335bc..9847f189fff5 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -34,7 +34,6 @@
DEFINE SECURITY_STUB_ENABLE = TRUE
DEFINE SMM_SUPPORT = FALSE
DEFINE PLATFORM_BOOT_TIMEOUT = 3
- DEFINE ABOVE_4G_MEMORY = TRUE
DEFINE BOOT_MANAGER_ESCAPE = FALSE
DEFINE ATA_ENABLE = TRUE
DEFINE SD_ENABLE = TRUE
@@ -442,7 +441,6 @@
!endif
gEfiMdeModulePkgTokenSpaceGuid.PcdSdMmcGenericTimeoutValue|$(SD_MMC_TIMEOUT)
- gUefiPayloadPkgTokenSpaceGuid.PcdDispatchModuleAbove4GMemory|$(ABOVE_4G_MEMORY)
gUefiPayloadPkgTokenSpaceGuid.PcdBootManagerEscape|$(BOOT_MANAGER_ESCAPE)
gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength|1800000
--
2.39.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [edk2-devel][PATCH v1 2/2] UefiPayloadPkg: Update default memory type information for S4
2023-03-31 23:57 [edk2-devel][PATCH v1 1/2] UefiPayloadPkg: Always build MemoryTypeInformation HOB for DXE GCD Benjamin Doron
@ 2023-03-31 23:57 ` Benjamin Doron
2023-04-03 7:32 ` Sean Rhodes
2023-04-03 7:31 ` [edk2-devel][PATCH v1 1/2] UefiPayloadPkg: Always build MemoryTypeInformation HOB for DXE GCD Sean Rhodes
1 sibling, 1 reply; 5+ messages in thread
From: Benjamin Doron @ 2023-03-31 23:57 UTC (permalink / raw)
To: devel; +Cc: Guo Dong, Ray Ni, Sean Rhodes, James Lu, Gua Guo
Copied values from OVMF, these are sufficient for a debug build.
Now that those are improved, remove
PcdResetOnMemoryTypeInformationChange override. If the memory map must
change, reset system so that an S4 resume will succeed.
Requires testing a hibernate resume to OS.
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>
Signed-off-by: Benjamin Doron <benjamin.doron00@gmail.com>
---
UefiPayloadPkg/UefiPayloadPkg.dec | 6 +++---
UefiPayloadPkg/UefiPayloadPkg.dsc | 1 -
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/UefiPayloadPkg/UefiPayloadPkg.dec b/UefiPayloadPkg/UefiPayloadPkg.dec
index 2ed73513700d..a5004a2b616e 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dec
+++ b/UefiPayloadPkg/UefiPayloadPkg.dec
@@ -71,11 +71,11 @@ gUefiPayloadPkgTokenSpaceGuid.PcdBootloaderParameter|0|UINT64|0x10000004
gUefiPayloadPkgTokenSpaceGuid.PcdShellFile|{ 0x83, 0xA5, 0x04, 0x7C, 0x3E, 0x9E, 0x1c, 0x4f, 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1 }|VOID*|0x10000005
## Used to help reduce fragmentation in the EFI memory map
-gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory|0x08|UINT32|0x10000012
+gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory|0x12|UINT32|0x10000012
gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS|0x04|UINT32|0x10000013
gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiReservedMemoryType|0x04|UINT32|0x00000014
-gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData|0xC0|UINT32|0x00000015
-gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode|0x80|UINT32|0x00000016
+gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData|0x100|UINT32|0x00000015
+gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode|0x100|UINT32|0x00000016
# Size of the region used by UEFI in permanent memory
gUefiPayloadPkgTokenSpaceGuid.PcdSystemMemoryUefiRegionSize|0x04000000|UINT32|0x00000017
diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayloadPkg.dsc
index 9847f189fff5..ba6cc7e1a4d8 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -539,7 +539,6 @@
!else
gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial|FALSE
!endif
- gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0
--
2.39.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [edk2-devel][PATCH v1 2/2] UefiPayloadPkg: Update default memory type information for S4
2023-03-31 23:57 ` [edk2-devel][PATCH v1 2/2] UefiPayloadPkg: Update default memory type information for S4 Benjamin Doron
@ 2023-04-03 7:32 ` Sean Rhodes
2023-04-03 7:36 ` Sean Rhodes
0 siblings, 1 reply; 5+ messages in thread
From: Sean Rhodes @ 2023-04-03 7:32 UTC (permalink / raw)
To: Benjamin Doron; +Cc: devel, Guo Dong, Ray Ni, James Lu, Gua Guo
[-- Attachment #1: Type: text/plain, Size: 2872 bytes --]
Reviewed-by: Sean Rhodes <sean@starlabs.systems>
On Sat, 1 Apr 2023 at 00:58, Benjamin Doron <benjamin.doron00@gmail.com>
wrote:
> Copied values from OVMF, these are sufficient for a debug build.
>
> Now that those are improved, remove
> PcdResetOnMemoryTypeInformationChange override. If the memory map must
> change, reset system so that an S4 resume will succeed.
>
> Requires testing a hibernate resume to OS.
>
> 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>
> Signed-off-by: Benjamin Doron <benjamin.doron00@gmail.com>
> ---
> UefiPayloadPkg/UefiPayloadPkg.dec | 6 +++---
> UefiPayloadPkg/UefiPayloadPkg.dsc | 1 -
> 2 files changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/UefiPayloadPkg/UefiPayloadPkg.dec
> b/UefiPayloadPkg/UefiPayloadPkg.dec
> index 2ed73513700d..a5004a2b616e 100644
> --- a/UefiPayloadPkg/UefiPayloadPkg.dec
> +++ b/UefiPayloadPkg/UefiPayloadPkg.dec
> @@ -71,11 +71,11 @@
> gUefiPayloadPkgTokenSpaceGuid.PcdBootloaderParameter|0|UINT64|0x10000004
> gUefiPayloadPkgTokenSpaceGuid.PcdShellFile|{ 0x83, 0xA5, 0x04, 0x7C,
> 0x3E, 0x9E, 0x1c, 0x4f, 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1
> }|VOID*|0x10000005
>
> ## Used to help reduce fragmentation in the EFI memory map
>
> -gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory|0x08|UINT32|0x10000012
>
> +gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory|0x12|UINT32|0x10000012
>
> gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS|0x04|UINT32|0x10000013
>
> gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiReservedMemoryType|0x04|UINT32|0x00000014
>
> -gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData|0xC0|UINT32|0x00000015
>
> -gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode|0x80|UINT32|0x00000016
>
> +gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData|0x100|UINT32|0x00000015
>
> +gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode|0x100|UINT32|0x00000016
>
> # Size of the region used by UEFI in permanent memory
>
> gUefiPayloadPkgTokenSpaceGuid.PcdSystemMemoryUefiRegionSize|0x04000000|UINT32|0x00000017
> diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc
> b/UefiPayloadPkg/UefiPayloadPkg.dsc
> index 9847f189fff5..ba6cc7e1a4d8 100644
> --- a/UefiPayloadPkg/UefiPayloadPkg.dsc
> +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
> @@ -539,7 +539,6 @@
> !else
> gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial|FALSE
> !endif
> -
> gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
> gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0
> gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0
> gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0
> --
> 2.39.1
>
>
[-- Attachment #2: Type: text/html, Size: 3722 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [edk2-devel][PATCH v1 2/2] UefiPayloadPkg: Update default memory type information for S4
2023-04-03 7:32 ` Sean Rhodes
@ 2023-04-03 7:36 ` Sean Rhodes
0 siblings, 0 replies; 5+ messages in thread
From: Sean Rhodes @ 2023-04-03 7:36 UTC (permalink / raw)
To: Benjamin Doron; +Cc: devel, Guo Dong, Ray Ni, James Lu, Gua Guo
[-- Attachment #1: Type: text/plain, Size: 3081 bytes --]
PR created at https://github.com/tianocore/edk2/pull/4231
On Mon, 3 Apr 2023 at 08:32, Sean Rhodes <sean@starlabs.systems> wrote:
> Reviewed-by: Sean Rhodes <sean@starlabs.systems>
>
> On Sat, 1 Apr 2023 at 00:58, Benjamin Doron <benjamin.doron00@gmail.com>
> wrote:
>
>> Copied values from OVMF, these are sufficient for a debug build.
>>
>> Now that those are improved, remove
>> PcdResetOnMemoryTypeInformationChange override. If the memory map must
>> change, reset system so that an S4 resume will succeed.
>>
>> Requires testing a hibernate resume to OS.
>>
>> 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>
>> Signed-off-by: Benjamin Doron <benjamin.doron00@gmail.com>
>> ---
>> UefiPayloadPkg/UefiPayloadPkg.dec | 6 +++---
>> UefiPayloadPkg/UefiPayloadPkg.dsc | 1 -
>> 2 files changed, 3 insertions(+), 4 deletions(-)
>>
>> diff --git a/UefiPayloadPkg/UefiPayloadPkg.dec
>> b/UefiPayloadPkg/UefiPayloadPkg.dec
>> index 2ed73513700d..a5004a2b616e 100644
>> --- a/UefiPayloadPkg/UefiPayloadPkg.dec
>> +++ b/UefiPayloadPkg/UefiPayloadPkg.dec
>> @@ -71,11 +71,11 @@
>> gUefiPayloadPkgTokenSpaceGuid.PcdBootloaderParameter|0|UINT64|0x10000004
>> gUefiPayloadPkgTokenSpaceGuid.PcdShellFile|{ 0x83, 0xA5, 0x04, 0x7C,
>> 0x3E, 0x9E, 0x1c, 0x4f, 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1
>> }|VOID*|0x10000005
>>
>> ## Used to help reduce fragmentation in the EFI memory map
>>
>> -gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory|0x08|UINT32|0x10000012
>>
>> +gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory|0x12|UINT32|0x10000012
>>
>> gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS|0x04|UINT32|0x10000013
>>
>> gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiReservedMemoryType|0x04|UINT32|0x00000014
>>
>> -gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData|0xC0|UINT32|0x00000015
>>
>> -gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode|0x80|UINT32|0x00000016
>>
>> +gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData|0x100|UINT32|0x00000015
>>
>> +gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode|0x100|UINT32|0x00000016
>>
>> # Size of the region used by UEFI in permanent memory
>>
>> gUefiPayloadPkgTokenSpaceGuid.PcdSystemMemoryUefiRegionSize|0x04000000|UINT32|0x00000017
>> diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc
>> b/UefiPayloadPkg/UefiPayloadPkg.dsc
>> index 9847f189fff5..ba6cc7e1a4d8 100644
>> --- a/UefiPayloadPkg/UefiPayloadPkg.dsc
>> +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
>> @@ -539,7 +539,6 @@
>> !else
>> gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial|FALSE
>> !endif
>> -
>> gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
>> gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0
>> gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0
>> gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0
>> --
>> 2.39.1
>>
>>
[-- Attachment #2: Type: text/html, Size: 4256 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [edk2-devel][PATCH v1 1/2] UefiPayloadPkg: Always build MemoryTypeInformation HOB for DXE GCD
2023-03-31 23:57 [edk2-devel][PATCH v1 1/2] UefiPayloadPkg: Always build MemoryTypeInformation HOB for DXE GCD Benjamin Doron
2023-03-31 23:57 ` [edk2-devel][PATCH v1 2/2] UefiPayloadPkg: Update default memory type information for S4 Benjamin Doron
@ 2023-04-03 7:31 ` Sean Rhodes
1 sibling, 0 replies; 5+ messages in thread
From: Sean Rhodes @ 2023-04-03 7:31 UTC (permalink / raw)
To: Benjamin Doron; +Cc: devel, Guo Dong, Ray Ni, James Lu, Gua Guo
[-- Attachment #1: Type: text/plain, Size: 5653 bytes --]
Reviewed-by: Sean Rhodes <sean@starlabs.systems>
On Sat, 1 Apr 2023 at 00:58, Benjamin Doron <benjamin.doron00@gmail.com>
wrote:
> 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/b6f96743891be51541184bf61dd2970c008e2c43/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>
> Signed-off-by: Benjamin Doron <benjamin.doron00@gmail.com>
> ---
> .../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/UefiPayloadPkg/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
> mDefaultMemoryTypeInformation[] = {
> { 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
>
> @@ -472,10 +448,14 @@ _ModuleEntryPoint (
> // Build other HOBs required by DXE
> BuildGenericHob ();
>
> - // Create a HOB to make resources for EDKII modules below 4G
> - if (!FixedPcdGetBool (PcdDispatchModuleAbove4GMemory)) {
> - ForceModulesBelow4G ();
> - }
> + //
> + // Create Memory Type Information HOB
> + //
> + BuildGuidDataHob (
> + &gEfiMemoryTypeInformationGuid,
> + mDefaultMemoryTypeInformation,
> + sizeof (mDefaultMemoryTypeInformation)
> + );
>
> // Load the DXE Core
> Status = LoadDxeCore (&DxeCoreEntryPoint);
> diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
> b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
> index d47e8e76cf4c..e2af8a4b7c1b 100644
> --- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
> +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
> @@ -96,5 +96,3 @@
> gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy ##
> SOMETIMES_CONSUMES
> gEfiMdeModulePkgTokenSpaceGuid.PcdImageProtectionPolicy ##
> SOMETIMES_CONSUMES
>
> - gUefiPayloadPkgTokenSpaceGuid.PcdDispatchModuleAbove4GMemory
> -
> diff --git a/UefiPayloadPkg/UefiPayloadPkg.dec
> b/UefiPayloadPkg/UefiPayloadPkg.dec
> index 7d61d6eeae6c..2ed73513700d 100644
> --- a/UefiPayloadPkg/UefiPayloadPkg.dec
> +++ b/UefiPayloadPkg/UefiPayloadPkg.dec
> @@ -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
>
> -# Above 4G Memory
>
> -gUefiPayloadPkgTokenSpaceGuid.PcdDispatchModuleAbove4GMemory|TRUE|BOOLEAN|0x00000019
> -
> # Boot Manager Key
>
> gUefiPayloadPkgTokenSpaceGuid.PcdBootManagerEscape|FALSE|BOOLEAN|0x00000020
>
> diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc
> b/UefiPayloadPkg/UefiPayloadPkg.dsc
> index bca5d3f335bc..9847f189fff5 100644
> --- a/UefiPayloadPkg/UefiPayloadPkg.dsc
> +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
> @@ -34,7 +34,6 @@
> DEFINE SECURITY_STUB_ENABLE = TRUE
> DEFINE SMM_SUPPORT = FALSE
> DEFINE PLATFORM_BOOT_TIMEOUT = 3
> - DEFINE ABOVE_4G_MEMORY = TRUE
> DEFINE BOOT_MANAGER_ESCAPE = FALSE
> DEFINE ATA_ENABLE = TRUE
> DEFINE SD_ENABLE = TRUE
> @@ -442,7 +441,6 @@
> !endif
>
> gEfiMdeModulePkgTokenSpaceGuid.PcdSdMmcGenericTimeoutValue|$(SD_MMC_TIMEOUT)
>
> -
> gUefiPayloadPkgTokenSpaceGuid.PcdDispatchModuleAbove4GMemory|$(ABOVE_4G_MEMORY)
>
> gUefiPayloadPkgTokenSpaceGuid.PcdBootManagerEscape|$(BOOT_MANAGER_ESCAPE)
>
> gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength|1800000
> --
> 2.39.1
>
>
[-- Attachment #2: Type: text/html, Size: 7388 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-04-03 7:36 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-31 23:57 [edk2-devel][PATCH v1 1/2] UefiPayloadPkg: Always build MemoryTypeInformation HOB for DXE GCD Benjamin Doron
2023-03-31 23:57 ` [edk2-devel][PATCH v1 2/2] UefiPayloadPkg: Update default memory type information for S4 Benjamin Doron
2023-04-03 7:32 ` Sean Rhodes
2023-04-03 7:36 ` Sean Rhodes
2023-04-03 7:31 ` [edk2-devel][PATCH v1 1/2] UefiPayloadPkg: Always build MemoryTypeInformation HOB for DXE GCD Sean Rhodes
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox