exec

package
v1.9.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2024 License: MIT, MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OpLoadLinked         = 0x30
	OpStoreConditional   = 0x38
	OpLoadLinked64       = 0x34
	OpStoreConditional64 = 0x3c
)
View Source
const (
	FdStdin         = 0
	FdStdout        = 1
	FdStderr        = 2
	FdHintRead      = 3
	FdHintWrite     = 4
	FdPreimageRead  = 5
	FdPreimageWrite = 6
)

File descriptors

View Source
const (
	SysErrorSignal = ^Word(0)
	MipsEBADF      = 0x9
	MipsEINVAL     = 0x16
	MipsEAGAIN     = 0xb
	MipsETIMEDOUT  = 0x91
)

Errors

View Source
const (
	FutexWaitPrivate  = 128
	FutexWakePrivate  = 129
	FutexTimeoutSteps = 10_000
	FutexNoTimeout    = ^uint64(0)
	FutexEmptyAddr    = ^Word(0)
)

SysFutex-related constants

View Source
const (
	CloneVm            = 0x100
	CloneFs            = 0x200
	CloneFiles         = 0x400
	CloneSighand       = 0x800
	ClonePtrace        = 0x2000
	CloneVfork         = 0x4000
	CloneParent        = 0x8000
	CloneThread        = 0x10000
	CloneNewns         = 0x20000
	CloneSysvsem       = 0x40000
	CloneSettls        = 0x80000
	CloneParentSettid  = 0x100000
	CloneChildCleartid = 0x200000
	CloneUntraced      = 0x800000
	CloneChildSettid   = 0x1000000
	CloneStopped       = 0x2000000
	CloneNewuts        = 0x4000000
	CloneNewipc        = 0x8000000

	ValidCloneFlags = CloneVm |
		CloneFs |
		CloneFiles |
		CloneSighand |
		CloneSysvsem |
		CloneThread
)

SysClone flags Handling is meant to support go runtime use cases Pulled from: https://github.com/golang/go/blob/go1.21.3/src/runtime/os_linux.go#L124-L158

View Source
const (
	// SchedQuantum is the number of steps dedicated for a thread before it's preempted. Effectively used to emulate thread "time slices"
	SchedQuantum = 100_000

	// HZ is the assumed clock rate of an emulated MIPS32 CPU.
	// The value of HZ is a rough estimate of the Cannon instruction count / second on a typical machine.
	// HZ is used to emulate the clock_gettime syscall used by guest programs that have a Go runtime.
	// The Go runtime consumes the system time to determine when to initiate gc assists and for goroutine scheduling.
	// A HZ value that is too low (i.e. lower than the emulation speed) results in the main goroutine attempting to assist with GC more often.
	// Adjust this value accordingly as the emulation speed changes. The HZ value should be within the same order of magnitude as the emulation speed.
	HZ = 10_000_000

	// ClockGettimeRealtimeFlag is the clock_gettime clock id for Linux's realtime clock: https://github.com/torvalds/linux/blob/ad618736883b8970f66af799e34007475fe33a68/include/uapi/linux/time.h#L49
	ClockGettimeRealtimeFlag = 0
	// ClockGettimeMonotonicFlag is the clock_gettime clock id for Linux's monotonic clock: https://github.com/torvalds/linux/blob/ad618736883b8970f66af799e34007475fe33a68/include/uapi/linux/time.h#L50
	ClockGettimeMonotonicFlag = 1
)

Other constants

View Source
const (
	AddressMask = arch.AddressMask
)

Variables

This section is empty.

Functions

func GetInstructionDetails

func GetInstructionDetails(pc Word, memory *memory.Memory) (insn, opcode, fun uint32)

func HandleBranch

func HandleBranch(cpu *mipsevm.CpuScalars, registers *[32]Word, opcode uint32, insn uint32, rtReg Word, rs Word) error

func HandleHiLo

func HandleHiLo(cpu *mipsevm.CpuScalars, registers *[32]Word, fun uint32, rs Word, rt Word, storeReg Word) error

func HandleJump

func HandleJump(cpu *mipsevm.CpuScalars, registers *[32]Word, linkReg Word, dest Word) error

func HandleRd

func HandleRd(cpu *mipsevm.CpuScalars, registers *[32]Word, storeReg Word, val Word, conditional bool) error

func HandleSysRead

func HandleSysRead(
	a0, a1, a2 Word,
	preimageKey [32]byte,
	preimageOffset Word,
	preimageReader PreimageReader,
	memory *memory.Memory,
	memTracker MemTracker,
) (v0, v1, newPreimageOffset Word, memUpdated bool, memAddr Word)

func HandleSysWrite

func HandleSysWrite(a0, a1, a2 Word,
	lastHint hexutil.Bytes,
	preimageKey [32]byte,
	preimageOffset Word,
	oracle mipsevm.PreimageOracle,
	memory *memory.Memory,
	memTracker MemTracker,
	stdOut, stdErr io.Writer,
) (v0, v1 Word, newLastHint hexutil.Bytes, newPreimageKey common.Hash, newPreimageOffset Word)

func HandleSyscallUpdates

