target/i386: Reject ModRM.reg == 7 early when decoding 0xFE/0xFF (group 4 and 5) instructions - #2362
Open
unknown-1-0 wants to merge 1 commit into
Open
Conversation
Member
|
For such instruction semantic related fixes, a unit test could greatly speed up my reviewing process because I can debug and see the difference. Thanks in advance if you wish adding one. |
Author
|
Noted. Working on it |
unknown-1-0
force-pushed
the
i386-fix-group-4-and-5-decoding
branch
from
July 7, 2026 13:43
1368440 to
be8dc80
Compare
Author
|
Added the unit test |
Author
|
I see there's a merge conflict in test_x86.c across my open PRs. Please let me know when you are ready to merge each PR, and I'll resolve the conflicts one by one. |
…up 4 and 5) instructions According to both table A-6 in Volume 2 of Intel 64 and IA-32 Architectures Software Developer's Manual and table A-6 in Volume 3 of AMD64 Architecture Programmer's Manual, the opcode for ModRM.reg == 7 is reserved for both group 4 (0xFE) and 5 (0xFF) instructions. Although Unicorn already rejects ModRM.reg == 7 early with group 4 (0xFE) instructions, that is not the case with group 5 (0xFF) instructions. The latter case is eventually handled in the `default:` block of `switch(op)`, but by the time that code is reached, some micro-ops are already generated. These may include a memory load micro-op. As a result, an invalid memory access error may be produced instead of an expected invalid instruction error. Fix this bug by rejecting group 4 and 5 instructions with ModRM.reg == 7 before generating any micro-operations. Signed-off-by: Andrey Polivoda <apolivodaa433@gmail.com>
unknown-1-0
force-pushed
the
i386-fix-group-4-and-5-decoding
branch
from
July 22, 2026 16:33
be8dc80 to
8200be4
Compare
Author
|
Resolved the conflict. Moved the test between existing ones to prevent future conflicts. Also the commit is signed now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
According to both table A-6 in Volume 2 of Intel 64 and IA-32 Architectures Software Developer's Manual and table A-6 in Volume 3 of AMD64 Architecture Programmer's Manual, the opcode for ModRM.reg == 7 is reserved for both group 4 (0xFE) and 5 (0xFF) instructions.
Although Unicorn already rejects ModRM.reg == 7 early with group 4 (0xFE) instructions, that is not the case with group 5 (0xFF) instructions. The latter case is eventually handled in the
default:block ofswitch(op), but by the time that code is reached, some micro-ops are already generated. These may include a memory load micro-op. As a result, an invalid memory access error may be produced instead of an expected invalid instruction error.Fix this bug by rejecting group 4 and 5 instructions with ModRM.reg == 7 before generating any micro-operations.