public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [patch] MdeModulePkg/PiSmmCore: Remove SMM Perf entry
@ 2018-06-27  6:16 Dandan Bi
  2018-06-27  6:16 ` [patch] MdeModulePkg/PerformanceLib: Add NULL pointer check Dandan Bi
  2018-06-27  6:59 ` [patch] MdeModulePkg/PiSmmCore: Remove SMM Perf entry Gao, Liming
  0 siblings, 2 replies; 4+ messages in thread
From: Dandan Bi @ 2018-06-27  6:16 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Star Zeng

The perf measurement entry in SmmEntryPoint function
doesn't have significant meaning. So remove it now.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
 MdeModulePkg/Core/PiSmmCore/PiSmmCore.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
index 45f40e0e60c..2fb401e47e7 100644
--- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
+++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
@@ -642,12 +642,10 @@ SmmEntryPoint (
   BOOLEAN                     InLegacyBoot;
   BOOLEAN                     IsOverlapped;
   VOID                        *CommunicationBuffer;
   UINTN                       BufferSize;
 
-  PERF_INMODULE_BEGIN ("SMM");
-
   //
   // Update SMST with contents of the SmmEntryContext structure
   //
   gSmmCoreSmst.SmmStartupThisAp      = SmmEntryContext->SmmStartupThisAp;
   gSmmCoreSmst.CurrentlyExecutingCpu = SmmEntryContext->CurrentlyExecutingCpu;
@@ -736,12 +734,10 @@ SmmEntryPoint (
     //
     // Clear the InSmm flag as we are going to leave SMM
     //
     gSmmCorePrivate->InSmm = FALSE;
   }
-
-  PERF_INMODULE_END ("SMM");
 }
 
 /**
   Install LoadedImage protocol for SMM Core.
 **/
-- 
2.14.3.windows.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [patch] MdeModulePkg/PerformanceLib: Add NULL pointer check
  2018-06-27  6:16 [patch] MdeModulePkg/PiSmmCore: Remove SMM Perf entry Dandan Bi
@ 2018-06-27  6:16 ` Dandan Bi
  2018-06-27  7:22   ` Wu, Hao A
  2018-06-27  6:59 ` [patch] MdeModulePkg/PiSmmCore: Remove SMM Perf entry Gao, Liming
  1 sibling, 1 reply; 4+ messages in thread
From: Dandan Bi @ 2018-06-27  6:16 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Hao Wu

1. Add NULL pointer check for the "Guid" parameter
   when handle FPDT_DUAL_GUID_STRING_EVENT_TYPE.
2. Make the code logic in DxeCore/SmmCore/PeiPerformanceLib
   aligned when handle FPDT_DUAL_GUID_STRING_EVENT_TYPE.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
 .../DxeCorePerformanceLib/DxeCorePerformanceLib.c      | 18 ++++++++++++------
 .../Library/PeiPerformanceLib/PeiPerformanceLib.c      | 13 ++++++++-----
 .../SmmCorePerformanceLib/SmmCorePerformanceLib.c      | 18 ++++++++++++------
 3 files changed, 32 insertions(+), 17 deletions(-)

diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
index efff5134c7b..6e0c328c635 100644
--- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
+++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
@@ -1109,18 +1109,17 @@ InsertFpdtRecord (
 
   case PERF_EVENTSIGNAL_START_ID:
   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);
       FpdtRecordPtr.DualGuidStringEvent->Header.Revision  = FPDT_RECORD_REVISION_1;
       FpdtRecordPtr.DualGuidStringEvent->ProgressID       = PerfId;
@@ -1194,11 +1193,18 @@ InsertFpdtRecord (
     FpdtRecordPtr.DynamicStringEvent->Header.Type       = FPDT_DYNAMIC_STRING_EVENT_TYPE;
     FpdtRecordPtr.DynamicStringEvent->Header.Length     = sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
     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";
     }
     CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DynamicStringEvent->String, StringPtr, &FpdtRecordPtr.DynamicStringEvent->Header.Length);
 
diff --git a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c
index cd1b0e34ef7..3a44a0a438e 100644
--- a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c
+++ b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c
@@ -75,14 +75,14 @@ GetFpdtRecordPtr (
     //
     // PEI Performance HOB was found, then return the existing one.
     //
     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;
     }
     //
     // Previous HOB is used, then find next one.
@@ -421,23 +421,26 @@ InsertFpdtRecord (
 
   case PERF_EVENTSIGNAL_START_ID:
   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)) {
       FpdtRecordPtr.DualGuidStringEvent->Header.Type      = FPDT_DUAL_GUID_STRING_EVENT_TYPE;
       FpdtRecordPtr.DualGuidStringEvent->Header.Length    = sizeof (FPDT_DUAL_GUID_STRING_EVENT_RECORD);
       FpdtRecordPtr.DualGuidStringEvent->Header.Revision  = FPDT_RECORD_REVISION_1;
       FpdtRecordPtr.DualGuidStringEvent->ProgressID       = PerfId;
       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;
 
   case PERF_EVENT_ID:
   case PERF_FUNCTION_START_ID:
diff --git a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c
index 0c00fb51e82..f18c3fb60df 100644
--- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c
+++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c
@@ -647,18 +647,17 @@ InsertFpdtRecord (
 
   case PERF_EVENTSIGNAL_START_ID:
   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);
       FpdtRecordPtr.DualGuidStringEvent->Header.Revision  = FPDT_RECORD_REVISION_1;
       FpdtRecordPtr.DualGuidStringEvent->ProgressID       = PerfId;
@@ -732,11 +731,18 @@ InsertFpdtRecord (
     FpdtRecordPtr.DynamicStringEvent->Header.Type       = FPDT_DYNAMIC_STRING_EVENT_TYPE;
     FpdtRecordPtr.DynamicStringEvent->Header.Length     = sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
     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";
     }
     CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DynamicStringEvent->String, StringPtr, &FpdtRecordPtr.DynamicStringEvent->Header.Length);
 
-- 
2.14.3.windows.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [patch] MdeModulePkg/PiSmmCore: Remove SMM Perf entry
  2018-06-27  6:16 [patch] MdeModulePkg/PiSmmCore: Remove SMM Perf entry Dandan Bi
  2018-06-27  6:16 ` [patch] MdeModulePkg/PerformanceLib: Add NULL pointer check Dandan Bi
