]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelSiliconPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.c
IntelSiliconPkg/MicrocodeUpdate: Fix incorrect checksum issue
[mirror_edk2.git] / IntelSiliconPkg / Feature / Capsule / MicrocodeUpdateDxe / MicrocodeUpdate.c
index 9098712c2fc84a4821fa12daa4d1d42e1335cc42..e45c7a8def0d104dda1d21ffa1112e00fe312e61 100644 (file)
@@ -390,6 +390,7 @@ VerifyMicrocode (
   UINTN                                   DataSize;\r
   UINT32                                  CurrentRevision;\r
   PROCESSOR_INFO                          *ProcessorInfo;\r
+  UINT32                                  InCompleteCheckSum32;\r
   UINT32                                  CheckSum32;\r
   UINTN                                   ExtendedTableLength;\r
   UINT32                                  ExtendedTableCount;\r
@@ -488,6 +489,10 @@ VerifyMicrocode (
     }\r
     return EFI_VOLUME_CORRUPTED;\r
   }\r
+  InCompleteCheckSum32 = CheckSum32;\r
+  InCompleteCheckSum32 -= MicrocodeEntryPoint->ProcessorSignature.Uint32;\r
+  InCompleteCheckSum32 -= MicrocodeEntryPoint->ProcessorFlags;\r
+  InCompleteCheckSum32 -= MicrocodeEntryPoint->Checksum;\r
 \r
   //\r
   // Check ProcessorSignature/ProcessorFlags\r
@@ -518,11 +523,14 @@ VerifyMicrocode (
           //\r
           ExtendedTableCount = ExtendedTableHeader->ExtendedSignatureCount;\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
+            DEBUG((DEBUG_ERROR, "VerifyMicrocode - ExtendedTableCount %d is too big\n", ExtendedTableCount));\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
+              CheckSum32 = InCompleteCheckSum32;\r
+              CheckSum32 += ExtendedTable->ProcessorSignature.Uint32;\r
+              CheckSum32 += ExtendedTable->ProcessorFlag;\r
+              CheckSum32 += ExtendedTable->Checksum;\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