]> git.proxmox.com Git - mirror_edk2.git/commitdiff
IntelSiliconPkg MicrocodeUpdateDxe: TotalSize must be multiples of 1KB
authorStar Zeng <star.zeng@intel.com>
Thu, 21 Dec 2017 02:57:04 +0000 (10:57 +0800)
committerStar Zeng <star.zeng@intel.com>
Fri, 26 Jan 2018 10:21:04 +0000 (18:21 +0800)
TotalSize must be multiples of 1024 bytes (1 KBytes) according to SDM.

Also enhance the debug message for DataSize that must be
multiples of DWORDs.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Rangasai V Chaganty <rangasai.v.chaganty@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
IntelSiliconPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.c

index b99221c9696d0ab57385ddedea8a30b252ed87f0..65729e30a019b2bcc1cc768c9b28e13a544a0cd9 100644 (file)
@@ -8,7 +8,7 @@
 \r
   MicrocodeWrite() and VerifyMicrocode() will receive untrusted input and do basic validation.\r
 \r
-  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -421,7 +421,7 @@ VerifyMicrocode (
     return EFI_INCOMPATIBLE_VERSION;\r
   }\r
   //\r
-  // Check Size\r
+  // Check TotalSize\r
   //\r
   if (MicrocodeEntryPoint->DataSize == 0) {\r
     TotalSize = 2048;\r
@@ -436,6 +436,14 @@ VerifyMicrocode (
     }\r
     return EFI_VOLUME_CORRUPTED;\r
   }\r
+  if ((TotalSize & (SIZE_1KB - 1)) != 0) {\r
+    DEBUG((DEBUG_ERROR, "VerifyMicrocode - TotalSize is not multiples of 1024 bytes (1 KBytes)\n"));\r
+    *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT;\r
+    if (AbortReason != NULL) {\r
+      *AbortReason = AllocateCopyPool(sizeof(L"InvalidTotalSize"), L"InvalidTotalSize");\r
+    }\r
+    return EFI_VOLUME_CORRUPTED;\r
+  }\r
   if (TotalSize != ImageSize) {\r
     DEBUG((DEBUG_ERROR, "VerifyMicrocode - fail on TotalSize\n"));\r
     *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT;\r
@@ -445,7 +453,7 @@ VerifyMicrocode (
     return EFI_VOLUME_CORRUPTED;\r
   }\r
   //\r
-  // Check CheckSum32\r
+  // Check DataSize\r
   //\r
   if (MicrocodeEntryPoint->DataSize == 0) {\r
     DataSize = 2048 - sizeof(CPU_MICROCODE_HEADER);\r
@@ -461,13 +469,16 @@ VerifyMicrocode (
     return EFI_VOLUME_CORRUPTED;\r
   }\r
   if ((DataSize & 0x3) != 0) {\r
-    DEBUG((DEBUG_ERROR, "VerifyMicrocode - DataSize not aligned\n"));\r
+    DEBUG((DEBUG_ERROR, "VerifyMicrocode - DataSize is not multiples of DWORDs\n"));\r
     *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT;\r
     if (AbortReason != NULL) {\r
       *AbortReason = AllocateCopyPool(sizeof(L"InvalidDataSize"), L"InvalidDataSize");\r
     }\r
     return EFI_VOLUME_CORRUPTED;\r
   }\r
+  //\r
+  // Check CheckSum32\r
+  //\r
   CheckSum32 = CalculateSum32((UINT32 *)MicrocodeEntryPoint, DataSize + sizeof(CPU_MICROCODE_HEADER));\r
   if (CheckSum32 != 0) {\r
     DEBUG((DEBUG_ERROR, "VerifyMicrocode - fail on CheckSum32\n"));\r