]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/CpuMpPei: Load microcode if found newer revision
authorJeff Fan <jeff.fan@intel.com>
Wed, 2 Mar 2016 01:45:14 +0000 (09:45 +0800)
committerJeff Fan <jeff.fan@intel.com>
Thu, 3 Mar 2016 01:10:15 +0000 (09:10 +0800)
Current implementation only loads the latest revision if there is no microcode
loaded. Per IA32 User Manual, we should load the newer revision by comparing
the existing microcode loaded with the updating revision.

Cc: Feng Tian <feng.tian@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
Reviewed-by: Michael Kinney <michael.d.kinney@intel.com>
UefiCpuPkg/CpuMpPei/Microcode.c

index 70e149be877262973e67fd36cd990f432a23a037..9dcbf99db3b6e5d676ac2d5d12bbaacaeadcc4ec 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implementation of loading microcode on processors.\r
 \r
 /** @file\r
   Implementation of loading microcode on processors.\r
 \r
-  Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2015 - 2016, 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
   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
@@ -57,7 +57,6 @@ MicrocodeDetect (
   UINTN                                   TotalSize;\r
   UINT32                                  CheckSum32;\r
   BOOLEAN                                 CorrectMicrocode;\r
   UINTN                                   TotalSize;\r
   UINT32                                  CheckSum32;\r
   BOOLEAN                                 CorrectMicrocode;\r
-  INT32                                   CurrentSignature;\r
   MICROCODE_INFO                          MicrocodeInfo;\r
 \r
   ZeroMem (&MicrocodeInfo, sizeof (MICROCODE_INFO));\r
   MICROCODE_INFO                          MicrocodeInfo;\r
 \r
   ZeroMem (&MicrocodeInfo, sizeof (MICROCODE_INFO));\r
@@ -181,17 +180,20 @@ MicrocodeDetect (
 \r
   if (LatestRevision > 0) {\r
     //\r
 \r
   if (LatestRevision > 0) {\r
     //\r
-    // Get microcode update signature of currently loaded microcode update\r
+    // BIOS only authenticate updates that contain a numerically larger revision\r
+    // than the currently loaded revision, where Current Signature < New Update\r
+    // Revision. A processor with no loaded update is considered to have a\r
+    // revision equal to zero.\r
     //\r
     //\r
-    CurrentSignature = GetCurrentMicrocodeSignature ();\r
-    //\r
-    // If no microcode update has been loaded, then trigger microcode load.\r
-    //\r
-    if (CurrentSignature == 0) {\r
+    if (LatestRevision > GetCurrentMicrocodeSignature ()) {\r
       AsmWriteMsr64 (\r
         EFI_MSR_IA32_BIOS_UPDT_TRIG,\r
         (UINT64) (UINTN) MicrocodeInfo.MicrocodeData\r
         );\r
       AsmWriteMsr64 (\r
         EFI_MSR_IA32_BIOS_UPDT_TRIG,\r
         (UINT64) (UINTN) MicrocodeInfo.MicrocodeData\r
         );\r
+      //\r
+      // Get and verify new microcode signature\r
+      //\r
+      ASSERT (LatestRevision == GetCurrentMicrocodeSignature ());\r
       MicrocodeInfo.Load = TRUE;\r
     } else {\r
       MicrocodeInfo.Load = FALSE;\r
       MicrocodeInfo.Load = TRUE;\r
     } else {\r
       MicrocodeInfo.Load = FALSE;\r