IntelSiliconPkg/MicrocodeUpdateDxe: Refine debug messages
[mirror_edk2.git] / IntelSiliconPkg / Feature / Capsule / MicrocodeUpdateDxe / MicrocodeUpdate.c
index 65729e3..2cb0adb 100644 (file)
@@ -445,7 +445,7 @@ VerifyMicrocode (
     return EFI_VOLUME_CORRUPTED;\r
   }\r
   if (TotalSize != ImageSize) {\r
-    DEBUG((DEBUG_ERROR, "VerifyMicrocode - fail on TotalSize\n"));\r
+    DEBUG((DEBUG_ERROR, "VerifyMicrocode - TotalSize not equal to ImageSize\n"));\r
     *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT;\r
     if (AbortReason != NULL) {\r
       *AbortReason = AllocateCopyPool(sizeof(L"InvalidTotalSize"), L"InvalidTotalSize");\r
@@ -507,16 +507,25 @@ VerifyMicrocode (
       //\r
       if ((ExtendedTableLength > sizeof(CPU_MICROCODE_EXTENDED_TABLE_HEADER)) && ((ExtendedTableLength & 0x3) == 0)) {\r
         CheckSum32 = CalculateSum32((UINT32 *)ExtendedTableHeader, ExtendedTableLength);\r
-        if (CheckSum32 == 0) {\r
+        if (CheckSum32 != 0) {\r
+          //\r
+          // Checksum incorrect\r
+          //\r
+          DEBUG((DEBUG_ERROR, "VerifyMicrocode - The checksum for extended table is incorrect\n"));\r
+        } else {\r
           //\r
           // Checksum correct\r
           //\r
           ExtendedTableCount = ExtendedTableHeader->ExtendedSignatureCount;\r
-          if (ExtendedTableCount <= (ExtendedTableLength - sizeof(CPU_MICROCODE_EXTENDED_TABLE_HEADER)) / sizeof(CPU_MICROCODE_EXTENDED_TABLE)) {\r
+          if (ExtendedTableCount > (ExtendedTableLength - sizeof(CPU_MICROCODE_EXTENDED_TABLE_HEADER)) / sizeof(CPU_MICROCODE_EXTENDED_TABLE)) {\r
+            DEBUG((DEBUG_ERROR, "VerifyMicrocode - ExtendedTableCount too big\n"));\r
+          } else {\r
             ExtendedTable = (CPU_MICROCODE_EXTENDED_TABLE *)(ExtendedTableHeader + 1);\r
             for (Index = 0; Index < ExtendedTableCount; Index++) {\r
               CheckSum32 = CalculateSum32((UINT32 *)ExtendedTable, sizeof(CPU_MICROCODE_EXTENDED_TABLE));\r
-              if (CheckSum32 == 0) {\r
+              if (CheckSum32 != 0) {\r
+                DEBUG((DEBUG_ERROR, "VerifyMicrocode - The checksum for ExtendedTable entry with index 0x%x is incorrect\n", Index));\r
+              } else {\r
                 //\r
                 // Verify Header\r
                 //\r
@@ -537,7 +546,7 @@ VerifyMicrocode (
     }\r
     if (!CorrectMicrocode) {\r
       if (TryLoad) {\r
-        DEBUG((DEBUG_ERROR, "VerifyMicrocode - fail on CurrentProcessorSignature/ProcessorFlags\n"));\r
+        DEBUG((DEBUG_ERROR, "VerifyMicrocode - fail on Current ProcessorSignature/ProcessorFlags\n"));\r
       }\r
       *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INCORRECT_VERSION;\r
       if (AbortReason != NULL) {\r