Documentation

Solanalib.SBPF.State

SBPF.State — interpreter state #

The machine state of the sBPF interpreter, ported from vm_state.thy, vm.thy, ebpf.thy, and the state section of Interpreter.thy. This module defines the register file, the call-frame stack, the function registry, the small-step result type, the VM constants, and the initial state.

Main definitions #

VM constants #

Number of scratch (caller-saved) registers, BR6BR9.

Equations
Instances For

    Base virtual address of the VM stack region.

    Equations
    Instances For

      Base virtual address of the program input region.

      Equations
      Instances For

        Maximum nested call depth.

        Equations
        Instances For

          Size of a single stack frame, in bytes.

          Equations
          Instances For

            Registers #

            @[reducible, inline]

            The register file: each of the eleven registers holds a 64-bit word.

            Equations
            Instances For

              Read a register (eval_reg).

              Equations
              Instances For

                Functional register update: rs with r set to v.

                Equations
                Instances For

                  The all-zero register file (init_reg_map).

                  Equations
                  Instances For

                    Call frames and the stack #

                    A saved call frame: the caller's scratch registers, frame pointer, and the program counter to return to (vm_state.thy's CallFrame).

                    • callerSavedRegisters : List U64

                      The caller-saved registers BR6BR9, in order.

                    • framePointer : U64

                      The caller's frame pointer (BR10).

                    • targetPc : U64

                      The program counter to resume at on return.

                    Instances For
                      theorem Solanalib.SBPF.CallFrame.ext {x y : CallFrame} (callerSavedRegisters : x.callerSavedRegisters = y.callerSavedRegisters) (framePointer : x.framePointer = y.framePointer) (targetPc : x.targetPc = y.targetPc) :
                      x = y
                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For
                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For

                          The call-frame stack: current depth, stack pointer, and saved frames.

                          • callDepth : U64

                            The current nesting depth of function calls.

                          • stackPointer : U64

                            The current stack pointer.

                          • callFrames : List CallFrame

                            The saved call frames, innermost last.

                          Instances For
                            theorem Solanalib.SBPF.StackState.ext {x y : StackState} (callDepth : x.callDepth = y.callDepth) (stackPointer : x.stackPointer = y.stackPointer) (callFrames : x.callFrames = y.callFrames) :
                            x = y
                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For
                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For

                                The initial stack: depth 0, stack pointer at the top of the region, and maxCallDepth default frames preallocated (init_stack_state).

                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For

                                  Function registry #

                                  @[reducible, inline]

                                  The function registry: a partial map from a 32-bit key to a target address (ebpf.thy's func_map).

                                  Equations
                                  Instances For

                                    The empty function registry (init_func_map).

                                    Equations
                                    Instances For

                                      Look up a function address by key (get_function_registry).

                                      Equations
                                      Instances For

                                        Step results #

                                        The small-step result (bpf_state).

                                        • ok pc rs m ss sv fm curCu remainCu — a normal post-state.
                                        • success v — the program returned v.
                                        • eflag — a runtime fault (out-of-bounds, fuel exhaustion, …).
                                        • err — a malformed instruction the verifier should have rejected.
                                        Instances For

                                          The result of an ALU-style evaluation ('a option2, specialised to the register file): oks carries the updated registers, okn signals a runtime fault (EFlag), nok a malformed instruction (Err).

                                          Instances For
                                            def Solanalib.SBPF.initBpfState (rs : RegMap) (m : Mem) (n : U64) (v : SBPFV) :

                                            The initial machine state: PC 0, BR10 pointing at the top of the stack, memory m, version v, empty registry, and n units of fuel (init_bpf_state).

                                            Equations
                                            • One or more equations did not get rendered due to their size.
                                            Instances For