@ 2018-06-27  6:59 ` Gao, Liming
  1 sibling, 0 replies; 4+ messages in thread
From: Gao, Liming @ 2018-06-27  6:59 UTC (permalink / raw)
  To: Bi, Dandan, edk2-devel@lists.01.org; +Cc: Zeng, Star

Reviewed-by: Liming Gao <liming.gao@intel.com>

>-----Original Message-----
>From: Bi, Dandan
>Sent: Wednesday, June 27, 2018 2:16 PM
>To: edk2-devel@lists.01.org
>Cc: Gao, Liming <liming.gao@intel.com>; Zeng, Star <star.zeng@intel.com>
>Subject: [patch] MdeModulePkg/PiSmmCore: Remove SMM Perf entry
>
>The perf measurement entry in SmmEntryPoint function
>doesn't have significant meaning. So remove it now.
>
>Cc: Liming Gao <liming.gao@intel.com>
>Cc: Star Zeng <star.zeng@intel.com>
>Contributed-under: TianoCore Contribution Agreement 1.1
>Signed-off-by: Dandan Bi <dandan.bi@intel.com>
>---
> MdeModulePkg/Core/PiSmmCore/PiSmmCore.c | 4 ----
> 1 file changed, 4 deletions(-)
>
>diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
>b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
>index 45f40e0e60c..2fb401e47e7 100644
>--- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
>+++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
>@@ -642,12 +642,10 @@ SmmEntryPoint (
>   BOOLEAN                     InLegacyBoot;
>   BOOLEAN                     IsOverlapped;
>   VOID                        *CommunicationBuffer;
>   UINTN                       BufferSize;
>
>-  PERF_INMODULE_BEGIN ("SMM");
>-
>   //
>   // Update SMST with contents of the SmmEntryContext structure
>   //
>   gSmmCoreSmst.SmmStartupThisAp      = SmmEntryContext-
>>SmmStartupThisAp;
>   gSmmCoreSmst.CurrentlyExecutingCpu = SmmEntryContext-
>>CurrentlyExecutingCpu;
>@@ -736,12 +734,10 @@ SmmEntryPoint (
>     //
>     // Clear the InSmm flag as we are going to leave SMM
>     //
>     gSmmCorePrivate->InSmm = FALSE;
>   }
>-
>-  PERF_INMODULE_END ("SMM");
> }
>
> /**
>   Install LoadedImage protocol for SMM Core.
> **/
>--
>2.14.3.windows.1



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] MdeModulePkg/PerformanceLib: Add NULL pointer check
  2018-06-27  6:16 ` [patch] MdeModulePkg/PerformanceLib: Add NULL pointer check Dandan Bi
