Skip to content

AArch64: add acquire load ordering to RCpc family instructions#9077

Open
liamwhite wants to merge 1 commit intoNationalSecurityAgency:masterfrom
liamwhite:sleigh-aarch64-ldapr-acquireop
Open

AArch64: add acquire load ordering to RCpc family instructions#9077
liamwhite wants to merge 1 commit intoNationalSecurityAgency:masterfrom
liamwhite:sleigh-aarch64-ldapr-acquireop

Conversation

@liamwhite
Copy link
Copy Markdown

For this function, which uses the ldapr RCpc instruction:

ldapr_test:
	ldapr	x0, [x0]
	ret

The decompiler currently doesn't note that the instruction has release-consistent processor-consistent acquire semantics with respect to the input pointer.

undefined8 ldapr_test(undefined8 *param_1)
{
  return *param_1;
}

This PR reuses the LOAcquire pcodeop to encode two arguments:

  1. The address for which the RCpc acquire barrier is performed
  2. The size of the load

(This could easily be changed to a distinct pcodeop if desired)

undefined8 ldapr_test(undefined8 *param_1)
{
  LOAcquire(param_1,8);
  return *param_1;
}

@GhidorahRex
Copy link
Copy Markdown
Collaborator

I think it's worth adding a new pcodeop LOAcquirePC but is there any specific reason that the ldapr instruction needs the address and size compared to the ldar?

@liamwhite
Copy link
Copy Markdown
Author

For normal acquire ops, LOAcquire is a barrier that constrains all subsequent memory operations and so has no need to be parametrized. For RCpc acquires, ARM dictates that coherence guarantees are constrained to a specific address range [ptr, ptr + size) (implementing C++'s atomic::load(memory_order_acquire)).

For the purposes of emulation, it's okay to model AcquireRCpc as having the global side effect, but for source-level recreation they're not equivalent.

@GhidorahRex
Copy link
Copy Markdown
Collaborator

Then we definitely should include a separate pcodeop, but otherwise the PR looks good. I'll try to get all of these reviewed when I get the opportunity

@liamwhite liamwhite force-pushed the sleigh-aarch64-ldapr-acquireop branch from ab49090 to 52fb26e Compare April 1, 2026 01:11
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