]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg: Remove alignment check when calculate microcode size.
authorSiyuan Fu <siyuan.fu@intel.com>
Fri, 3 Jan 2020 07:11:51 +0000 (15:11 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 8 Jan 2020 00:47:43 +0000 (00:47 +0000)
This patch removes the unnecessary alignment check on microcode patch
TotalSize introduced by commit d786a172. The TotalSize has already been
checked with 1K alignment and MAX_ADDRESS in previous code as below:

    if ( (UINTN)MicrocodeEntryPoint > (MAX_ADDRESS - TotalSize) ||
         ((UINTN)MicrocodeEntryPoint + TotalSize) > MicrocodeEnd ||
         (DataSize & 0x3) != 0 ||
         (TotalSize & (SIZE_1KB - 1)) != 0 ||
         TotalSize < DataSize
       ) {

Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Signed-off-by: Siyuan Fu <siyuan.fu@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
UefiCpuPkg/Library/MpInitLib/Microcode.c
UefiCpuPkg/Library/MpInitLib/MpLib.h

index 3da5bfb9cf2f9a4a4293a0967b80323e6480474c..a9d06dd4099a81b1f0e557cec1cacab884c6e8b5 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implementation of loading microcode on processors.\r
 \r
-  Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2015 - 2020, Intel Corporation. All rights reserved.<BR>\r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
@@ -397,16 +397,7 @@ LoadMicrocodePatchWorker (
       Patches[Index].Size\r
       );\r
 \r
-    //\r
-    // Zero-fill the padding area\r
-    // Please note that AlignedSize will be no less than Size\r
-    //\r
-    ZeroMem (\r
-      Walker + Patches[Index].Size,\r
-      Patches[Index].AlignedSize - Patches[Index].Size\r
-      );\r
-\r
-    Walker += Patches[Index].AlignedSize;\r
+    Walker += Patches[Index].Size;\r
   }\r
 \r
   //\r
@@ -578,14 +569,9 @@ LoadMicrocodePatch (
       //\r
       // Store the information of this microcode patch\r
       //\r
-      if (TotalSize > ALIGN_VALUE (TotalSize, SIZE_1KB) ||\r
-          ALIGN_VALUE (TotalSize, SIZE_1KB) > MAX_UINTN - TotalLoadSize) {\r
-        goto OnExit;\r
-      }\r
-      PatchInfoBuffer[PatchCount - 1].Address     = (UINTN) MicrocodeEntryPoint;\r
-      PatchInfoBuffer[PatchCount - 1].Size        = TotalSize;\r
-      PatchInfoBuffer[PatchCount - 1].AlignedSize = ALIGN_VALUE (TotalSize, SIZE_1KB);\r
-      TotalLoadSize += PatchInfoBuffer[PatchCount - 1].AlignedSize;\r
+      PatchInfoBuffer[PatchCount - 1].Address = (UINTN) MicrocodeEntryPoint;\r
+      PatchInfoBuffer[PatchCount - 1].Size    = TotalSize;\r
+      TotalLoadSize += TotalSize;\r
     }\r
 \r
     //\r
index 6609c958ce8a63b29f92f5656d58152cdf30babf..b6e5a1afab0044cdde2e82abb6b4c6504a1e98b3 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Common header file for MP Initialize Library.\r
 \r
-  Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2016 - 2020, Intel Corporation. All rights reserved.<BR>\r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
@@ -54,7 +54,6 @@
 typedef struct {\r
   UINTN    Address;\r
   UINTN    Size;\r
-  UINTN    AlignedSize;\r
 } MICROCODE_PATCH_INFO;\r
 \r
 //\r