func HandleSyscallUpdates(cpu *mipsevm.CpuScalars, registers *[32]Word, v0, v1 Word)

Types

type MemTracker

type MemTracker interface {
	TrackMemAccess(addr Word)
}

type MemoryTrackerImpl

type MemoryTrackerImpl struct {
	// contains filtered or unexported fields
}

func NewMemoryTracker

func NewMemoryTracker(memory *memory.Memory) *MemoryTrackerImpl

func (*MemoryTrackerImpl) MemProof

func (m *MemoryTrackerImpl) MemProof() [memory.MemProofSize]byte

func (*MemoryTrackerImpl) MemProof2 added in v1.9.3

func (m *MemoryTrackerImpl) MemProof2() [memory.MemProofSize]byte

func (*MemoryTrackerImpl) Reset

func (m *MemoryTrackerImpl) Reset(enableProof bool)

func (*MemoryTrackerImpl) TrackMemAccess

func (m *MemoryTrackerImpl) TrackMemAccess(effAddr Word)

func (*MemoryTrackerImpl) TrackMemAccess2 added in v1.9.3

func (m *MemoryTrackerImpl) TrackMemAccess2(effAddr Word)

TrackMemAccess2 creates a proof for a memory access following a call to TrackMemAccess This is used to generate proofs for contiguous memory accesses within the same step

type NoopStackTracker

type NoopStackTracker struct{}

func (*NoopStackTracker) PopStack

func (n *NoopStackTracker) PopStack()

func (*NoopStackTracker) PushStack

func (n *NoopStackTracker) PushStack(caller Word, target Word)

func (*NoopStackTracker) Traceback

func (n *NoopStackTracker) Traceback()

type PreimageReader

type PreimageReader interface {
	ReadPreimage(key [32]byte, offset Word) (dat [32]byte, datLen Word)
}

type StackTracker

type StackTracker interface {
	PushStack(caller Word, target Word)
	PopStack()
}

type StackTrackerImpl

type StackTrackerImpl struct {
	// contains filtered or unexported fields
}

func NewStackTracker

func NewStackTracker(state mipsevm.FPVMState, meta mipsevm.Metadata) (*StackTrackerImpl, error)

func NewStackTrackerUnsafe

func NewStackTrackerUnsafe(state mipsevm.FPVMState, meta mipsevm.Metadata) *StackTrackerImpl

NewStackTrackerUnsafe creates a new TraceableStackTracker without verifying meta is not nil

func (*StackTrackerImpl) PopStack

func (s *StackTrackerImpl) PopStack()

func (*StackTrackerImpl) PushStack

func (s *StackTrackerImpl) PushStack(caller Word, target Word)

func (*StackTrackerImpl) Traceback

func (s *StackTrackerImpl) Traceback()

type TraceableStackTracker

type TraceableStackTracker interface {
	StackTracker
	Traceback()
}

type TrackingPreimageOracleReader

type TrackingPreimageOracleReader struct {
	// contains filtered or unexported fields
}

TrackingPreimageOracleReader wraps around a PreimageOracle, implements the PreimageOracle interface, and adds tracking functionality. It also implements the PreimageReader interface

func (*TrackingPreimageOracleReader) GetPreimage

func (p *TrackingPreimageOracleReader) GetPreimage(k [32]byte) []byte

func (*TrackingPreimageOracleReader) Hint

func (p *TrackingPreimageOracleReader) Hint(v []byte)

func (*TrackingPreimageOracleReader) LastPreimage

func (p *TrackingPreimageOracleReader) LastPreimage() ([32]byte, []byte, Word)

func (*TrackingPreimageOracleReader) NumPreimageRequests

func (p *TrackingPreimageOracleReader) NumPreimageRequests() int

func (*TrackingPreimageOracleReader) ReadPreimage

func (p *TrackingPreimageOracleReader) ReadPreimage(key [32]byte, offset Word) (dat [32]byte, datLen Word)

func (*TrackingPreimageOracleReader) Reset

func (p *TrackingPreimageOracleReader) Reset()

func (*TrackingPreimageOracleReader) TotalPreimageSize

func (p *TrackingPreimageOracleReader) TotalPreimageSize() int

type Word added in v1.9.4

type Word = arch.Word

func ExecMipsCoreStepLogic

func ExecMipsCoreStepLogic(cpu *mipsevm.CpuScalars, registers *[32]Word, memory *memory.Memory, insn, opcode, fun uint32, memTracker MemTracker, stackTracker StackTracker) (memUpdated bool, memAddr Word, err error)

func ExecuteMipsInstruction

func ExecuteMipsInstruction(insn uint32, opcode uint32, fun uint32, rs, rt, mem Word) Word

func GetSyscallArgs

func GetSyscallArgs(registers *[32]Word) (syscallNum, a0, a1, a2, a3 Word)

func HandleSysFcntl

func HandleSysFcntl(a0, a1 Word) (v0, v1 Word)

func HandleSysMmap

func HandleSysMmap(a0, a1, heap Word) (v0, v1, newHeap Word)

func SignExtend

func SignExtend(dat Word, idx Word) Word

func SignExtendImmediate added in v1.9.3

func SignExtendImmediate(insn uint32) Word

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL