Skip to content

Commit

Permalink
cannon: Use 4-byte alignment for memory.SetUint32
Browse files Browse the repository at this point in the history
  • Loading branch information
mbaxter committed Oct 14, 2024
1 parent 9d9dc32 commit ce9abdd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cannon/mipsevm/memory/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import (
"slices"
"sort"

"github.com/ethereum-optimism/optimism/cannon/mipsevm/arch"
"github.com/ethereum/go-ethereum/crypto"
"golang.org/x/exp/maps"

"github.com/ethereum-optimism/optimism/cannon/mipsevm/arch"
)

// Note: 2**12 = 4 KiB, the min phys page size in the Go runtime.
Expand Down Expand Up @@ -193,8 +194,8 @@ func (m *Memory) pageLookup(pageIndex Word) (*CachedPage, bool) {
}

func (m *Memory) SetUint32(addr Word, v uint32) {
// addr must be aligned to WordSizeBytes bytes
if addr&arch.ExtMask != 0 {
// addr must be aligned to 4-byte (32-bit) boundaries
if addr&3 != 0 {
panic(fmt.Errorf("unaligned memory access: %x", addr))
}

Expand Down

0 comments on commit ce9abdd

Please sign in to comment.