Fix LoaderVersion and UpdateVersion handling in MCU

This commit is contained in:
vit9696 2019-09-05 23:38:53 +03:00
parent 8bddbe7d1f
commit 967375243c
2 changed files with 10 additions and 8 deletions

View File

@ -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))

View File

@ -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.