Skip to content

Commit

Permalink
Update XOP range checks
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfsck committed Jul 17, 2020
1 parent 971c1f3 commit 984cc76
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/csharp/Intel/IcedFuzzer/IcedFuzzer.Core/InstrGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ static IEnumerable<FuzzerInstruction> GetLegacyInstructions(int bitness, UsedOpC
case 0xF0: // lock
case 0xF2: // repne
case 0xF3: // rep/repe
Assert.True(instructions.Count == 0);
yield break;

case 0x62:
Expand All @@ -587,7 +588,7 @@ static IEnumerable<FuzzerInstruction> GetLegacyInstructions(int bitness, UsedOpC
break;

case 0x8F:
// XOP uses reg=1-3 and reg=5-7 so we need special checks below
// XOP uses reg=1-7 so we need special checks below
xopCheck = (genFlags & InstrGenFlags.NoXOP) == 0;
break;

Expand Down Expand Up @@ -752,9 +753,7 @@ static IEnumerable<FuzzerInstruction> GetLegacyInstructions(int bitness, UsedOpC

if (xopCheck) {
// Make sure there are no instructions in the XOP range
for (int i = 0; i < 8; i++) {
if (i == 0 || i == 4)
continue;
for (int i = 1; i < 8; i++) {
Assert.True(groupInfos[i].IsInvalidMandatoryPrefixInstructions(InvalidInstructionKind.Group));
groupInfos[i].ClearAll();
}
Expand Down Expand Up @@ -918,9 +917,7 @@ static bool IsResNopGroup(LegacyInfo[] infos, int index, MandatoryPrefix[] prefi

if (xopCheck) {
// Make sure there are no instructions in the XOP range
for (int i = 0; i < 8; i++) {
if (i == 0 || i == 4)
continue;
for (int i = 1; i < 8; i++) {
Assert.True(infos[i << 3].IsInvalidMandatoryPrefixInstructions(InvalidInstructionKind.Group));
infos[i << 3].ClearAll();
}
Expand Down Expand Up @@ -956,9 +953,8 @@ static bool IsResNopGroup(LegacyInfo[] infos, int index, MandatoryPrefix[] prefi
if (xopCheck && !instructions.Any(a => GetRealGroupIndex(a) >= 0)) {
// Seems like `pop r/m` was removed
Assert.True(instrs.Count == 0);
// XOP only uses reg=1-3 and reg=5-7 (reg=4 sets XOP.B=1 and uses XOP tables 0-7, reg=0 is pop rm)
// XOP only uses reg=1-7 (reg=4 sets XOP.B=1 and uses XOP tables 0-7, reg=0 is pop rm)
yield return FuzzerInstruction.CreateInvalidLegacy(table, new OpCode(opCode), 0, isModrmMemory, MandatoryPrefix.None);
yield return FuzzerInstruction.CreateInvalidLegacy(table, new OpCode(opCode), 4, isModrmMemory, MandatoryPrefix.None);
yield break;
}

Expand Down

0 comments on commit 984cc76

Please sign in to comment.