diff options
author | Michael D Kinney <michael.d.kinney@intel.com> | 2024-01-09 10:13:12 -0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2024-01-30 18:30:02 +0000 |
commit | c5e702e45ad4e71e1bfc710c9db0826c1c893b18 (patch) | |
tree | a61b2b04f38cde05a2fe1ed2718ae78f3c2543b3 /MdeModulePkg/Core/Dxe | |
parent | 909a9a5ae4b8236c1ca7cad7f214c752a579bd67 (diff) | |
download | edk2-c5e702e45ad4e71e1bfc710c9db0826c1c893b18.zip edk2-c5e702e45ad4e71e1bfc710c9db0826c1c893b18.tar.gz edk2-c5e702e45ad4e71e1bfc710c9db0826c1c893b18.tar.bz2 |
MdeModulePkg/Core/Dxe: Initialize GCD before RT memory allocations
Update the DxeMain initialization order to initialize GCD
services before any runtime allocations are performed. This
is required to prevent runtime data fragmentation when the
UEFI System Table and UEFI Runtime Service Table are allocated
before both the memory and GCD services are initialized.
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Aaron Li <aaron.li@intel.com>
Cc: Liu Yun <yun.y.liu@intel.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Diffstat (limited to 'MdeModulePkg/Core/Dxe')
-rw-r--r-- | MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c | 23 | ||||
-rw-r--r-- | MdeModulePkg/Core/Dxe/Image/Image.c | 13 |
2 files changed, 20 insertions, 16 deletions
diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c index 0e0f976..17d510a 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c +++ b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c @@ -277,6 +277,18 @@ DxeMain ( MemoryProfileInit (HobStart);
//
+ // Start the Image Services.
+ //
+ Status = CoreInitializeImageServices (HobStart);
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Initialize the Global Coherency Domain Services
+ //
+ Status = CoreInitializeGcdServices (&HobStart, MemoryBaseAddress, MemoryLength);
+ ASSERT_EFI_ERROR (Status);
+
+ //
// Allocate the EFI System Table and EFI Runtime Service Table from EfiRuntimeServicesData
// Use the templates to initialize the contents of the EFI System Table and EFI Runtime Services Table
//
@@ -289,16 +301,9 @@ DxeMain ( gDxeCoreST->RuntimeServices = gDxeCoreRT;
//
- // Start the Image Services.
- //
- Status = CoreInitializeImageServices (HobStart);
- ASSERT_EFI_ERROR (Status);
-
- //
- // Initialize the Global Coherency Domain Services
+ // Update DXE Core Loaded Image Protocol with allocated UEFI System Table
//
- Status = CoreInitializeGcdServices (&HobStart, MemoryBaseAddress, MemoryLength);
- ASSERT_EFI_ERROR (Status);
+ gDxeCoreLoadedImage->SystemTable = gDxeCoreST;
//
// Call constructor for all libraries
diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c b/MdeModulePkg/Core/Dxe/Image/Image.c index 6bc3a54..f520c48 100644 --- a/MdeModulePkg/Core/Dxe/Image/Image.c +++ b/MdeModulePkg/Core/Dxe/Image/Image.c @@ -218,13 +218,12 @@ CoreInitializeImageServices ( //
Image = &mCorePrivateImage;
- Image->EntryPoint = (EFI_IMAGE_ENTRY_POINT)(UINTN)DxeCoreEntryPoint;
- Image->ImageBasePage = DxeCoreImageBaseAddress;
- Image->NumberOfPages = (UINTN)(EFI_SIZE_TO_PAGES ((UINTN)(DxeCoreImageLength)));
- Image->Tpl = gEfiCurrentTpl;
- Image->Info.SystemTable = gDxeCoreST;
- Image->Info.ImageBase = (VOID *)(UINTN)DxeCoreImageBaseAddress;
- Image->Info.ImageSize = DxeCoreImageLength;
+ Image->EntryPoint = (EFI_IMAGE_ENTRY_POINT)(UINTN)DxeCoreEntryPoint;
+ Image->ImageBasePage = DxeCoreImageBaseAddress;
+ Image->NumberOfPages = (UINTN)(EFI_SIZE_TO_PAGES ((UINTN)(DxeCoreImageLength)));
+ Image->Tpl = gEfiCurrentTpl;
+ Image->Info.ImageBase = (VOID *)(UINTN)DxeCoreImageBaseAddress;
+ Image->Info.ImageSize = DxeCoreImageLength;
//
// Install the protocol interfaces for this image
|