-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Work environment
| Questions | Answers |
|---|---|
| System Capstone runs on OS/arch/bits | Ubuntu 24.04 (x86 64-bit) |
| Capstone module affected | x86 |
| Source of Capstone | git clone |
| Version/git commit | 8872be6 |
Instruction bytes giving faulty results
f33e66670fa484170000000000
Expected results
It should decode successfully, but fails to decode instead.
Steps to get the wrong result
With cstool:
cstool -d x64 f33e66670fa484170000000000Additional Logs, screenshots, source code, configuration dump, ...
This issue appears to be caused by the logic in setPrefixPresent. It assumes that instruction prefixes appear in the order of their group (i.e., as if only 3ef366670fa484170000000000 should be valid), but as far as I can tell this is not the case.
The AMD reference manual Volume 1, Section 3.5.1 says:
The legacy prefixes can appear in any order in the instruction, but only one prefix from each of the five groups can be used in a single instruction.
Similarly, the Intel manual Volume 2, Section 2.1.1 says:
For each instruction, it is only useful to include up to one prefix code from each of the four groups (Groups 1, 2, 3, 4). Groups 1 through 4 may be placed in any order relative to each other.
Additionally, I have confirmed that my CPU executes this instruction normally.
I would be happy to work on a patch to fix this.