Skip to content

feat: rvr extention for rv64 riscv#2876

Merged
shuklaayush merged 11 commits into
develop-v2.1.0-rv64from
feat/rvr-support-rv64-riscv
Jun 14, 2026
Merged

feat: rvr extention for rv64 riscv#2876
shuklaayush merged 11 commits into
develop-v2.1.0-rv64from
feat/rvr-support-rv64-riscv

Conversation

@mansur20478

@mansur20478 mansur20478 commented Jun 11, 2026

Copy link
Copy Markdown

RVR extension for RV64 RISCV. The current implementation was tested on openvm-riscv-integration-tests tests.

The RVR extension required following changes on top of rvr-rv32:

  1. Adding new W ALU and Mult/Div instructions, new lwu instruction.
  2. Updating lifter to lift new instructions.
  3. Updating instruction simulation done in block generation phase to 64bit.
  4. Updating C code emission to emit 64bit instructions (MULH instruction uses __int128 to avoid overflow of 64bit multiplication to get upper 64bit of the result). Adding 64bit and 32bit sign extended reads in rvr.
  5. Updating RvState registers to 64bit.
  6. Updating bridge.rs - the buffer access between VmState and rvr:ffi, to 64bit.

towards INT-8107

@github-actions

This comment has been minimized.

@mansur20478 mansur20478 self-assigned this Jun 11, 2026
@github-actions

This comment has been minimized.

@mansur20478 mansur20478 marked this pull request as ready for review June 11, 2026 18:09
@mansur20478 mansur20478 requested review from gdmlcjs and shuklaayush and removed request for shuklaayush June 11, 2026 18:09
@github-actions

This comment has been minimized.

@mansur20478 mansur20478 requested a review from shuklaayush June 11, 2026 18:27
@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@github-actions

This comment has been minimized.

@shuklaayush shuklaayush left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some comments - primarily pc should become u64 even if at the moment we don't support pc above 30 bits

Comment thread crates/rvr/rvr-openvm-lift/src/cfg.rs
Comment thread crates/rvr/rvr-openvm-lift/src/cfg.rs Outdated
Comment thread crates/rvr/rvr-state/src/state.rs Outdated
Comment thread crates/rvr/rvr-state/src/state.rs Outdated
Comment thread crates/rvr/rvr-state/src/state.rs Outdated
Comment thread crates/rvr/rvr-state/src/state.rs Outdated
Comment thread crates/vm/src/arch/rvr/metered.rs Outdated
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@mansur20478 mansur20478 requested a review from shuklaayush June 12, 2026 18:03
@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
group app.proof_time_ms app.cycles leaf.proof_time_ms
fibonacci 1,659 4,000,051 529
keccak 16,105 14,365,133 3,002
sha2_bench 10,428 11,167,961 1,948
regex 1,528 4,090,656 424
ecrecover 481 112,210 305
pairing 617 592,827 290
kitchen_sink 3,972 1,979,971 871

Note: cells_used metrics omitted because CUDA tracegen does not expose unpadded trace heights.

Commit: 125023d

Benchmark Workflow

@gdmlcjs gdmlcjs left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment changes ("RV32" -> "RV64") in

  • crates/vm/src/arch/rvr/debug.rs:58
  • crates/vm/src/arch/rvr/execute.rs:97

}
}

/// HINT_RANDOM phantom: fill the hint stream with `reg[num_words_reg] * 4`

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the 4 should be changed to 8

@shuklaayush shuklaayush left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some comments but we can address in a follow up

Comment on lines +922 to +926
assert!(
t < (1u64 << PC_BITS),
"JumpDyn target {t:#x} exceeds PC address space"
);
let pc32 = t as u32;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's try to avoid converting pc to u32 altogether if possible. also better to emit errors instead of panicing

@@ -79,10 +79,10 @@ pub fn init_rvr_state<F: PrimeField32>(
vm_state: &mut VmState<F, GuestMemory>,
pc: u32,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should change it to u64

Comment on lines +144 to +146
vm_state.set_pc(
u32::try_from(state.pc).expect("PC must be within u32 range after C bounds check"),
);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not the most ideal, we should change pc to u64 but check that it's within PC_BITS

@shuklaayush shuklaayush merged commit d08fac7 into develop-v2.1.0-rv64 Jun 14, 2026
62 of 66 checks passed
@shuklaayush shuklaayush deleted the feat/rvr-support-rv64-riscv branch June 14, 2026 08:37
shuklaayush pushed a commit that referenced this pull request Jun 19, 2026
RVR extension for RV64 RISCV. The current implementation was tested on
`openvm-riscv-integration-tests` tests.

The RVR extension required following changes on top of `rvr-rv32`:
1) Adding new `W` ALU and Mult/Div instructions, new `lwu` instruction.
2) Updating lifter to lift new instructions.
3) Updating instruction simulation done in block generation phase to
64bit.
4) Updating `C` code emission to emit 64bit instructions (`MULH`
instruction uses `__int128` to avoid overflow of `64bit` multiplication
to get upper 64bit of the result). Adding 64bit and 32bit sign extended
reads in rvr.
5) Updating `RvState` registers to 64bit.
6) Updating `bridge.rs` - the buffer access between `VmState` and
`rvr:ffi`, to 64bit.

towards INT-8107
shuklaayush pushed a commit that referenced this pull request Jun 19, 2026
RVR extension for RV64 RISCV. The current implementation was tested on
`openvm-riscv-integration-tests` tests.

The RVR extension required following changes on top of `rvr-rv32`:
1) Adding new `W` ALU and Mult/Div instructions, new `lwu` instruction.
2) Updating lifter to lift new instructions.
3) Updating instruction simulation done in block generation phase to
64bit.
4) Updating `C` code emission to emit 64bit instructions (`MULH`
instruction uses `__int128` to avoid overflow of `64bit` multiplication
to get upper 64bit of the result). Adding 64bit and 32bit sign extended
reads in rvr.
5) Updating `RvState` registers to 64bit.
6) Updating `bridge.rs` - the buffer access between `VmState` and
`rvr:ffi`, to 64bit.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants