diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c index 57a14e8796..5798c89fff 100644 --- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c +++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c @@ -1111,14 +1111,13 @@ InsertFpdtRecord ( case PERF_EVENTSIGNAL_END_ID: case PERF_CALLBACK_START_ID: case PERF_CALLBACK_END_ID: - if (String == NULL) { + if (String == NULL || Guid == NULL) { return EFI_INVALID_PARAMETER; } - // - // Cache the event guid in string event record when PcdEdkiiFpdtStringRecordEnableOnly == TRUE - // - CopyGuid (&ModuleGuid, Guid); StringPtr = String; + if (AsciiStrLen (String) == 0) { + StringPtr = "unknown name"; + } if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) { FpdtRecordPtr.DualGuidStringEvent->Header.Type = FPDT_DUAL_GUID_STRING_EVENT_TYPE; FpdtRecordPtr.DualGuidStringEvent->Header.Length = sizeof (FPDT_DUAL_GUID_STRING_EVENT_RECORD); @@ -1196,7 +1195,14 @@ InsertFpdtRecord ( FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1; FpdtRecordPtr.DynamicStringEvent->ProgressID = PerfId; FpdtRecordPtr.DynamicStringEvent->Timestamp = TimeStamp; - CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.DynamicStringEvent->Guid)); + if (Guid != NULL) { + // + // Cache the event guid in string event record. + // + CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, Guid, sizeof (FpdtRecordPtr.DynamicStringEvent->Guid)); + } else { + CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.DynamicStringEvent->Guid)); + } if (AsciiStrLen (StringPtr) == 0) { StringPtr = "unknown name"; } diff --git a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c index 8a65a2a747..808a63501e 100644 --- a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c +++ b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c @@ -77,10 +77,10 @@ GetFpdtRecordPtr ( // PeiFirmwarePerformance = (UINT8*)GET_GUID_HOB_DATA (GuidHob); *PeiPerformanceLogHeader = (FPDT_PEI_EXT_PERF_HEADER *)PeiFirmwarePerformance; - if (!(*PeiPerformanceLogHeader)->HobIsFull && (*PeiPerformanceLogHeader)->SizeOfAllEntries + RecordSize > (UINTN)(PeiPerformanceLogEntries * PEI_MAX_RECORD_SIZE)) { + if (!(*PeiPerformanceLogHeader)->HobIsFull && (*PeiPerformanceLogHeader)->SizeOfAllEntries + RecordSize > (PeiPerformanceLogEntries * PEI_MAX_RECORD_SIZE)) { (*PeiPerformanceLogHeader)->HobIsFull = TRUE; } - if (!(*PeiPerformanceLogHeader)->HobIsFull && (*PeiPerformanceLogHeader)->SizeOfAllEntries + RecordSize <= (UINTN)(PeiPerformanceLogEntries * PEI_MAX_RECORD_SIZE)) { + if (!(*PeiPerformanceLogHeader)->HobIsFull && (*PeiPerformanceLogHeader)->SizeOfAllEntries + RecordSize <= (PeiPerformanceLogEntries * PEI_MAX_RECORD_SIZE)) { FpdtRecordPtr->RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(PeiFirmwarePerformance + sizeof (FPDT_PEI_EXT_PERF_HEADER) + (*PeiPerformanceLogHeader)->SizeOfAllEntries); break; } @@ -423,9 +423,11 @@ InsertFpdtRecord ( case PERF_EVENTSIGNAL_END_ID: case PERF_CALLBACK_START_ID: case PERF_CALLBACK_END_ID: - if (String != NULL && AsciiStrLen (String) != 0) { - StringPtr = String; - } else { + if (String == NULL || Guid == NULL) { + return EFI_INVALID_PARAMETER; + } + StringPtr = String; + if (AsciiStrLen (String) == 0) { StringPtr = "unknown name"; } if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) { @@ -436,6 +438,7 @@ InsertFpdtRecord ( FpdtRecordPtr.DualGuidStringEvent->Timestamp = TimeStamp; CopyMem (&FpdtRecordPtr.DualGuidStringEvent->Guid1, ModuleGuid, sizeof (FpdtRecordPtr.DualGuidStringEvent->Guid1)); CopyMem (&FpdtRecordPtr.DualGuidStringEvent->Guid2, Guid, sizeof (FpdtRecordPtr.DualGuidStringEvent->Guid2)); + CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DualGuidStringEvent->String, StringPtr, &FpdtRecordPtr.DualGuidStringEvent->Header.Length); } break; diff --git a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c index 0c00fb51e8..f18c3fb60d 100644 --- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c +++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c @@ -649,14 +649,13 @@ InsertFpdtRecord ( case PERF_EVENTSIGNAL_END_ID: case PERF_CALLBACK_START_ID: case PERF_CALLBACK_END_ID: - if (String == NULL) { + if (String == NULL || Guid == NULL) { return EFI_INVALID_PARAMETER; } - // - // Cache the event guid in string event record when PcdEdkiiFpdtStringRecordEnableOnly == TRUE - // - CopyGuid (&ModuleGuid, Guid); StringPtr = String; + if (AsciiStrLen (String) == 0) { + StringPtr = "unknown name"; + } if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) { FpdtRecordPtr.DualGuidStringEvent->Header.Type = FPDT_DUAL_GUID_STRING_EVENT_TYPE; FpdtRecordPtr.DualGuidStringEvent->Header.Length = sizeof (FPDT_DUAL_GUID_STRING_EVENT_RECORD); @@ -734,7 +733,14 @@ InsertFpdtRecord ( FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1; FpdtRecordPtr.DynamicStringEvent->ProgressID = PerfId; FpdtRecordPtr.DynamicStringEvent->Timestamp = TimeStamp; - CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.DynamicStringEvent->Guid)); + if (Guid != NULL) { + // + // Cache the event guid in string event record. + // + CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, Guid, sizeof (FpdtRecordPtr.DynamicStringEvent->Guid)); + } else { + CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.DynamicStringEvent->Guid)); + } if (AsciiStrLen (StringPtr) == 0) { StringPtr = "unknown name"; }