@ 2018-06-27  7:22   ` Wu, Hao A
  0 siblings, 0 replies; 4+ messages in thread
From: Wu, Hao A @ 2018-06-27  7:22 UTC (permalink / raw)
  To: Bi, Dandan, edk2-devel@lists.01.org; +Cc: Gao, Liming

The patch seems good to me.
Reviewed-by: Hao Wu <hao.a.wu@intel.com>


Best Regards,
Hao Wu


> -----Original Message-----
> From: Bi, Dandan
> Sent: Wednesday, June 27, 2018 2:16 PM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming; Wu, Hao A
> Subject: [patch] MdeModulePkg/PerformanceLib: Add NULL pointer check
> 
> 1. Add NULL pointer check for the "Guid" parameter
>    when handle FPDT_DUAL_GUID_STRING_EVENT_TYPE.
> 2. Make the code logic in DxeCore/SmmCore/PeiPerformanceLib
>    aligned when handle FPDT_DUAL_GUID_STRING_EVENT_TYPE.
> 
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Hao Wu <hao.a.wu@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Dandan Bi <dandan.bi@intel.com>
> ---
>  .../DxeCorePerformanceLib/DxeCorePerformanceLib.c      | 18 ++++++++++++-
> -----
>  .../Library/PeiPerformanceLib/PeiPerformanceLib.c      | 13 ++++++++-----
>  .../SmmCorePerformanceLib/SmmCorePerformanceLib.c      | 18
> ++++++++++++------
>  3 files changed, 32 insertions(+), 17 deletions(-)
> 
> diff --git
> a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
> b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
> index efff5134c7b..6e0c328c635 100644
> ---
> a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
> +++
> b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
> @@ -1109,18 +1109,17 @@ InsertFpdtRecord (
> 
>    case PERF_EVENTSIGNAL_START_ID:
>    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);
>        FpdtRecordPtr.DualGuidStringEvent->Header.Revision  =
> FPDT_RECORD_REVISION_1;
>        FpdtRecordPtr.DualGuidStringEvent->ProgressID       = PerfId;
> @@ -1194,11 +1193,18 @@ InsertFpdtRecord (
>      FpdtRecordPtr.DynamicStringEvent->Header.Type       =
> FPDT_DYNAMIC_STRING_EVENT_TYPE;
>      FpdtRecordPtr.DynamicStringEvent->Header.Length     = sizeof
> (FPDT_DYNAMIC_STRING_EVENT_RECORD);
>      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";
>      }
>      CopyStringIntoPerfRecordAndUpdateLength
> (FpdtRecordPtr.DynamicStringEvent->String, StringPtr,
> &FpdtRecordPtr.DynamicStringEvent->Header.Length);
> 
> diff --git a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c
> b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c
> index cd1b0e34ef7..3a44a0a438e 100644
> --- a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c
> +++ b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c
> @@ -75,14 +75,14 @@ GetFpdtRecordPtr (
>      //
>      // PEI Performance HOB was found, then return the existing one.
>      //
>      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;
>      }
>      //
>      // Previous HOB is used, then find next one.
> @@ -421,23 +421,26 @@ InsertFpdtRecord (
> 
>    case PERF_EVENTSIGNAL_START_ID:
>    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)) {
>        FpdtRecordPtr.DualGuidStringEvent->Header.Type      =
> FPDT_DUAL_GUID_STRING_EVENT_TYPE;
>        FpdtRecordPtr.DualGuidStringEvent->Header.Length    = sizeof
> (FPDT_DUAL_GUID_STRING_EVENT_RECORD);
>        FpdtRecordPtr.DualGuidStringEvent->Header.Revision  =
> FPDT_RECORD_REVISION_1;
>        FpdtRecordPtr.DualGuidStringEvent->ProgressID       = PerfId;
>        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;
> 
>    case PERF_EVENT_ID:
>    case PERF_FUNCTION_START_ID:
> diff --git
> a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib
> .c
> b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib
> .c
> index 0c00fb51e82..f18c3fb60df 100644
> ---
> a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib
> .c
> +++
> b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib
> .c
> @@ -647,18 +647,17 @@ InsertFpdtRecord (
> 
>    case PERF_EVENTSIGNAL_START_ID:
>    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);
>        FpdtRecordPtr.DualGuidStringEvent->Header.Revision  =
> FPDT_RECORD_REVISION_1;
>        FpdtRecordPtr.DualGuidStringEvent->ProgressID       = PerfId;
> @@ -732,11 +731,18 @@ InsertFpdtRecord (
>      FpdtRecordPtr.DynamicStringEvent->Header.Type       =
> FPDT_DYNAMIC_STRING_EVENT_TYPE;
>      FpdtRecordPtr.DynamicStringEvent->Header.Length     = sizeof
> (FPDT_DYNAMIC_STRING_EVENT_RECORD);
>      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";
>      }
>      CopyStringIntoPerfRecordAndUpdateLength
> (FpdtRecordPtr.DynamicStringEvent->String, StringPtr,
> &FpdtRecordPtr.DynamicStringEvent->Header.Length);
> 
> --
> 2.14.3.windows.1



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-06-27  7:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-27  6:16 [patch] MdeModulePkg/PiSmmCore: Remove SMM Perf entry Dandan Bi
2018-06-27  6:16 ` [patch] MdeModulePkg/PerformanceLib: Add NULL pointer check Dandan Bi
2018-06-27  7:22   ` Wu, Hao A
2018-06-27  6:59 ` [patch] MdeModulePkg/PiSmmCore: Remove SMM Perf entry Gao, Liming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox