Skip to content

Commit

Permalink
Change exit code from invalidSyscall to invalidInstruction for invali…
Browse files Browse the repository at this point in the history
…d load instruction encoding
  • Loading branch information
mininny committed Jan 21, 2025
1 parent cfd156c commit 2c3c7dd
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion rvgo/fast/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ func (inst *InstrumentedState) riscvStep() (outErr error) {

// bits[14:12] set to 111 are reserved
if eq64(funct3, byteToU64(0x7)) != 0 {
revertWithCode(riscv.ErrInvalidSyscall, fmt.Errorf("illegal instruction %d: reserved instruction encoding", instr))
revertWithCode(riscv.ErrIllegalInstruction, fmt.Errorf("illegal instruction %d: reserved instruction encoding", instr))
}

imm := parseImmTypeI(instr)
Expand Down
2 changes: 1 addition & 1 deletion rvgo/slow/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ func Step(calldata []byte, po PreimageOracle) (stateHash common.Hash, outErr err

// bits[14:12] set to 111 are reserved
if eq64(funct3, byteToU64(0x7)) != (U64{}) {
revertWithCode(riscv.ErrInvalidSyscall, fmt.Errorf("illegal instruction %d: reserved instruction encoding", instr))
revertWithCode(riscv.ErrIllegalInstruction, fmt.Errorf("illegal instruction %d: reserved instruction encoding", instr))
}

imm := parseImmTypeI(instr)
Expand Down
2 changes: 1 addition & 1 deletion rvsol/src/RISCV.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,7 @@ contract RISCV is IBigStepper {
// LB, LH, LW, LD, LBU, LHU, LWU

// bits[14:12] set to 111 are reserved
if eq64(funct3, toU64(0x7)) { revertWithCode(0xf001ca11) }
if eq64(funct3, toU64(0x7)) { revertWithCode(0xbadc0de) }

let imm := parseImmTypeI(instr)
let signed := iszero64(and64(funct3, toU64(4))) // 4 = 100 -> bitflag
Expand Down
4 changes: 2 additions & 2 deletions rvsol/test/RISCV.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2487,7 +2487,7 @@ contract RISCV_Test is CommonTest {
state.registers[25] = 0xf956;
bytes memory encodedState = encodeState(state);

vm.expectRevert(hex"00000000000000000000000000000000000000000000000000000000f001ca11");
vm.expectRevert(hex"0000000000000000000000000000000000000000000000000000000000badc0de");
riscv.step(encodedState, proof, 0);
}

Expand All @@ -2501,7 +2501,7 @@ contract RISCV_Test is CommonTest {

bytes memory encodedState = encodeState(state);

vm.expectRevert(hex"00000000000000000000000000000000000000000000000000000000f001ca11");
vm.expectRevert(hex"0000000000000000000000000000000000000000000000000000000000badc0de");
riscv.step(encodedState, proof, 0);
}

Expand Down

0 comments on commit 2c3c7dd

Please sign in to comment.