Skip to content

Commit 7c4eaf6

Browse files
authored
Merge pull request #134 from ethereum-optimism/feature/mininny/update-exitcode-to-illegal-inst
Update exitcode from invalidSyscall to illegalInstruction
2 parents f01251b + 740e8f3 commit 7c4eaf6

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

rvgo/fast/vm.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ func (inst *InstrumentedState) riscvStep() (outErr error) {
590590

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

596596
imm := parseImmTypeI(instr)
@@ -688,13 +688,13 @@ func (inst *InstrumentedState) riscvStep() (outErr error) {
688688
case 1: // 001 = SLLIW
689689
// SLLIW where imm[5] != 0 is reserved
690690
if and64(imm, byteToU64(0x20)) != 0 {
691-
revertWithCode(riscv.ErrInvalidSyscall, fmt.Errorf("illegal instruction %d: reserved instruction encoding", instr))
691+
revertWithCode(riscv.ErrIllegalInstruction, fmt.Errorf("illegal instruction %d: reserved instruction encoding", instr))
692692
}
693693
rdValue = mask32Signed64(shl64(and64(imm, byteToU64(0x1F)), rs1Value))
694694
case 5: // 101 = SR~
695695
// SRLIW and SRAIW where imm[5] != 0 is reserved
696696
if and64(imm, byteToU64(0x20)) != 0 {
697-
revertWithCode(riscv.ErrInvalidSyscall, fmt.Errorf("illegal instruction %d: reserved instruction encoding", instr))
697+
revertWithCode(riscv.ErrIllegalInstruction, fmt.Errorf("illegal instruction %d: reserved instruction encoding", instr))
698698
}
699699
shamt := and64(imm, byteToU64(0x1F))
700700
switch shr64(byteToU64(5), imm) { // top 7 bits select the shift type

rvgo/slow/vm.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ func Step(calldata []byte, po PreimageOracle) (stateHash common.Hash, outErr err
774774

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

780780
imm := parseImmTypeI(instr)
@@ -872,13 +872,13 @@ func Step(calldata []byte, po PreimageOracle) (stateHash common.Hash, outErr err
872872
case 1: // 001 = SLLIW
873873
// SLLIW where imm[5] != 0 is reserved
874874
if and64(imm, byteToU64(0x20)) != (U64{}) {
875-
revertWithCode(riscv.ErrInvalidSyscall, fmt.Errorf("illegal instruction %d: reserved instruction encoding", instr))
875+
revertWithCode(riscv.ErrIllegalInstruction, fmt.Errorf("illegal instruction %d: reserved instruction encoding", instr))
876876
}
877877
rdValue = mask32Signed64(shl64(and64(imm, byteToU64(0x1F)), rs1Value))
878878
case 5: // 101 = SR~
879879
// SRLIW and SRAIW imm[5] != 0 is reserved
880880
if and64(imm, byteToU64(0x20)) != (U64{}) {
881-
revertWithCode(riscv.ErrInvalidSyscall, fmt.Errorf("illegal instruction %d: reserved instruction encoding", instr))
881+
revertWithCode(riscv.ErrIllegalInstruction, fmt.Errorf("illegal instruction %d: reserved instruction encoding", instr))
882882
}
883883
shamt := and64(imm, byteToU64(0x1F))
884884
switch shr64(byteToU64(5), imm).val() { // top 7 bits select the shift type

rvsol/src/RISCV.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,7 @@ contract RISCV is IBigStepper {
11611161
// LB, LH, LW, LD, LBU, LHU, LWU
11621162

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

11661166
let imm := parseImmTypeI(instr)
11671167
let signed := iszero64(and64(funct3, toU64(4))) // 4 = 100 -> bitflag
@@ -1295,12 +1295,12 @@ contract RISCV is IBigStepper {
12951295
// 001 = SLLIW
12961296

12971297
// SLLIW where imm[5] != 0 is reserved
1298-
if and64(imm, toU64(0x20)) { revertWithCode(0xf001ca11) }
1298+
if and64(imm, toU64(0x20)) { revertWithCode(0xbadc0de) }
12991299
rdValue := mask32Signed64(shl64(and64(imm, toU64(0x1F)), rs1Value))
13001300
}
13011301
case 5 {
13021302
// SRLIW and SRAIW where imm[5] != 0 is reserved
1303-
if and64(imm, toU64(0x20)) { revertWithCode(0xf001ca11) }
1303+
if and64(imm, toU64(0x20)) { revertWithCode(0xbadc0de) }
13041304

13051305
// 101 = SR~
13061306
let shamt := and64(imm, toU64(0x1F))

rvsol/test/RISCV.t.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2487,7 +2487,7 @@ contract RISCV_Test is CommonTest {
24872487
state.registers[25] = 0xf956;
24882488
bytes memory encodedState = encodeState(state);
24892489

2490-
vm.expectRevert(hex"00000000000000000000000000000000000000000000000000000000f001ca11");
2490+
vm.expectRevert(hex"000000000000000000000000000000000000000000000000000000000badc0de");
24912491
riscv.step(encodedState, proof, 0);
24922492
}
24932493

@@ -2501,7 +2501,7 @@ contract RISCV_Test is CommonTest {
25012501

25022502
bytes memory encodedState = encodeState(state);
25032503

2504-
vm.expectRevert(hex"00000000000000000000000000000000000000000000000000000000f001ca11");
2504+
vm.expectRevert(hex"000000000000000000000000000000000000000000000000000000000badc0de");
25052505
riscv.step(encodedState, proof, 0);
25062506
}
25072507

0 commit comments

Comments
 (0)