OvmfPkg: Add OVMF Memory Debug Logging support to PlatformDebugLibIoPort

Extend OvmfPkg PlatformDebugLibIoPort library to also
write debug messages to memory.

Include NULL versions of MemDebugLogLib to all OVMF builds
which use PlatformDebugLibIoPort.

Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Aaron Young <aaron.young@oracle.com>
This commit is contained in:
Aaron Young
2025-04-28 09:30:12 -07:00
committed by mergify[bot]
parent 57844e4997
commit b3bc195490
12 changed files with 31 additions and 4 deletions

View File

@@ -211,6 +211,7 @@
TdxLib|MdePkg/Library/TdxLib/TdxLib.inf
TdxMailboxLib|OvmfPkg/Library/TdxMailboxLib/TdxMailboxLibNull.inf
TdxHelperLib|OvmfPkg/IntelTdx/TdxHelperLib/TdxHelperLibNull.inf
MemDebugLogLib|OvmfPkg/Library/MemDebugLogLib/MemDebugLogLibNull.inf
[LibraryClasses.common.SEC]
TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf

View File

@@ -243,6 +243,7 @@
BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
CcExitLib|UefiCpuPkg/Library/CcExitLibNull/CcExitLibNull.inf
TdxLib|MdePkg/Library/TdxLib/TdxLib.inf
MemDebugLogLib|OvmfPkg/Library/MemDebugLogLib/MemDebugLogLibNull.inf
[LibraryClasses.common.SEC]
!ifdef $(DEBUG_ON_SERIAL_PORT)

View File

@@ -258,6 +258,7 @@
TdxLib|MdePkg/Library/TdxLib/TdxLib.inf
TdxMailboxLib|OvmfPkg/Library/TdxMailboxLib/TdxMailboxLibNull.inf
TdxHelperLib|OvmfPkg/IntelTdx/TdxHelperLib/TdxHelperLibNull.inf
MemDebugLogLib|OvmfPkg/Library/MemDebugLogLib/MemDebugLogLibNull.inf
[LibraryClasses.common.SEC]
TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf

View File

@@ -218,6 +218,7 @@
TdxLib|MdePkg/Library/TdxLib/TdxLib.inf
TdxMailboxLib|OvmfPkg/Library/TdxMailboxLib/TdxMailboxLib.inf
PlatformInitLib|OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf
MemDebugLogLib|OvmfPkg/Library/MemDebugLogLib/MemDebugLogLibNull.inf
[LibraryClasses.common.SEC]
TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf

View File

@@ -16,6 +16,7 @@
#include <Library/PcdLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugPrintErrorLevelLib.h>
#include <Library/MemDebugLogLib.h>
#include "DebugLibDetect.h"
//
@@ -93,10 +94,11 @@ DebugPrintMarker (
ASSERT (Format != NULL);
//
// Check if the global mask disables this message or the device is inactive
// If the global mask disables this message OR the debug I/O port is not
// present and Memory Debug Logging is disabled, there's nothing to do.
//
if (((ErrorLevel & GetDebugPrintErrorLevel ()) == 0) ||
!PlatformDebugLibIoPortFound ())
(!PlatformDebugLibIoPortFound () && !MemDebugLogEnabled ()))
{
return;
}
@@ -111,9 +113,18 @@ DebugPrintMarker (
}
//
// Send the print string to the debug I/O port
// Send the print string to the debug I/O port, if present
//
IoWriteFifo8 (PcdGet16 (PcdDebugIoPort), Length, Buffer);
if (PlatformDebugLibIoPortFound ()) {
IoWriteFifo8 (PcdGet16 (PcdDebugIoPort), Length, Buffer);
}
//
// Send string to Memory Debug Log if enabled
//
if (MemDebugLogEnabled ()) {
MemDebugLogWrite (Buffer, Length);
}
}
/**
@@ -221,6 +232,11 @@ DebugAssert (
IoWriteFifo8 (PcdGet16 (PcdDebugIoPort), Length, Buffer);
}
//
// Send the string to Memory Debug Log
//
MemDebugLogWrite (Buffer, Length);
//
// Generate a Breakpoint, DeadLoop, or NOP based on PCD settings
//

View File

@@ -40,6 +40,7 @@
PrintLib
BaseLib
DebugPrintErrorLevelLib
MemDebugLogLib
[Pcd]
gUefiOvmfPkgTokenSpaceGuid.PcdDebugIoPort ## CONSUMES

View File

@@ -40,6 +40,7 @@
PrintLib
BaseLib
DebugPrintErrorLevelLib
MemDebugLogLib
[Pcd]
gUefiOvmfPkgTokenSpaceGuid.PcdDebugIoPort ## CONSUMES

View File

@@ -249,6 +249,7 @@
TdxLib|MdePkg/Library/TdxLib/TdxLib.inf
TdxMailboxLib|OvmfPkg/Library/TdxMailboxLib/TdxMailboxLibNull.inf
TdxHelperLib|OvmfPkg/IntelTdx/TdxHelperLib/TdxHelperLibNull.inf
MemDebugLogLib|OvmfPkg/Library/MemDebugLogLib/MemDebugLogLibNull.inf
[LibraryClasses.common.SEC]
QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSecLib.inf

View File

@@ -246,6 +246,7 @@
TdxLib|MdePkg/Library/TdxLib/TdxLib.inf
TdxMailboxLib|OvmfPkg/Library/TdxMailboxLib/TdxMailboxLibNull.inf
TdxHelperLib|OvmfPkg/IntelTdx/TdxHelperLib/TdxHelperLibNull.inf
MemDebugLogLib|OvmfPkg/Library/MemDebugLogLib/MemDebugLogLibNull.inf
[LibraryClasses.common.SEC]
TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf

View File

@@ -251,6 +251,7 @@
TdxLib|MdePkg/Library/TdxLib/TdxLib.inf
TdxMailboxLib|OvmfPkg/Library/TdxMailboxLib/TdxMailboxLibNull.inf
TdxHelperLib|OvmfPkg/IntelTdx/TdxHelperLib/TdxHelperLibNull.inf
MemDebugLogLib|OvmfPkg/Library/MemDebugLogLib/MemDebugLogLibNull.inf
[LibraryClasses.common.SEC]
TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf

View File

@@ -267,6 +267,7 @@
CcExitLib|OvmfPkg/Library/CcExitLib/CcExitLib.inf
TdxLib|MdePkg/Library/TdxLib/TdxLib.inf
TdxMailboxLib|OvmfPkg/Library/TdxMailboxLib/TdxMailboxLib.inf
MemDebugLogLib|OvmfPkg/Library/MemDebugLogLib/MemDebugLogLibNull.inf
[LibraryClasses.common.SEC]
TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf

View File

@@ -235,6 +235,7 @@
BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
CcExitLib|UefiCpuPkg/Library/CcExitLibNull/CcExitLibNull.inf
TdxLib|MdePkg/Library/TdxLib/TdxLib.inf
MemDebugLogLib|OvmfPkg/Library/MemDebugLogLib/MemDebugLogLibNull.inf
[LibraryClasses.common.SEC]
QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSecLib.inf