From 1366cd58cd4459f00b4ecf5abed13e77ac4ad06c Mon Sep 17 00:00:00 2001 From: Laszlo Ersek Date: Tue, 3 Nov 2020 17:15:57 +0100 Subject: [PATCH] MdeModulePkg/Core/Dxe: log memory base and length, after lib ctors again MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CoreInitializeMemoryServices() logs "BaseAddress" and "Length" with DEBUG() before DxeMain() calls ProcessLibraryConstructorList() explicitly. (Library construction is not an automatic part of the DXE Core entry point.) So those DEBUG()s in CoreInitializeMemoryServices() are issued against an un-constructed DebugLib, and also against a -- possibly underlying -- un-constructed SerialPortLib. Some DebugLib instances can deal with this (see for example commit 91a5b1365075, "OvmfPkg/PlatformDebugLibIoPort: fix port detection for use in the DXE Core", 2018-08-06), while some others can't (see for example the DebugLib instance "MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf" coupled with the SerialPortLib instance "ArmVirtPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.inf"). Addressing this issue in a SerialPortLib instance that underlies BaseDebugLibSerialPort seems wrong; either the DebugLib instance should cope directly with being called un-constructed (see again commit 91a5b1365075), or the DXE Core should log relevant information *at least* after library instances have been constructed. This patch implements the latter (only for the "BaseAddress" and "Length" values calculated by CoreInitializeMemoryServices()). Cc: Ard Biesheuvel Cc: Dandan Bi Cc: Hao A Wu Cc: Jeff Brasen Cc: Jian J Wang Cc: Leif Lindholm Cc: Liming Gao Cc: Philippe Mathieu-Daudé Signed-off-by: Laszlo Ersek Message-Id: <20201103161557.30621-1-lersek@redhat.com> Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Liming Gao --- MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c index 5ee4cd10b4..db21311f93 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c +++ b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c @@ -298,6 +298,14 @@ DxeMain ( PERF_CROSSMODULE_END ("PEI"); PERF_CROSSMODULE_BEGIN ("DXE"); + // + // Log MemoryBaseAddress and MemoryLength again (from + // CoreInitializeMemoryServices()), now that library constructors have + // executed. + // + DEBUG ((DEBUG_INFO, "%a: MemoryBaseAddress=0x%Lx MemoryLength=0x%Lx\n", + __FUNCTION__, MemoryBaseAddress, MemoryLength)); + // // Report DXE Core image information to the PE/COFF Extra Action Library //