From 967375243cb14d977a1c1660d6bda29538583255 Mon Sep 17 00:00:00 2001 From: vit9696 Date: Thu, 5 Sep 2019 23:38:53 +0300 Subject: [PATCH] Fix LoaderVersion and UpdateVersion handling in MCU --- common/ffsparser.cpp | 14 ++++++++------ common/fit.h | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/common/ffsparser.cpp b/common/ffsparser.cpp index 9877d32..185f9c4 100644 --- a/common/ffsparser.cpp +++ b/common/ffsparser.cpp @@ -1280,12 +1280,15 @@ BOOLEAN FfsParser::microcodeHeaderValid(const INTEL_MICROCODE_HEADER* ucodeHeade ucodeHeader->DateYear > 0x2049) { return FALSE; } - - // Check LoaderRevision to be less than 0x100 - if (ucodeHeader->LoaderRevision > 0xFF) { + // Check UpdateVersion to be 1. + if (ucodeHeader->UpdateVersion != 1) { return FALSE; } - + // Check LoaderVersion to be 1. + if (ucodeHeader->LoaderVersion != 1) { + return FALSE; + } + return TRUE; } @@ -4356,7 +4359,7 @@ USTATUS FfsParser::parseIntelMicrocodeHeader(const UByteArray & microcode, const // Add info UString name("Intel microcode"); UString info = usprintf("Full size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\nTail size: %Xh (%u)\n" - "Date: %02X.%02X.%04x\nCPU signature: %08Xh\nRevision: %08Xh\nLoader revision: %08Xh\nCPU flags: %02Xh\nChecksum: %08Xh, ", + "Date: %02X.%02X.%04x\nCPU signature: %08Xh\nRevision: %08Xh\nCPU flags: %02Xh\nChecksum: %08Xh, ", dataSize, dataSize, header.size(), header.size(), body.size(), body.size(), @@ -4366,7 +4369,6 @@ USTATUS FfsParser::parseIntelMicrocodeHeader(const UByteArray & microcode, const ucodeHeader->DateYear, ucodeHeader->CpuSignature, ucodeHeader->Revision, - ucodeHeader->LoaderRevision, ucodeHeader->CpuFlags, ucodeHeader->Checksum) + (ucodeHeader->Checksum == calculated ? UString("valid") : usprintf("invalid, should be %08Xh", calculated)) diff --git a/common/fit.h b/common/fit.h index 62e4f43..8e00c8c 100755 --- a/common/fit.h +++ b/common/fit.h @@ -60,7 +60,7 @@ typedef struct { // This scructure is described in Section 9.11.1 of the Intel Software Developer manual Volume 3A Part 1 typedef struct INTEL_MICROCODE_HEADER_ { - UINT32 Version; // 0x00000001 + UINT32 UpdateVersion; // 0x00000001 UINT32 Revision; UINT16 DateYear; // BCD UINT8 DateDay; // BCD @@ -69,7 +69,7 @@ typedef struct INTEL_MICROCODE_HEADER_ { UINT32 Checksum; // Checksum of Update Data and Header. Used to verify the integrity of the update header and data. // Checksum is correct when the summation of all the DWORDs (including the extended Processor Signature Table) // that comprise the microcode update result in 00000000H. - UINT32 LoaderRevision; // Sane values are less than 0x100 + UINT32 LoaderVersion; // 0x00000001 UINT8 CpuFlags; UINT8 CpuFlagsReserved[3]; // Zeroes UINT32 DataSize; // Specifies the size of the encrypted data in bytes, and must be a multiple of DWORDs.