diff --git a/rvgo/fast/vm.go b/rvgo/fast/vm.go index 710b611..6700e07 100644 --- a/rvgo/fast/vm.go +++ b/rvgo/fast/vm.go @@ -877,7 +877,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) diff --git a/rvgo/slow/vm.go b/rvgo/slow/vm.go index a9e43ae..8dc15b4 100644 --- a/rvgo/slow/vm.go +++ b/rvgo/slow/vm.go @@ -1061,7 +1061,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)