Skip to content

Commit 4e2a8f6

Browse files
committed
Add Intel uCode parser
1 parent 58366f4 commit 4e2a8f6

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

common/nvramparser.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,42 @@ USTATUS NvramParser::parseNvramVolumeBody(const UModelIndex & index,const UINT32
12211221
// Phoenix SLIC Pubkey/Marker
12221222

12231223
// Intel uCode
1224+
try {
1225+
// Check data size
1226+
if (volumeBodySize - storeOffset < sizeof(INTEL_MICROCODE_HEADER)) {
1227+
throw 0;
1228+
}
1229+
1230+
const UINT32 currentUint32 = readUnaligned((const UINT32*)(volumeBody.constData() + storeOffset));
1231+
1232+
if (currentUint32 != INTEL_MICROCODE_HEADER_VERSION_1) {
1233+
throw 0;
1234+
}
1235+
1236+
// Check microcode header candidate
1237+
const INTEL_MICROCODE_HEADER* ucodeHeader = (const INTEL_MICROCODE_HEADER*)(volumeBody.constData() + storeOffset);
1238+
if (FALSE == ffsParser->microcodeHeaderValid(ucodeHeader)) {
1239+
throw 0;
1240+
}
1241+
1242+
// Check size candidate
1243+
if (ucodeHeader->TotalSize == 0) {
1244+
throw 0;
1245+
}
1246+
1247+
// All checks passed, microcode found
1248+
UByteArray ucode = volumeBody.mid(storeOffset);
1249+
UModelIndex ucodeIndex;
1250+
if (U_SUCCESS != ffsParser->parseIntelMicrocodeHeader(ucode, storeOffset, index, ucodeIndex)) {
1251+
throw 0;
1252+
}
1253+
1254+
storeOffset += ucodeHeader->TotalSize - 1;
1255+
previousStoreEndOffset = storeOffset + 1;
1256+
continue;
1257+
} catch (...) {
1258+
// Parsing failed, try something else
1259+
}
12241260

12251261
// Padding
12261262
if (storeOffset < volumeBodySize) {

0 commit comments

Comments
 (0)