Skip to content

Commit f3d0af4

Browse files
OvmfPkg: Add OVMF Memory Debug Logging to Ia32X64 and X64 OVMF builds
Add the OVMF Memory Debug Logging feature (MemDebugLogLib library and MemDebugLogPei PEIM) to the Ia32X64 and X64 OVMF builds. This includes reserving the "early" memory debug log buffer in the .fdf files. The OVMF Memory Debug Logging feature is enabled via the -D DEBUG_TO_MEM build flag. Cc: Gerd Hoffmann <[email protected]> Cc: Ard Biesheuvel <[email protected]> Cc: Jiewen Yao <[email protected]> Signed-off-by: Aaron Young <[email protected]>
1 parent fb584b5 commit f3d0af4

File tree

4 files changed

+70
-2
lines changed

4 files changed

+70
-2
lines changed

OvmfPkg/OvmfPkgIa32X64.dsc

+25
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,11 @@
251251
TdxLib|MdePkg/Library/TdxLib/TdxLib.inf
252252
TdxMailboxLib|OvmfPkg/Library/TdxMailboxLib/TdxMailboxLibNull.inf
253253
TdxHelperLib|OvmfPkg/IntelTdx/TdxHelperLib/TdxHelperLibNull.inf
254+
!if $(DEBUG_TO_MEM)
255+
MemDebugLogLib|OvmfPkg/Library/MemDebugLogLib/MemDebugLogDxeLib.inf
256+
!else
254257
MemDebugLogLib|OvmfPkg/Library/MemDebugLogLib/MemDebugLogLibNull.inf
258+
!endif
255259

256260
[LibraryClasses.common.SEC]
257261
TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf
@@ -260,6 +264,9 @@
260264
DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
261265
!else
262266
DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf
267+
!endif
268+
!if $(DEBUG_TO_MEM)
269+
MemDebugLogLib|OvmfPkg/Library/MemDebugLogLib/MemDebugLogSecLib.inf
263270
!endif
264271
ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf
265272
ExtractGuidedSectionLib|MdePkg/Library/BaseExtractGuidedSectionLib/BaseExtractGuidedSectionLib.inf
@@ -286,6 +293,9 @@
286293
DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
287294
!else
288295
DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf
296+
!endif
297+
!if $(DEBUG_TO_MEM)
298+
MemDebugLogLib|OvmfPkg/Library/MemDebugLogLib/MemDebugLogPeiCoreLib.inf
289299
!endif
290300
PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
291301

@@ -302,6 +312,9 @@
302312
DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
303313
!else
304314
DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf
315+
!endif
316+
!if $(DEBUG_TO_MEM)
317+
MemDebugLogLib|OvmfPkg/Library/MemDebugLogLib/MemDebugLogPeiLib.inf
305318
!endif
306319
PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
307320
ResourcePublicationLib|MdePkg/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf
@@ -347,6 +360,9 @@
347360
DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
348361
!else
349362
DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
363+
!endif
364+
!if $(DEBUG_TO_MEM)
365+
MemDebugLogLib|OvmfPkg/Library/MemDebugLogLib/MemDebugLogRtLib.inf
350366
!endif
351367
UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
352368
BaseCryptLib|CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
@@ -692,6 +708,9 @@
692708
# PEI Phase modules
693709
#
694710
MdeModulePkg/Core/Pei/PeiMain.inf
711+
!if $(DEBUG_TO_MEM)
712+
OvmfPkg/MemDebugLogPei/MemDebugLogPei.inf
713+
!endif
695714
MdeModulePkg/Universal/PCD/Pei/Pcd.inf {
696715
<LibraryClasses>
697716
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
@@ -738,6 +757,9 @@
738757
MdeModulePkg/Universal/PCD/Dxe/Pcd.inf {
739758
<LibraryClasses>
740759
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
760+
!if $(DEBUG_TO_MEM)
761+
MemDebugLogLib|OvmfPkg/Library/MemDebugLogLib/MemDebugLogLibNull.inf
762+
!endif
741763
}
742764

743765
MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
@@ -815,6 +837,9 @@
815837
<LibraryClasses>
816838
DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
817839
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
840+
!if $(DEBUG_TO_MEM)
841+
MemDebugLogLib|OvmfPkg/Library/MemDebugLogLib/MemDebugLogLibNull.inf
842+
!endif
818843
}
819844
MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
820845
MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf

OvmfPkg/OvmfPkgIa32X64.fdf

+10-1
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,13 @@ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvm
8282
0x010000|0x010000
8383
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize
8484

85-
0x020000|0x0E0000
85+
0x020000|0x0D0000
8686
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize
8787
FV = PEIFV
8888

89+
0x0F0000|0x10000
90+
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfEarlyMemDebugLogBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfEarlyMemDebugLogSize
91+
8992
0x100000|0xE80000
9093
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize
9194
FV = DXEFV
@@ -152,6 +155,9 @@ READ_LOCK_CAP = TRUE
152155
READ_LOCK_STATUS = TRUE
153156

154157
APRIORI PEI {
158+
!if $(DEBUG_TO_MEM)
159+
INF OvmfPkg/MemDebugLogPei/MemDebugLogPei.inf
160+
!endif
155161
INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf
156162
}
157163

@@ -162,6 +168,9 @@ INF MdeModulePkg/Core/Pei/PeiMain.inf
162168
INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf
163169
INF MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.inf
164170
INF MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf
171+
!if $(DEBUG_TO_MEM)
172+
INF OvmfPkg/MemDebugLogPei/MemDebugLogPei.inf
173+
!endif
165174
INF OvmfPkg/PlatformPei/PlatformPei.inf
166175
INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
167176
INF UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf

OvmfPkg/OvmfPkgX64.dsc

+25
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,11 @@
267267
CcExitLib|OvmfPkg/Library/CcExitLib/CcExitLib.inf
268268
TdxLib|MdePkg/Library/TdxLib/TdxLib.inf
269269
TdxMailboxLib|OvmfPkg/Library/TdxMailboxLib/TdxMailboxLib.inf
270+
!if $(DEBUG_TO_MEM)
271+
MemDebugLogLib|OvmfPkg/Library/MemDebugLogLib/MemDebugLogDxeLib.inf
272+
!else
270273
MemDebugLogLib|OvmfPkg/Library/MemDebugLogLib/MemDebugLogLibNull.inf
274+
!endif
271275

272276
[LibraryClasses.common.SEC]
273277
TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf
@@ -276,6 +280,9 @@
276280
DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
277281
!else
278282
DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf
283+
!endif
284+
!if $(DEBUG_TO_MEM)
285+
MemDebugLogLib|OvmfPkg/Library/MemDebugLogLib/MemDebugLogSecLib.inf
279286
!endif
280287
ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf
281288
ExtractGuidedSectionLib|MdePkg/Library/BaseExtractGuidedSectionLib/BaseExtractGuidedSectionLib.inf
@@ -305,6 +312,9 @@
305312
DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
306313
!else
307314
DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf
315+
!endif
316+
!if $(DEBUG_TO_MEM)
317+
MemDebugLogLib|OvmfPkg/Library/MemDebugLogLib/MemDebugLogPeiCoreLib.inf
308318
!endif
309319
PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
310320
CcProbeLib|OvmfPkg/Library/CcProbeLib/SecPeiCcProbeLib.inf
@@ -322,6 +332,9 @@
322332
DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
323333
!else
324334
DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf
335+
!endif
336+
!if $(DEBUG_TO_MEM)
337+
MemDebugLogLib|OvmfPkg/Library/MemDebugLogLib/MemDebugLogPeiLib.inf
325338
!endif
326339
PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
327340
ResourcePublicationLib|MdePkg/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf
@@ -371,6 +384,9 @@
371384
DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
372385
!else
373386
DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
387+
!endif
388+
!if $(DEBUG_TO_MEM)
389+
MemDebugLogLib|OvmfPkg/Library/MemDebugLogLib/MemDebugLogRtLib.inf
374390
!endif
375391
UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
376392
BaseCryptLib|CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
@@ -722,6 +738,9 @@
722738
# PEI Phase modules
723739
#
724740
MdeModulePkg/Core/Pei/PeiMain.inf
741+
!if $(DEBUG_TO_MEM)
742+
OvmfPkg/MemDebugLogPei/MemDebugLogPei.inf
743+
!endif
725744
MdeModulePkg/Universal/PCD/Pei/Pcd.inf {
726745
<LibraryClasses>
727746
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
@@ -796,6 +815,9 @@
796815
MdeModulePkg/Universal/PCD/Dxe/Pcd.inf {
797816
<LibraryClasses>
798817
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
818+
!if $(DEBUG_TO_MEM)
819+
MemDebugLogLib|OvmfPkg/Library/MemDebugLogLib/MemDebugLogLibNull.inf
820+
!endif
799821
}
800822

801823
MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
@@ -896,6 +918,9 @@
896918
<LibraryClasses>
897919
DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
898920
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
921+
!if $(DEBUG_TO_MEM)
922+
MemDebugLogLib|OvmfPkg/Library/MemDebugLogLib/MemDebugLogLibNull.inf
923+
!endif
899924
}
900925
MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
901926
MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf

OvmfPkg/OvmfPkgX64.fdf

+10-1
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,13 @@ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecApicPageTableBase|gUefiOvmfPkgTokenSpaceGui
103103
0x011000|0x00F000
104104
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize
105105

106-
0x020000|0x0E0000
106+
0x020000|0x0D0000
107107
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize
108108
FV = PEIFV
109109

110+
0x0F0000|0x10000
111+
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfEarlyMemDebugLogBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfEarlyMemDebugLogSize
112+
110113
0x100000|0xE80000
111114
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize
112115
FV = DXEFV
@@ -173,6 +176,9 @@ READ_LOCK_CAP = TRUE
173176
READ_LOCK_STATUS = TRUE
174177

175178
APRIORI PEI {
179+
!if $(DEBUG_TO_MEM)
180+
INF OvmfPkg/MemDebugLogPei/MemDebugLogPei.inf
181+
!endif
176182
INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf
177183
}
178184

@@ -183,6 +189,9 @@ INF MdeModulePkg/Core/Pei/PeiMain.inf
183189
INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf
184190
INF MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.inf
185191
INF MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf
192+
!if $(DEBUG_TO_MEM)
193+
INF OvmfPkg/MemDebugLogPei/MemDebugLogPei.inf
194+
!endif
186195
!if $(CC_MEASUREMENT_ENABLE) == TRUE
187196
INF OvmfPkg/Tcg/TdTcg2Pei/TdTcg2Pei.inf
188197
!endif

0 commit comments

Comments
 (0)