x86: Use longMode context bit instead of bit64 in more places #6522
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.
Commit 25801da introduced the
longMode
context bit to better handle decoding differences in long mode (64-bit mode).Before the introduction of the
longMode
context bits, many of the constructors used the constraintbit64=0
orbit64=1
to handle difference between the different processor modes. However, the value ofbit64
is based on the current address size which can be overridden using an 0x67 prefix, causing invalid instructions to be incorrectly treated as valid.This commit replaces most uses of the
bit64
constraint with$(LONGMODE_OFF)
instead. The following instruction encodings after this PR correctly match the behaviour of the hardware (on both an AMD and Intel CPU) forx86:LE:64:default
:These instructions did not have a
bit64=0
constraint, but are also not allowed in long mode (based on "2.5.10 Invalid Instructions" in the AMD64 Manual Vol 2, and verified with hardware):This PR contains also a couple of closely related fixes, I can split this into multiple PRs if desired:
16-bit MOVSXD is allowed: e.g.
6663c1 MOVSXD AX,CX
with CX=0x10x86:LE:64:default
(Existing): Invalid Instructionx86:LE:64:default
(This patch): "MOVSXD AX,CX " { RAX=0x10 }Allow RDTSCP to be decoded in 32-bit mode: e.g.
0f01f9 RDTSCP
.x86:LE:32:default
(Existing): Invalid Instructionx86:LE:32:default
(This patch): "RDTSCP"