Update field names in microcode struct as in EDK II

This commit is contained in:
vit9696 2019-09-06 23:16:26 +03:00
parent 967375243c
commit f2e343d8bf
2 changed files with 40 additions and 40 deletions

View File

@ -1233,8 +1233,8 @@ BOOLEAN FfsParser::microcodeHeaderValid(const INTEL_MICROCODE_HEADER* ucodeHeade
} }
// Check CpuFlags reserved bytes to be zero // Check CpuFlags reserved bytes to be zero
for (UINT32 i = 0; i < sizeof(ucodeHeader->CpuFlagsReserved); i++) { for (UINT32 i = 0; i < sizeof(ucodeHeader->ProcessorFlagsReserved); i++) {
if (ucodeHeader->CpuFlagsReserved[i] != 0x00) { if (ucodeHeader->ProcessorFlagsReserved[i] != 0x00) {
reservedBytesValid = false; reservedBytesValid = false;
break; break;
} }
@ -1280,12 +1280,12 @@ BOOLEAN FfsParser::microcodeHeaderValid(const INTEL_MICROCODE_HEADER* ucodeHeade
ucodeHeader->DateYear > 0x2049) { ucodeHeader->DateYear > 0x2049) {
return FALSE; return FALSE;
} }
// Check UpdateVersion to be 1. // Check HeaderVersion to be 1.
if (ucodeHeader->UpdateVersion != 1) { if (ucodeHeader->HeaderVersion != 1) {
return FALSE; return FALSE;
} }
// Check LoaderVersion to be 1. // Check LoaderRevision to be 1.
if (ucodeHeader->LoaderVersion != 1) { if (ucodeHeader->LoaderRevision != 1) {
return FALSE; return FALSE;
} }
@ -3845,8 +3845,8 @@ USTATUS FfsParser::parseFitEntryMicrocode(const UByteArray & microcode, const UI
// Valid microcode found // Valid microcode found
info = usprintf("CpuSignature: %08Xh, Revision: %08Xh, Date: %02X.%02X.%04X", info = usprintf("CpuSignature: %08Xh, Revision: %08Xh, Date: %02X.%02X.%04X",
ucodeHeader->CpuSignature, ucodeHeader->ProcessorSignature,
ucodeHeader->Revision, ucodeHeader->UpdateRevision,
ucodeHeader->DateDay, ucodeHeader->DateDay,
ucodeHeader->DateMonth, ucodeHeader->DateMonth,
ucodeHeader->DateYear); ucodeHeader->DateYear);
@ -4343,13 +4343,13 @@ USTATUS FfsParser::parseIntelMicrocodeHeader(const UByteArray & microcode, const
// Recalculate checksum after patching // Recalculate checksum after patching
tempUcodeHeader->Checksum = 0; tempUcodeHeader->Checksum = 0;
tempUcodeHeader->CpuFlags = entry->CpuFlags; tempUcodeHeader->ProcessorFlags = entry->ProcessorFlags;
tempUcodeHeader->CpuSignature = entry->CpuSignature; tempUcodeHeader->ProcessorSignature = entry->ProcessorSignature;
UINT32 entryCalculated = calculateChecksum32((const UINT32*)tempMicrocode.constData(), sizeof(INTEL_MICROCODE_HEADER) + dataSize); UINT32 entryCalculated = calculateChecksum32((const UINT32*)tempMicrocode.constData(), sizeof(INTEL_MICROCODE_HEADER) + dataSize);
extendedHeaderInfo += usprintf("\nCPU signature #%u: %08Xh\nCPU flags #%u: %02Xh\nChecksum #%u: %08Xh, ", extendedHeaderInfo += usprintf("\nCPU signature #%u: %08Xh\nCPU flags #%u: %02Xh\nChecksum #%u: %08Xh, ",
i + 1, entry->CpuSignature, i + 1, entry->ProcessorSignature,
i + 1, entry->CpuFlags, i + 1, entry->ProcessorFlags,
i + 1, entry->Checksum) i + 1, entry->Checksum)
+ (entry->Checksum == entryCalculated ? UString("valid") : usprintf("invalid, should be %08Xh", entryCalculated)); + (entry->Checksum == entryCalculated ? UString("valid") : usprintf("invalid, should be %08Xh", entryCalculated));
} }
@ -4367,9 +4367,9 @@ USTATUS FfsParser::parseIntelMicrocodeHeader(const UByteArray & microcode, const
ucodeHeader->DateDay, ucodeHeader->DateDay,
ucodeHeader->DateMonth, ucodeHeader->DateMonth,
ucodeHeader->DateYear, ucodeHeader->DateYear,
ucodeHeader->CpuSignature, ucodeHeader->ProcessorSignature,
ucodeHeader->Revision, ucodeHeader->UpdateRevision,
ucodeHeader->CpuFlags, ucodeHeader->ProcessorFlags,
ucodeHeader->Checksum) ucodeHeader->Checksum)
+ (ucodeHeader->Checksum == calculated ? UString("valid") : usprintf("invalid, should be %08Xh", calculated)) + (ucodeHeader->Checksum == calculated ? UString("valid") : usprintf("invalid, should be %08Xh", calculated))
+ extendedHeaderInfo; + extendedHeaderInfo;

