x86: correctly handle XACQUIRE/XRELEASE#2882
Open
jxors wants to merge 1 commit intocapstone-engine:nextfrom
Open
x86: correctly handle XACQUIRE/XRELEASE#2882jxors wants to merge 1 commit intocapstone-engine:nextfrom
jxors wants to merge 1 commit intocapstone-engine:nextfrom
Conversation
This patch changes XACQUIRE/XRELEASE decoding to happen only after all prefixes have been read. This is necessary to handle all possible orderings of prefixes. For example, both F3F0 and F0F3 should be treated as XRELEASE. The last REP prefix is taken to distinguish between XACQUIRE and XRELEASE. So F2F3F0 = XRELEASE, F3F2F0 = XACQUIRE. This behavior is specified in the Intel SDM Section 6.1 - XACQUIRE/XRELEASE. Additionally, this patch changes the disassembly printing of LOCKs and XACQUIRE/XRELEASE to reflect the actual prefixes used. Previously, XCHG instructions would always be printed without LOCK and everything else with LOCK. For this, an extra field is added to MCInst.
Collaborator
Contributor
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.
Your checklist for this pull request
Detailed description
This patch changes XACQUIRE/XRELEASE decoding to happen only after all prefixes have been read.
This is necessary to handle all possible orderings of prefixes. For example, both F3F0 and F0F3 should be treated as XRELEASE. The last REP prefix is taken to distinguish between XACQUIRE and XRELEASE. So
F2F3F0= XRELEASE,F3F2F0= XACQUIRE.This behavior is specified in the Intel SDM Section 6.1 - XACQUIRE/XRELEASE.
Additionally, this patch changes the disassembly printing of LOCKs and XACQUIRE/XRELEASE to reflect the actual prefixes used. Previously, XCHG instructions would always be printed without LOCK and everything else with LOCK.
For this, an extra field is added to MCInst.
Test plan
I have added 9 new tests in
issues/x86-xacquire-xrelease.yaml. There were also already 4 tests inissues.yamlthat were relevant to this change.