SBPF.Memory — the sBPF memory model #
Byte-addressable memory, access widths, and the load / store operations of the
sBPF semantics, ported from Mem.thy. Memory is a partial map from 64-bit
address to byte; loads and stores are little-endian and operate at one of four
access widths.
Main definitions #
Solanalib.SBPF.MemoryChunk— access width (m8…m64).Solanalib.SBPF.Mem— the byte-addressable address space.Solanalib.SBPF.loadv— read aValof a given width (noneif unmapped).Solanalib.SBPF.storev— write aVal, returning the updated memory.
Access width for a memory operation (the source theory's memory_chunk).
- m8 : MemoryChunk
- m16 : MemoryChunk
- m32 : MemoryChunk
- m64 : MemoryChunk
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Byte-addressable memory: a partial map from 64-bit address to byte.
Modelled as a total function into Option U8 (none = unmapped), matching the
source theory's (u64, u8) map.
Equations
Instances For
The empty address space — every byte unmapped.
Equations
Instances For
The width of a chunk, as a 64-bit value (vlong_of_memory_chunk).
Equations
- Solanalib.SBPF.vlongOfMemoryChunk Solanalib.SBPF.MemoryChunk.m8 = Solanalib.SBPF.Val.vlong 8
- Solanalib.SBPF.vlongOfMemoryChunk Solanalib.SBPF.MemoryChunk.m16 = Solanalib.SBPF.Val.vlong 16
- Solanalib.SBPF.vlongOfMemoryChunk Solanalib.SBPF.MemoryChunk.m32 = Solanalib.SBPF.Val.vlong 32
- Solanalib.SBPF.vlongOfMemoryChunk Solanalib.SBPF.MemoryChunk.m64 = Solanalib.SBPF.Val.vlong 64
Instances For
Tag a 64-bit word as the value of the given access width, truncating to the
width (memory_chunk_value_of_u64).
Equations
- Solanalib.SBPF.memoryChunkValueOfU64 Solanalib.SBPF.MemoryChunk.m8 v = Solanalib.SBPF.Val.vbyte (BitVec.setWidth 8 v)
- Solanalib.SBPF.memoryChunkValueOfU64 Solanalib.SBPF.MemoryChunk.m16 v = Solanalib.SBPF.Val.vshort (BitVec.setWidth 16 v)
- Solanalib.SBPF.memoryChunkValueOfU64 Solanalib.SBPF.MemoryChunk.m32 v = Solanalib.SBPF.Val.vint (BitVec.setWidth 32 v)
- Solanalib.SBPF.memoryChunkValueOfU64 Solanalib.SBPF.MemoryChunk.m64 v = Solanalib.SBPF.Val.vlong v
Instances For
Read a value of the given width at addr, little-endian. Yields none if
any byte in the accessed range is unmapped.
Equations
- One or more equations did not get rendered due to their size.
- Solanalib.SBPF.loadv Solanalib.SBPF.MemoryChunk.m8 m addr = Option.map (fun (b0 : Solanalib.SBPF.U8) => Solanalib.SBPF.Val.vbyte b0) (m addr)
- Solanalib.SBPF.loadv Solanalib.SBPF.MemoryChunk.m16 m addr = do let b0 ← m addr let b1 ← m (addr + 1) pure (Solanalib.SBPF.Val.vshort (BitVec.setWidth 16 b0 ||| BitVec.setWidth 16 b1 <<< 8))
Instances For
Write a value of the given width at addr, little-endian. Yields none if
the value's tag does not match the access width.
Equations
- One or more equations did not get rendered due to their size.
- Solanalib.SBPF.storev Solanalib.SBPF.MemoryChunk.m8 m addr (Solanalib.SBPF.Val.vbyte n) = some fun (i : Solanalib.SBPF.U64) => if i = addr then some n else m i
- Solanalib.SBPF.storev mc m addr v = none