View File

@ -60,26 +60,26 @@ typedef struct {
// This scructure is described in Section 9.11.1 of the Intel Software Developer manual Volume 3A Part 1 // This scructure is described in Section 9.11.1 of the Intel Software Developer manual Volume 3A Part 1
typedef struct INTEL_MICROCODE_HEADER_ { typedef struct INTEL_MICROCODE_HEADER_ {
UINT32 UpdateVersion; // 0x00000001 UINT32 HeaderVersion; // 0x00000001
UINT32 Revision; UINT32 UpdateRevision;
UINT16 DateYear; // BCD UINT16 DateYear; // BCD
UINT8 DateDay; // BCD UINT8 DateDay; // BCD
UINT8 DateMonth; // BCD UINT8 DateMonth; // BCD
UINT32 CpuSignature; UINT32 ProcessorSignature;
UINT32 Checksum; // Checksum of Update Data and Header. Used to verify the integrity of the update header and data. 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) // Checksum is correct when the summation of all the DWORDs (including the extended Processor Signature Table)
// that comprise the microcode update result in 00000000H. // that comprise the microcode update result in 00000000H.
UINT32 LoaderVersion; // 0x00000001 UINT32 LoaderRevision; // 0x00000001
UINT8 CpuFlags; UINT8 ProcessorFlags;
UINT8 CpuFlagsReserved[3]; // Zeroes UINT8 ProcessorFlagsReserved[3]; // Zeroes
UINT32 DataSize; // Specifies the size of the encrypted data in bytes, and must be a multiple of DWORDs. UINT32 DataSize; // Specifies the size of the encrypted data in bytes, and must be a multiple of DWORDs.
// If this value is 00000000H, then the microcode update encrypted data is 2000 bytes (or 500 DWORDs). // If this value is 00000000H, then the microcode update encrypted data is 2000 bytes (or 500 DWORDs).
// Sane values are less than 0x1000000 // Sane values are less than 0x1000000
UINT32 TotalSize; // Specifies the total size of the microcode update in bytes. UINT32 TotalSize; // Specifies the total size of the microcode update in bytes.
// It is the summation of the header size, the encrypted data size and the size of the optional extended signature table. // It is the summation of the header size, the encrypted data size and the size of the optional extended signature table.
// This value is always a multiple of 1024 according to the spec, but Intel already breached it several times. // This value is always a multiple of 1024 according to the spec, but Intel already breached it several times.
// Sane values are less than 0x1000000 // Sane values are less than 0x1000000
UINT8 Reserved[12]; // Zeroes UINT8 Reserved[12]; // Zeroes
} INTEL_MICROCODE_HEADER; } INTEL_MICROCODE_HEADER;
#define INTEL_MICROCODE_REAL_DATA_SIZE_ON_ZERO 2000 #define INTEL_MICROCODE_REAL_DATA_SIZE_ON_ZERO 2000
@ -95,11 +95,11 @@ typedef struct INTEL_MICROCODE_EXTENDED_HEADER_ {
} INTEL_MICROCODE_EXTENDED_HEADER; } INTEL_MICROCODE_EXTENDED_HEADER;
typedef struct INTEL_MICROCODE_EXTENDED_HEADER_ENTRY_ { typedef struct INTEL_MICROCODE_EXTENDED_HEADER_ENTRY_ {
UINT32 CpuSignature; UINT32 ProcessorSignature;
UINT32 CpuFlags; UINT32 ProcessorFlags;
UINT32 Checksum; // To calculate the Checksum, substitute the Primary Processor Signature entry and the Processor Flags entry with the corresponding Extended Patch entry. UINT32 Checksum; // To calculate the Checksum, substitute the Primary Processor Signature entry and the Processor Flags entry with the corresponding Extended Patch entry.
// Delete the Extended Processor Signature Table entries. // Delete the Extended Processor Signature Table entries.
// Checksum is correct when the summation of all DWORDs that comprise the created Extended Processor Patch results in 00000000H. // Checksum is correct when the summation of all DWORDs that comprise the created Extended Processor Patch results in 00000000H.
} INTEL_MICROCODE_EXTENDED_HEADER_ENTRY; } INTEL_MICROCODE_EXTENDED_HEADER_ENTRY;
#define INTEL_MICROCODE_HEADER_VERSION_1 0x00000001 #define INTEL_MICROCODE_HEADER_VERSION_1 0x00000001