diff options
author | Chen A Chen <chen.a.chen@intel.com> | 2019-02-28 11:15:51 +0800 |
---|---|---|
committer | Zhang, Chao B <chao.b.zhang@intel.com> | 2019-03-01 14:06:30 +0800 |
commit | c3947b54235c93e4f41d6d56b1f5296a9f8021d5 (patch) | |
tree | 4efc75629e21acafd5b7794786ac1e1349090f60 | |
parent | 2a93cccc24cfca12c66f13a41d52fb0a82fb924e (diff) | |
download | edk2-c3947b54235c93e4f41d6d56b1f5296a9f8021d5.tar.gz edk2-c3947b54235c93e4f41d6d56b1f5296a9f8021d5.tar.bz2 edk2-c3947b54235c93e4f41d6d56b1f5296a9f8021d5.zip |
UefiCpuPkg/Microcode: Fix InComplete CheckSum32 issue
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>
Reviewed-by: Ray Ni <ray.ni@intel.com>
-rw-r--r-- | UefiCpuPkg/Library/MpInitLib/Microcode.c | 37 |
1 files 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
|