* [PATCH 32/32] UefiPayloadPkg: Add build option for Above 4G Memory [not found] <9dd14fc91c174eae87fd122c7ac70073a363527f.1643403631.git.sean@starlabs.systems> @ 2022-01-28 21:04 ` sean 2022-01-29 0:13 ` [edk2-devel] " Guo Dong 0 siblings, 1 reply; 6+ messages in thread From: sean @ 2022-01-28 21:04 UTC (permalink / raw) To: devel; +Cc: Sean Rhodes 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. Signed-off-by: Sean Rhodes <sean@starlabs.systems> --- .../UefiPayloadEntry/UefiPayloadEntry.c | 41 +++++++++++++++++++ .../UefiPayloadEntry/UefiPayloadEntry.inf | 7 ++++ UefiPayloadPkg/UefiPayloadPkg.dec | 3 ++ UefiPayloadPkg/UefiPayloadPkg.dsc | 7 ++++ 4 files changed, 58 insertions(+) diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c index 0fed1e3691..e343956a1a 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c @@ -5,10 +5,46 @@ **/ +#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 + + @param None + + @retval None +**/ +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 @@ -438,6 +474,11 @@ _ModuleEntryPoint ( // 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 1847d6481a..2ca47e3bb5 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.PcdAbove4GMemory + diff --git a/UefiPayloadPkg/UefiPayloadPkg.dec b/UefiPayloadPkg/UefiPayloadPkg.dec index 551f0a4915..3915a0579b 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dec +++ b/UefiPayloadPkg/UefiPayloadPkg.dec @@ -83,6 +83,9 @@ 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.PcdAbove4GMemory|1|UINT32|0x00000019 + ## FFS filename to find the default variable initial data file. # @Prompt FFS Name of variable initial data file gUefiPayloadPkgTokenSpaceGuid.PcdNvsDataFile |{ 0x1a, 0xf1, 0xb1, 0xae, 0x42, 0xcc, 0xcf, 0x4e, 0xac, 0x60, 0xdb, 0xab, 0xf6, 0xca, 0x69, 0xe6 }|VOID*|0x00000025 diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayloadPkg.dsc index 1ce96a51c1..9fda5f652e 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dsc +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc @@ -33,6 +33,7 @@ DEFINE UNIVERSAL_PAYLOAD = FALSE DEFINE SECURITY_STUB_ENABLE = TRUE DEFINE SMM_SUPPORT = FALSE + DEFINE ABOVE_4G_MEMORY = TRUE # # SBL: UEFI payload for Slim Bootloader # COREBOOT: UEFI payload for coreboot @@ -399,6 +400,12 @@ gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask | 0x1 !endif +!if $(ABOVE_4G_MEMORY) == TRUE + gUefiPayloadPkgTokenSpaceGuid.PcdAbove4GMemory|TRUE +!else + gUefiPayloadPkgTokenSpaceGuid.PcdAbove4GMemory|FALSE +!endif + [PcdsPatchableInModule.X64] gPcAtChipsetPkgTokenSpaceGuid.PcdRtcIndexRegister|$(RTC_INDEX_REGISTER) gPcAtChipsetPkgTokenSpaceGuid.PcdRtcTargetRegister|$(RTC_TARGET_REGISTER) -- 2.32.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [edk2-devel] [PATCH 32/32] UefiPayloadPkg: Add build option for Above 4G Memory 2022-01-28 21:04 ` [PATCH 32/32] UefiPayloadPkg: Add build option for Above 4G Memory sean @ 2022-01-29 0:13 ` Guo Dong 2022-01-29 8:46 ` Sean Rhodes 0 siblings, 1 reply; 6+ messages in thread From: Guo Dong @ 2022-01-29 0:13 UTC (permalink / raw) To: devel@edk2.groups.io, Rhodes, Sean Here are few comments: +gUefiPayloadPkgTokenSpaceGuid.PcdAbove4GMemory|1|UINT32|0x00000019 Based on usage, better change to BOOLEAN instead of UINT32 as below gUefiPayloadPkgTokenSpaceGuid.PcdAbove4GMemory|TRUE|BOOLEAN|0x00000019 +!if $(ABOVE_4G_MEMORY) == TRUE + gUefiPayloadPkgTokenSpaceGuid.PcdAbove4GMemory|TRUE +!else + gUefiPayloadPkgTokenSpaceGuid.PcdAbove4GMemory|FALSE +!endif Simply change to below. gUefiPayloadPkgTokenSpaceGuid.PcdAbove4GMemory|$(ABOVE_4G_MEMORY) + if (FixedPcdGetBool (PcdAbove4GMemory) == FALSE) { + ForceModulesBelow4G (); + } Following EDK2 coding style, BOOLEAN type should not compare with BOOLEAN const. Change to + if (!FixedPcdGetBool (PcdAbove4GMemory) ) { + ForceModulesBelow4G (); + } Thanks, Guo -----Original Message----- From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Sean Rhodes Sent: Friday, January 28, 2022 2:04 PM To: devel@edk2.groups.io Cc: Rhodes, Sean <sean@starlabs.systems> Subject: [edk2-devel] [PATCH 32/32] 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. Signed-off-by: Sean Rhodes <sean@starlabs.systems> --- .../UefiPayloadEntry/UefiPayloadEntry.c | 41 +++++++++++++++++++ .../UefiPayloadEntry/UefiPayloadEntry.inf | 7 ++++ UefiPayloadPkg/UefiPayloadPkg.dec | 3 ++ UefiPayloadPkg/UefiPayloadPkg.dsc | 7 ++++ 4 files changed, 58 insertions(+) diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c index 0fed1e3691..e343956a1a 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c @@ -5,10 +5,46 @@ **/ +#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++ @param None++ @retval None+**/+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 @@ -438,6 +474,11 @@ _ModuleEntryPoint ( // 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 1847d6481a..2ca47e3bb5 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.PcdAbove4GMemory+diff --git a/UefiPayloadPkg/UefiPayloadPkg.dec b/UefiPayloadPkg/UefiPayloadPkg.dec index 551f0a4915..3915a0579b 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dec +++ b/UefiPayloadPkg/UefiPayloadPkg.dec @@ -83,6 +83,9 @@ 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.PcdAbove4GMemory|1|UINT32|0x00000019+ ## FFS filename to find the default variable initial data file. # @Prompt FFS Name of variable initial data file gUefiPayloadPkgTokenSpaceGuid.PcdNvsDataFile |{ 0x1a, 0xf1, 0xb1, 0xae, 0x42, 0xcc, 0xcf, 0x4e, 0xac, 0x60, 0xdb, 0xab, 0xf6, 0xca, 0x69, 0xe6 }|VOID*|0x00000025diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayloadPkg.dsc index 1ce96a51c1..9fda5f652e 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dsc +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc @@ -33,6 +33,7 @@ DEFINE UNIVERSAL_PAYLOAD = FALSE DEFINE SECURITY_STUB_ENABLE = TRUE DEFINE SMM_SUPPORT = FALSE+ DEFINE ABOVE_4G_MEMORY = TRUE # # SBL: UEFI payload for Slim Bootloader # COREBOOT: UEFI payload for coreboot@@ -399,6 +400,12 @@ gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask | 0x1 !endif +!if $(ABOVE_4G_MEMORY) == TRUE+ gUefiPayloadPkgTokenSpaceGuid.PcdAbove4GMemory|TRUE+!else+ gUefiPayloadPkgTokenSpaceGuid.PcdAbove4GMemory|FALSE+!endif+ [PcdsPatchableInModule.X64] gPcAtChipsetPkgTokenSpaceGuid.PcdRtcIndexRegister|$(RTC_INDEX_REGISTER) gPcAtChipsetPkgTokenSpaceGuid.PcdRtcTargetRegister|$(RTC_TARGET_REGISTER)-- 2.32.0 -=-=-=-=-=-= Groups.io Links: You receive all messages sent to this group. View/Reply Online (#86184): https://edk2.groups.io/g/devel/message/86184 Mute This Topic: https://groups.io/mt/88757870/1781375 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [guo.dong@intel.com] -=-=-=-=-=-= ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [edk2-devel] [PATCH 32/32] UefiPayloadPkg: Add build option for Above 4G Memory 2022-01-29 0:13 ` [edk2-devel] " Guo Dong @ 2022-01-29 8:46 ` Sean Rhodes 2022-02-01 22:53 ` Guo Dong 0 siblings, 1 reply; 6+ messages in thread From: Sean Rhodes @ 2022-01-29 8:46 UTC (permalink / raw) To: Guo Dong, devel [-- Attachment #1: Type: text/plain, Size: 5848 bytes --] Thanks :) I've updated the PR. Do I need to resend the new patch again? [PATCH 33/33] 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. Signed-off-by: Sean Rhodes <sean@starlabs.systems> --- .../UefiPayloadEntry/UefiPayloadEntry.c | 41 +++++++++++++++++++ .../UefiPayloadEntry/UefiPayloadEntry.inf | 7 ++++ UefiPayloadPkg/UefiPayloadPkg.dec | 3 ++ UefiPayloadPkg/UefiPayloadPkg.dsc | 3 ++ 4 files changed, 54 insertions(+) diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c index 0fed1e3691..d5c18dc343 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c @@ -5,10 +5,46 @@ **/ +#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 + + @param None + + @retval None +**/ +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 @@ -438,6 +474,11 @@ _ModuleEntryPoint ( // Build other HOBs required by DXE BuildGenericHob (); + // Create a HOB to make resources for EDKII modules below 4G + if (!FixedPcdGetBool (PcdAbove4GMemory) ) { + 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 1847d6481a..2ca47e3bb5 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.PcdAbove4GMemory + diff --git a/UefiPayloadPkg/UefiPayloadPkg.dec b/UefiPayloadPkg/UefiPayloadPkg.dec index 551f0a4915..653a52b5a7 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dec +++ b/UefiPayloadPkg/UefiPayloadPkg.dec @@ -83,6 +83,9 @@ 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.PcdAbove4GMemory|TRUE|BOOLEAN|0x00000019 + ## FFS filename to find the default variable initial data file. # @Prompt FFS Name of variable initial data file gUefiPayloadPkgTokenSpaceGuid.PcdNvsDataFile |{ 0x1a, 0xf1, 0xb1, 0xae, 0x42, 0xcc, 0xcf, 0x4e, 0xac, 0x60, 0xdb, 0xab, 0xf6, 0xca, 0x69, 0xe6 }|VOID*|0x00000025 diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayloadPkg.dsc index 1ce96a51c1..dad14be343 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dsc +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc @@ -33,6 +33,7 @@ DEFINE UNIVERSAL_PAYLOAD = FALSE DEFINE SECURITY_STUB_ENABLE = TRUE DEFINE SMM_SUPPORT = FALSE + DEFINE ABOVE_4G_MEMORY = TRUE # # SBL: UEFI payload for Slim Bootloader # COREBOOT: UEFI payload for coreboot @@ -399,6 +400,8 @@ gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask | 0x1 !endif + gUefiPayloadPkgTokenSpaceGuid.PcdAbove4GMemory|$(ABOVE_4G_MEMORY) + [PcdsPatchableInModule.X64] gPcAtChipsetPkgTokenSpaceGuid.PcdRtcIndexRegister|$(RTC_INDEX_REGISTER) gPcAtChipsetPkgTokenSpaceGuid.PcdRtcTargetRegister|$(RTC_TARGET_REGISTER) -- 2.32.0 [-- Attachment #2: Type: text/html, Size: 8434 bytes --] ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [edk2-devel] [PATCH 32/32] UefiPayloadPkg: Add build option for Above 4G Memory 2022-01-29 8:46 ` Sean Rhodes @ 2022-02-01 22:53 ` Guo Dong 2022-02-01 22:55 ` Sean Rhodes 0 siblings, 1 reply; 6+ messages in thread From: Guo Dong @ 2022-02-01 22:53 UTC (permalink / raw) To: Rhodes, Sean, devel@edk2.groups.io [-- Attachment #1: Type: text/plain, Size: 6249 bytes --] Yes, please re-send the patch once there is any update. And please CC the package maintainers when you send patches to edk2 devel list follow EDK2 process. Thanks, Guo From: Sean Rhodes <sean@starlabs.systems> Sent: Saturday, January 29, 2022 1:47 AM To: Dong, Guo <guo.dong@intel.com>; devel@edk2.groups.io Subject: Re: [edk2-devel] [PATCH 32/32] UefiPayloadPkg: Add build option for Above 4G Memory Thanks :) I've updated the PR. Do I need to resend the new patch again? [PATCH 33/33] 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. Signed-off-by: Sean Rhodes <sean@starlabs.systems<mailto:sean@starlabs.systems>> --- .../UefiPayloadEntry/UefiPayloadEntry.c | 41 +++++++++++++++++++ .../UefiPayloadEntry/UefiPayloadEntry.inf | 7 ++++ UefiPayloadPkg/UefiPayloadPkg.dec | 3 ++ UefiPayloadPkg/UefiPayloadPkg.dsc | 3 ++ 4 files changed, 54 insertions(+) diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c index 0fed1e3691..d5c18dc343 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c @@ -5,10 +5,46 @@ **/ +#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 + + @param None + + @retval None +**/ +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 @@ -438,6 +474,11 @@ _ModuleEntryPoint ( // Build other HOBs required by DXE BuildGenericHob (); + // Create a HOB to make resources for EDKII modules below 4G + if (!FixedPcdGetBool (PcdAbove4GMemory) ) { + 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 1847d6481a..2ca47e3bb5 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.PcdAbove4GMemory + diff --git a/UefiPayloadPkg/UefiPayloadPkg.dec b/UefiPayloadPkg/UefiPayloadPkg.dec index 551f0a4915..653a52b5a7 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dec +++ b/UefiPayloadPkg/UefiPayloadPkg.dec @@ -83,6 +83,9 @@ 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.PcdAbove4GMemory|TRUE|BOOLEAN|0x00000019 + ## FFS filename to find the default variable initial data file. # @Prompt FFS Name of variable initial data file gUefiPayloadPkgTokenSpaceGuid.PcdNvsDataFile |{ 0x1a, 0xf1, 0xb1, 0xae, 0x42, 0xcc, 0xcf, 0x4e, 0xac, 0x60, 0xdb, 0xab, 0xf6, 0xca, 0x69, 0xe6 }|VOID*|0x00000025 diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayloadPkg.dsc index 1ce96a51c1..dad14be343 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dsc +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc @@ -33,6 +33,7 @@ DEFINE UNIVERSAL_PAYLOAD = FALSE DEFINE SECURITY_STUB_ENABLE = TRUE DEFINE SMM_SUPPORT = FALSE + DEFINE ABOVE_4G_MEMORY = TRUE # # SBL: UEFI payload for Slim Bootloader # COREBOOT: UEFI payload for coreboot @@ -399,6 +400,8 @@ gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask | 0x1 !endif + gUefiPayloadPkgTokenSpaceGuid.PcdAbove4GMemory|$(ABOVE_4G_MEMORY) + [PcdsPatchableInModule.X64] gPcAtChipsetPkgTokenSpaceGuid.PcdRtcIndexRegister|$(RTC_INDEX_REGISTER) gPcAtChipsetPkgTokenSpaceGuid.PcdRtcTargetRegister|$(RTC_TARGET_REGISTER) -- 2.32.0 [-- Attachment #2: Type: text/html, Size: 17013 bytes --] ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [edk2-devel] [PATCH 32/32] UefiPayloadPkg: Add build option for Above 4G Memory 2022-02-01 22:53 ` Guo Dong @ 2022-02-01 22:55 ` Sean Rhodes 2022-03-31 8:21 ` Sheng Lean Tan 0 siblings, 1 reply; 6+ messages in thread From: Sean Rhodes @ 2022-02-01 22:55 UTC (permalink / raw) To: Dong, Guo; +Cc: devel@edk2.groups.io [-- Attachment #1: Type: text/plain, Size: 6811 bytes --] Will do, thanks! SeanRhodes Technical Project Lead On Tue, 1 Feb 2022 at 22:53, Dong, Guo <guo.dong@intel.com> wrote: > > > Yes, please re-send the patch once there is any update. > > And please CC the package maintainers when you send patches to edk2 devel > list follow EDK2 process. > > > > Thanks, > > Guo > > > > *From:* Sean Rhodes <sean@starlabs.systems> > *Sent:* Saturday, January 29, 2022 1:47 AM > *To:* Dong, Guo <guo.dong@intel.com>; devel@edk2.groups.io > *Subject:* Re: [edk2-devel] [PATCH 32/32] UefiPayloadPkg: Add build > option for Above 4G Memory > > > > Thanks :) > > I've updated the PR. Do I need to resend the new patch again? > > [PATCH 33/33] 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. > > > > Signed-off-by: Sean Rhodes <sean@starlabs.systems> > > --- > > .../UefiPayloadEntry/UefiPayloadEntry.c | 41 +++++++++++++++++++ > > .../UefiPayloadEntry/UefiPayloadEntry.inf | 7 ++++ > > UefiPayloadPkg/UefiPayloadPkg.dec | 3 ++ > > UefiPayloadPkg/UefiPayloadPkg.dsc | 3 ++ > > 4 files changed, 54 insertions(+) > > > > diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c > b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c > > index 0fed1e3691..d5c18dc343 100644 > > --- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c > > +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c > > @@ -5,10 +5,46 @@ > > > > **/ > > > > +#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 > > + > > + @param None > > + > > + @retval None > > +**/ > > +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 > > > > @@ -438,6 +474,11 @@ _ModuleEntryPoint ( > > // Build other HOBs required by DXE > > BuildGenericHob (); > > > > + // Create a HOB to make resources for EDKII modules below 4G > > + if (!FixedPcdGetBool (PcdAbove4GMemory) ) { > > + 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 1847d6481a..2ca47e3bb5 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.PcdAbove4GMemory > > + > > diff --git a/UefiPayloadPkg/UefiPayloadPkg.dec > b/UefiPayloadPkg/UefiPayloadPkg.dec > > index 551f0a4915..653a52b5a7 100644 > > --- a/UefiPayloadPkg/UefiPayloadPkg.dec > > +++ b/UefiPayloadPkg/UefiPayloadPkg.dec > > @@ -83,6 +83,9 @@ > 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.PcdAbove4GMemory|TRUE|BOOLEAN|0x00000019 > > + > > ## FFS filename to find the default variable initial data file. > > # @Prompt FFS Name of variable initial data file > > gUefiPayloadPkgTokenSpaceGuid.PcdNvsDataFile |{ 0x1a, 0xf1, 0xb1, 0xae, > 0x42, 0xcc, 0xcf, 0x4e, 0xac, 0x60, 0xdb, 0xab, 0xf6, 0xca, 0x69, 0xe6 > }|VOID*|0x00000025 > > diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc > b/UefiPayloadPkg/UefiPayloadPkg.dsc > > index 1ce96a51c1..dad14be343 100644 > > --- a/UefiPayloadPkg/UefiPayloadPkg.dsc > > +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc > > @@ -33,6 +33,7 @@ > > DEFINE UNIVERSAL_PAYLOAD = FALSE > > DEFINE SECURITY_STUB_ENABLE = TRUE > > DEFINE SMM_SUPPORT = FALSE > > + DEFINE ABOVE_4G_MEMORY = TRUE > > # > > # SBL: UEFI payload for Slim Bootloader > > # COREBOOT: UEFI payload for coreboot > > @@ -399,6 +400,8 @@ > > gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask | 0x1 > > !endif > > > > + gUefiPayloadPkgTokenSpaceGuid.PcdAbove4GMemory|$(ABOVE_4G_MEMORY) > > + > > [PcdsPatchableInModule.X64] > > gPcAtChipsetPkgTokenSpaceGuid.PcdRtcIndexRegister|$(RTC_INDEX_REGISTER) > > > gPcAtChipsetPkgTokenSpaceGuid.PcdRtcTargetRegister|$(RTC_TARGET_REGISTER) > > -- > > 2.32.0 > > > [-- Attachment #2: Type: text/html, Size: 16218 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [edk2-devel] [PATCH 32/32] UefiPayloadPkg: Add build option for Above 4G Memory 2022-02-01 22:55 ` Sean Rhodes @ 2022-03-31 8:21 ` Sheng Lean Tan 0 siblings, 0 replies; 6+ messages in thread From: Sheng Lean Tan @ 2022-03-31 8:21 UTC (permalink / raw) To: Sean Rhodes, devel [-- Attachment #1: Type: text/plain, Size: 56 bytes --] Merged. https://github.com/tianocore/edk2/pull/2590 [-- Attachment #2: Type: text/html, Size: 68 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-03-31 8:21 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <9dd14fc91c174eae87fd122c7ac70073a363527f.1643403631.git.sean@starlabs.systems> 2022-01-28 21:04 ` [PATCH 32/32] UefiPayloadPkg: Add build option for Above 4G Memory sean 2022-01-29 0:13 ` [edk2-devel] " Guo Dong 2022-01-29 8:46 ` Sean Rhodes 2022-02-01 22:53 ` Guo Dong 2022-02-01 22:55 ` Sean Rhodes 2022-03-31 8:21 ` Sheng Lean Tan
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox