<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);" class="elementToProof">
Reviewed-by: Ray Ni <ray.ni@intel.com></div>
<div class="elementToProof">
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="Signature">
<div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
Thanks,</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
Ray</div>
</div>
</div>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Tan, Dun <dun.tan@intel.com><br>
<b>Sent:</b> Wednesday, August 30, 2023 3:35 PM<br>
<b>To:</b> devel@edk2.groups.io <devel@edk2.groups.io><br>
<b>Cc:</b> Wang, Jian J <jian.j.wang@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>; Ni, Ray <ray.ni@intel.com><br>
<b>Subject:</b> [Patch V2] MdeModulePkg/DxeCorePerformanceLib:fix smm perf issue</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Fix smm perf issue in DxeCorePerformanceLib. In<br>
current code logic, total SMM perf record is copied<br>
multiple times to FPDT table if multiple ReadyToBoot<br>
events are signaled. This patch changes the function<br>
InternalGetSmmPerfData() to only get newly generated<br>
Smm perf data. Then previous generated Smm perf data<br>
won't be copied to FPDT again.<br>
<br>
BZ: <a href="https://bugzilla.tianocore.org/show_bug.cgi?id=4470">https://bugzilla.tianocore.org/show_bug.cgi?id=4470</a><br>
Signed-off-by: Dun Tan <dun.tan@intel.com><br>
Cc: Jian J Wang <jian.j.wang@intel.com><br>
Cc: Liming Gao <gaoliming@byosoft.com.cn><br>
Cc: Ray Ni <ray.ni@intel.com><br>
---<br>
MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c | 32 +++++++++++++++++++-------------<br>
1 file changed, 19 insertions(+), 13 deletions(-)<br>
<br>
diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c<br>
index ef14bc0738..0a994be6a5 100644<br>
--- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c<br>
+++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c<br>
@@ -10,7 +10,7 @@<br>
This library is mainly used by DxeCore to start performance logging to ensure that<br>
Performance Protocol is installed at the very beginning of DXE phase.<br>
<br>
-Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR><br>
+Copyright (c) 2006 - 2023, Intel Corporation. All rights reserved.<BR><br>
(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR><br>
SPDX-License-Identifier: BSD-2-Clause-Patent<br>
<br>
@@ -73,6 +73,7 @@ UINT8 *mPerformancePointer = NULL;<br>
UINT8 *mBootRecordBuffer = NULL;<br>
BOOLEAN mLockInsertRecord = FALSE;<br>
CHAR8 *mDevicePathString = NULL;<br>
+UINTN mSmmBootRecordOffset = 0;<br>
<br>
EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *mDevicePathToText = NULL;<br>
<br>
@@ -236,6 +237,7 @@ InternalGetSmmPerfData (<br>
VOID *SmmBootRecordData;<br>
UINTN SmmBootRecordDataSize;<br>
UINTN ReservedMemSize;<br>
+ UINTN SmmBootRecordDataRetrieved;<br>
<br>
//<br>
// Collect boot records from SMM drivers.<br>
@@ -297,28 +299,32 @@ InternalGetSmmPerfData (<br>
}<br>
<br>
//<br>
- // Get all boot records<br>
+ // Get boot records starting from mSmmBootRecordOffset<br>
//<br>
- SmmCommData->Function = SMM_FPDT_FUNCTION_GET_BOOT_RECORD_DATA_BY_OFFSET;<br>
- SmmBootRecordDataSize = SmmCommData->BootRecordSize;<br>
- SmmBootRecordData = AllocateZeroPool (SmmBootRecordDataSize);<br>
+ SmmCommData->Function = SMM_FPDT_FUNCTION_GET_BOOT_RECORD_DATA_BY_OFFSET;<br>
+ SmmCommData->BootRecordOffset = mSmmBootRecordOffset;<br>
+ SmmBootRecordDataSize = SmmCommData->BootRecordSize - mSmmBootRecordOffset;<br>
+ SmmBootRecordData = AllocateZeroPool (SmmBootRecordDataSize);<br>
+ SmmBootRecordDataRetrieved = 0;<br>
ASSERT (SmmBootRecordData != NULL);<br>
- SmmCommData->BootRecordOffset = 0;<br>
- SmmCommData->BootRecordData = (VOID *)((UINTN)SmmCommMemRegion->PhysicalStart + SMM_BOOT_RECORD_COMM_SIZE);<br>
- SmmCommData->BootRecordSize = ReservedMemSize - SMM_BOOT_RECORD_COMM_SIZE;<br>
- while (SmmCommData->BootRecordOffset < SmmBootRecordDataSize) {<br>
+ SmmCommData->BootRecordData = (VOID *)((UINTN)SmmCommMemRegion->PhysicalStart + SMM_BOOT_RECORD_COMM_SIZE);<br>
+ SmmCommData->BootRecordSize = ReservedMemSize - SMM_BOOT_RECORD_COMM_SIZE;<br>
+ while (SmmBootRecordDataRetrieved < SmmBootRecordDataSize) {<br>
Status = Communication->Communicate (Communication, SmmBootRecordCommBuffer, &CommSize);<br>
ASSERT_EFI_ERROR (Status);<br>
ASSERT_EFI_ERROR (SmmCommData->ReturnStatus);<br>
- if (SmmCommData->BootRecordOffset + SmmCommData->BootRecordSize > SmmBootRecordDataSize) {<br>
- CopyMem ((UINT8 *)SmmBootRecordData + SmmCommData->BootRecordOffset, SmmCommData->BootRecordData, SmmBootRecordDataSize - SmmCommData->BootRecordOffset);<br>
+ if (SmmBootRecordDataRetrieved + SmmCommData->BootRecordSize > SmmBootRecordDataSize) {<br>
+ CopyMem ((UINT8 *)SmmBootRecordData + SmmBootRecordDataRetrieved, SmmCommData->BootRecordData, SmmBootRecordDataSize - SmmBootRecordDataRetrieved);<br>
} else {<br>
- CopyMem ((UINT8 *)SmmBootRecordData + SmmCommData->BootRecordOffset, SmmCommData->BootRecordData, SmmCommData->BootRecordSize);<br>
+ CopyMem ((UINT8 *)SmmBootRecordData + SmmBootRecordDataRetrieved, SmmCommData->BootRecordData, SmmCommData->BootRecordSize);<br>
}<br>
<br>
- SmmCommData->BootRecordOffset = SmmCommData->BootRecordOffset + SmmCommData->BootRecordSize;<br>
+ SmmBootRecordDataRetrieved += SmmCommData->BootRecordSize;<br>
+ SmmCommData->BootRecordOffset += SmmCommData->BootRecordSize;<br>
}<br>
<br>
+ mSmmBootRecordOffset = SmmCommData->BootRecordOffset;<br>
+<br>
*SmmPerfData = SmmBootRecordData;<br>
*SmmPerfDataSize = SmmBootRecordDataSize;<br>
}<br>
-- <br>
2.31.1.windows.1<br>
<br>
</div>
</span></font></div>
</body>
</html>
<div width="1" style="color:white;clear:both">_._,_._,_</div>
<hr>
Groups.io Links:<p>
You receive all messages sent to this group.
<p>
<a target="_blank" href="https://edk2.groups.io/g/devel/message/108141">View/Reply Online (#108141)</a> |
|
<a target="_blank" href="https://groups.io/mt/101047988/1813853">Mute This Topic</a>
| <a href="https://edk2.groups.io/g/devel/post">New Topic</a>
<br>
<a href="https://edk2.groups.io/g/devel/editsub/1813853">Your Subscription</a> |
<a href="mailto:devel+owner@edk2.groups.io">Contact Group Owner</a> |
<a href="https://edk2.groups.io/g/devel/leave/3943202/1813853/130120423/xyzzy">Unsubscribe</a>
[edk2-devel-archive@redhat.com]<br>
<div width="1" style="color:white;clear:both">_._,_._,_</div>