Skip to content

[RISCV][Lifting] Implement the atomic extension#6373

Draft
moste00 wants to merge 4 commits into
rizinorg:devfrom
moste00:feature/riscv_lifting_atomic
Draft

[RISCV][Lifting] Implement the atomic extension#6373
moste00 wants to merge 4 commits into
rizinorg:devfrom
moste00:feature/riscv_lifting_atomic

Conversation

@moste00

@moste00 moste00 commented May 17, 2026

Copy link
Copy Markdown
Contributor

Your checklist for this pull request

  • I've read the guidelines for contributing to this repository.
  • I made sure to follow the project's coding style.
  • I've documented every RZ_API function and struct this PR changes.
  • I've added tests that prove my changes are effective (required for changes to RZ_API).
  • I've updated the Rizin book with the relevant information (if needed).
  • I've used AI tools to generate fully or partially these code changes and I'm sure the changes are not copyrighted by somebody else.

Detailed description

Continues #6364. Implements the A extension of RISC-V "trivially", by ignoring all concurrency guards and gurantees in the spec since RzIL is a strictly sequential VM, all instructions defined by the extension therefore reduce to a simplified implementation.

Claude Code CLI was used to write some code under review and testing by me, I take responsiblity for all the code and bugs here, I use CCC as only a text editing multiplier.

Test plan

Testing this extension specifically could be challenging, since spawning threads is itself a syscall (which we don't model in RzIL), I'm not sure how can we execute multiple threads (if even sequentially) in RzIL VM.

Theoretically, executing threads one-after-the-other is a valid sequentially-consistent way to execute threads, but I'm not sure we can get to this point. It's also prone to deadlocks if threads share variables and wait on them.

So all-in-all, this extension will be a bit under-tested compared to the others, but I will still add regression testing in the asm test files.

Closing issues

PR Stack Structure

This PR is the third of a 4-PR stack that lifts the IMAFD RISC-V archiecture plus some privileged instructions.

The following is a table for ease of navigation from any PR to any other, please filter by the commit(s) mentioned in the table when reviewing the diff in the "Files Changed" tab to avoid the noise of the base branches.

Extension PR Commits To Select in "Files Changed" State (Open, Merged, Draft, Closed)
I #6287 No filtering necessary O
M #6364 "implement the rest of the multiplication extension" D
A #6373 < (THIS PR) "implement the atomic extension trivially by ignoring concurrency guards" D
F/D #6374 "add floating and double instructions, and add privlieged ISA instructions like reading CSRs to implement fflags reading and writing" D

Because it's painful to maintain this stack manually with no Github or other tooling support, I won't grow it any further until one of those 4 PRs gets merged.

Depends-on: #6364

@moste00 moste00 force-pushed the feature/riscv_lifting_atomic branch from b871922 to 2504d42 Compare May 21, 2026 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant