public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Chen A Chen <chen.a.chen@intel.com>
To: edk2-devel@lists.01.org
Cc: Chen A Chen <chen.a.chen@intel.com>, Ray Ni <ray.ni@intel.com>,
	Eric Dong <eric.dong@intel.com>
Subject: [PATCH 1/2] UefiCpuPkg/Microcode: Fix InComplete CheckSum32 issue
Date: Thu, 28 Feb 2019 14:02:51 +0800	[thread overview]
Message-ID: <20190228060252.23944-2-chen.a.chen@intel.com> (raw)
In-Reply-To: <20190228060252.23944-1-chen.a.chen@intel.com>

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1020

The Microcode region indicated by MicrocodePatchAddress PCD may contain
more than one Microcode entry. We should save InCompleteCheckSum32 value
for each payload. Move the logic for calculate InCompleteCheckSum32 from
the outsize of the do-while loop to the inside.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chen A Chen <chen.a.chen@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
---
 UefiCpuPkg/Library/MpInitLib/Microcode.c | 37 ++++++++++++++++----------------
 1 file changed, 19 insertions(+), 18 deletions(-)

diff --git a/UefiCpuPkg/Library/MpInitLib/Microcode.c b/UefiCpuPkg/Library/MpInitLib/Microcode.c
index e1f661d6b1..5f9ae22794 100644
--- a/UefiCpuPkg/Library/MpInitLib/Microcode.c
+++ b/UefiCpuPkg/Library/MpInitLib/Microcode.c
@@ -159,30 +159,31 @@ MicrocodeDetect (
   MicrocodeEnd = (UINTN) (CpuMpData->MicrocodePatchAddress + CpuMpData->MicrocodePatchRegionSize);
   MicrocodeEntryPoint = (CPU_MICROCODE_HEADER *) (UINTN) CpuMpData->MicrocodePatchAddress;
 
-  //
-  // Save an in-complete CheckSum32 from CheckSum Part1 for common parts.
-  //
-  if (MicrocodeEntryPoint->DataSize == 0) {
-    InCompleteCheckSum32 = CalculateSum32 (
-                             (UINT32 *) MicrocodeEntryPoint,
-                             sizeof (CPU_MICROCODE_HEADER) + 2000
-                             );
-  } else {
-    InCompleteCheckSum32 = CalculateSum32 (
-                             (UINT32 *) MicrocodeEntryPoint,
-                             sizeof (CPU_MICROCODE_HEADER) + MicrocodeEntryPoint->DataSize
-                             );
-  }
-  InCompleteCheckSum32 -= MicrocodeEntryPoint->ProcessorSignature.Uint32;
-  InCompleteCheckSum32 -= MicrocodeEntryPoint->ProcessorFlags;
-  InCompleteCheckSum32 -= MicrocodeEntryPoint->Checksum;
-
   do {
     //
     // Check if the microcode is for the Cpu and the version is newer
     // and the update can be processed on the platform
     //
     CorrectMicrocode = FALSE;
+
+    //
+    // Save an in-complete CheckSum32 from CheckSum Part1 for common parts.
+    //
+    if (MicrocodeEntryPoint->DataSize == 0) {
+      InCompleteCheckSum32 = CalculateSum32 (
+                               (UINT32 *) MicrocodeEntryPoint,
+                               sizeof (CPU_MICROCODE_HEADER) + 2000
+                               );
+    } else {
+      InCompleteCheckSum32 = CalculateSum32 (
+                               (UINT32 *) MicrocodeEntryPoint,
+                               sizeof (CPU_MICROCODE_HEADER) + MicrocodeEntryPoint->DataSize
+                               );
+    }
+    InCompleteCheckSum32 -= MicrocodeEntryPoint->ProcessorSignature.Uint32;
+    InCompleteCheckSum32 -= MicrocodeEntryPoint->ProcessorFlags;
+    InCompleteCheckSum32 -= MicrocodeEntryPoint->Checksum;
+
     if (MicrocodeEntryPoint->HeaderVersion == 0x1) {
       //
       // It is the microcode header. It is not the padding data between microcode patches
-- 
2.16.2.windows.1



  reply	other threads:[~2019-02-28  6:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-28  6:02 [PATCH 0/2] Fix Microcode failure issue Chen A Chen
2019-02-28  6:02 ` Chen A Chen [this message]
2019-02-28  6:14   ` [PATCH 1/2] UefiCpuPkg/Microcode: Fix InComplete CheckSum32 issue Ni, Ray
2019-02-28  6:02 ` [PATCH 2/2] UefiCpuPkg/Microcode: Add verification logic before parsing payload Chen A Chen
2019-02-28  6:54   ` Ni, Ray

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190228060252.23944-2-chen.a.chen@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox