x86: Fix overlap issue with INCSS/RDSSP #6520
Open
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.
INCSSQ
/RDSSPQ
(64-bit variants) are incorrectly decoded asINCSSPD
/RDSSPD
(32-bit variants).The 32-bit variants include the constraint
(opsize=0 | opsize=1 | opsize=2 | opsize=3)
which essentially doesn't constraint the constructor at all (sinceopsize
is a 2-bit field and this covers all combinations). However, this does appear to affect constructor ordering, since it means the 64-bit variants are not strictly more constrained than the 32-bit one and the 32-bit variants appear first in the sleigh source code so are matched first.The 64-bit variant should be used when REX.W is present which implies
opsize=2
(oropsize=3
if a 0x66 prefix is present), so these need to be removed from the allowedopsize
values for the 32-bit variant.By removing all of the
opsize
constraints, the 64-bit variants are now strictly more constrained than the 32-bit variant causing the decoder to match them if a REX.W prefix is present before checking 32-bit variant. This also matches the way the constraints are written forWRSSD
.e.g.
f3480faee8
: "INCSSPQ RAX"x86:LE:64:default
(Existing): "INCSSPD EAX"x86:LE:64:default
(This patch): "INCSSPQ RAX"