Skip to content

Commit

Permalink
Check size is not greater than 8 for RV32A and RV63A
Browse files Browse the repository at this point in the history
  • Loading branch information
mininny committed Dec 11, 2024
1 parent 8ff9318 commit 36b7895
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion rvgo/fast/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ func (inst *InstrumentedState) riscvStep() (outErr error) {
// 0b010 == RV32A W variants
// 0b011 == RV64A D variants
size := shl64(funct3, toU64(1))
if lt64(size, toU64(4)) != 0 {
if lt64(size, toU64(4)) != 0 || gt64(size, toU64(8)) != 0 {
revertWithCode(riscv.ErrBadAMOSize, fmt.Errorf("bad AMO size: %d", size))
}
addr := getRegister(rs1)
Expand Down
2 changes: 1 addition & 1 deletion rvgo/slow/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ func Step(calldata []byte, po PreimageOracle) (stateHash common.Hash, outErr err
// 0b010 == RV32A W variants
// 0b011 == RV64A D variants
size := shl64(funct3, toU64(1))
if lt64(size, toU64(4)) != (U64{}) {
if or64(lt64(size, toU64(4)), gt64(size, toU64(8))) != (U64{}) {
revertWithCode(riscv.ErrBadAMOSize, fmt.Errorf("bad AMO size: %d", size))
}
addr := getRegister(rs1)
Expand Down

0 comments on commit 36b7895

Please sign in to comment.