Skip to content

x86: correctly handle XACQUIRE/XRELEASE#2882

Open
jxors wants to merge 1 commit intocapstone-engine:nextfrom
jxors:xacquire-xrelease-fixes-v2
Open

x86: correctly handle XACQUIRE/XRELEASE#2882
jxors wants to merge 1 commit intocapstone-engine:nextfrom
jxors:xacquire-xrelease-fixes-v2

Conversation

@jxors
Copy link
Copy Markdown
Contributor

@jxors jxors commented Mar 23, 2026

Your checklist for this pull request

  • I've documented or updated the documentation of every API function and struct this PR changes.
  • I've added tests that prove my fix is effective or that my feature works (if possible)

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 in issues.yaml that were relevant to this change.

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.
@github-actions github-actions bot added X86 Arch LLVM-core-files auto-sync labels Mar 23, 2026
@Rot127
Copy link
Copy Markdown
Collaborator

Rot127 commented Mar 26, 2026

Haven't forgotten about this. But Rizin GSOC keeps me pretty busy and x86 reviews take time. Should have time in the next days.

@hainest Maybe you want to take a look as well, if you can find time? Also #2885

@hainest
Copy link
Copy Markdown
Contributor

hainest commented Mar 27, 2026

@Rot127 I'll try to take a look this weekend. @jxors If you don't hear from me by Monday, ping me again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants