Documentation ¶
Overview ¶
Package arch provides abstractions around architecture-dependent details, such as syscall calling conventions, native types, etc.
Index ¶
- Constants
- Variables
- type Arch
- type AuxEntry
- type Auxv
- type Context
- type ErrFloatingPoint
- type FloatingPointData
- type MmapDirection
- type MmapLayout
- type NativeSignalAct
- type NativeSignalStack
- type Registers
- type SignalAct
- func (s *SignalAct) CopyIn(cc marshal.CopyContext, addr usermem.Addr) (int, error)
- func (s *SignalAct) CopyOut(cc marshal.CopyContext, addr usermem.Addr) (int, error)
- func (s *SignalAct) CopyOutN(cc marshal.CopyContext, addr usermem.Addr, limit int) (int, error)
- func (s *SignalAct) DeserializeTo(other *SignalAct)
- func (s SignalAct) HasRestorer() bool
- func (s SignalAct) IsNoDefer() bool
- func (s SignalAct) IsOnStack() bool
- func (s SignalAct) IsResetHandler() bool
- func (s SignalAct) IsRestart() bool
- func (s SignalAct) IsSigInfo() bool
- func (s *SignalAct) MarshalBytes(dst []byte)
- func (s *SignalAct) MarshalUnsafe(dst []byte)
- func (s *SignalAct) Packed() bool
- func (s *SignalAct) SerializeFrom(other *SignalAct)
- func (s *SignalAct) SizeBytes() int
- func (s *SignalAct) StateFields() []string
- func (s *SignalAct) StateLoad(stateSourceObject state.Source)
- func (s *SignalAct) StateSave(stateSinkObject state.Sink)
- func (s *SignalAct) StateTypeName() string
- func (s *SignalAct) UnmarshalBytes(src []byte)
- func (s *SignalAct) UnmarshalUnsafe(src []byte)
- func (s *SignalAct) WriteTo(writer io.Writer) (int64, error)
- type SignalContext64
- func (s *SignalContext64) CopyIn(cc marshal.CopyContext, addr usermem.Addr) (int, error)
- func (s *SignalContext64) CopyOut(cc marshal.CopyContext, addr usermem.Addr) (int, error)
- func (s *SignalContext64) CopyOutN(cc marshal.CopyContext, addr usermem.Addr, limit int) (int, error)
- func (s *SignalContext64) MarshalBytes(dst []byte)
- func (s *SignalContext64) MarshalUnsafe(dst []byte)
- func (s *SignalContext64) Packed() bool
- func (s *SignalContext64) SizeBytes() int
- func (s *SignalContext64) UnmarshalBytes(src []byte)
- func (s *SignalContext64) UnmarshalUnsafe(src []byte)
- func (s *SignalContext64) WriteTo(writer io.Writer) (int64, error)
- type SignalInfo
- func (s *SignalInfo) Addr() uint64
- func (s *SignalInfo) Arch() uint32
- func (s *SignalInfo) Band() int64
- func (s *SignalInfo) CallAddr() uint64
- func (s *SignalInfo) CopyIn(cc marshal.CopyContext, addr usermem.Addr) (int, error)
- func (s *SignalInfo) CopyOut(cc marshal.CopyContext, addr usermem.Addr) (int, error)
- func (s *SignalInfo) CopyOutN(cc marshal.CopyContext, addr usermem.Addr, limit int) (int, error)
- func (s *SignalInfo) FD() uint32
- func (s *SignalInfo) FixSignalCodeForUser()
- func (s *SignalInfo) MarshalBytes(dst []byte)
- func (s *SignalInfo) MarshalUnsafe(dst []byte)
- func (s *SignalInfo) Overrun() int32
- func (s *SignalInfo) PID() int32
- func (s *SignalInfo) Packed() bool
- func (s *SignalInfo) SetAddr(val uint64)
- func (s *SignalInfo) SetArch(val uint32)
- func (s *SignalInfo) SetBand(val int64)
- func (s *SignalInfo) SetCallAddr(val uint64)
- func (s *SignalInfo) SetFD(val uint32)
- func (s *SignalInfo) SetOverrun(val int32)
- func (s *SignalInfo) SetPID(val int32)
- func (s *SignalInfo) SetSigval(val uint64)
- func (s *SignalInfo) SetStatus(val int32)
- func (s *SignalInfo) SetSyscall(val int32)
- func (s *SignalInfo) SetTimerID(val linux.TimerID)
- func (s *SignalInfo) SetUID(val int32)
- func (s *SignalInfo) Sigval() uint64
- func (s *SignalInfo) SizeBytes() int
- func (s *SignalInfo) StateFields() []string
- func (s *SignalInfo) StateLoad(stateSourceObject state.Source)
- func (s *SignalInfo) StateSave(stateSinkObject state.Sink)
- func (s *SignalInfo) StateTypeName() string
- func (s *SignalInfo) Status() int32
- func (s *SignalInfo) Syscall() int32
- func (s *SignalInfo) TimerID() linux.TimerID
- func (s *SignalInfo) UID() int32
- func (s *SignalInfo) UnmarshalBytes(src []byte)
- func (s *SignalInfo) UnmarshalUnsafe(src []byte)
- func (s *SignalInfo) WriteTo(writer io.Writer) (int64, error)
- type SignalStack
- func (s *SignalStack) Contains(sp usermem.Addr) bool
- func (s *SignalStack) CopyIn(cc marshal.CopyContext, addr usermem.Addr) (int, error)
- func (s *SignalStack) CopyOut(cc marshal.CopyContext, addr usermem.Addr) (int, error)
- func (s *SignalStack) CopyOutN(cc marshal.CopyContext, addr usermem.Addr, limit int) (int, error)
- func (s *SignalStack) DeserializeTo(other *SignalStack)
- func (s SignalStack) IsEnabled() bool
- func (s *SignalStack) MarshalBytes(dst []byte)
- func (s *SignalStack) MarshalUnsafe(dst []byte)
- func (s *SignalStack) Packed() bool
- func (s *SignalStack) SerializeFrom(other *SignalStack)
- func (s *SignalStack) SetOnStack()
- func (s *SignalStack) SizeBytes() int
- func (s *SignalStack) StateFields() []string
- func (s *SignalStack) StateLoad(stateSourceObject state.Source)
- func (s *SignalStack) StateSave(stateSinkObject state.Sink)
- func (s *SignalStack) StateTypeName() string
- func (s SignalStack) Top() usermem.Addr
- func (s *SignalStack) UnmarshalBytes(src []byte)
- func (s *SignalStack) UnmarshalUnsafe(src []byte)
- func (s *SignalStack) WriteTo(writer io.Writer) (int64, error)
- type Stack
- func (s *Stack) Align(offset int)
- func (s *Stack) CopyInBytes(sentinel usermem.Addr, b []byte) (int, error)
- func (s *Stack) CopyOutBytes(sentinel usermem.Addr, b []byte) (int, error)
- func (s *Stack) CopyScratchBuffer(size int) []byte
- func (s *Stack) Load(args []string, env []string, aux Auxv) (StackLayout, error)
- func (s *Stack) PushNullTerminatedByteSlice(bs []byte) (int, error)
- type StackLayout
- type State
- func (s *State) CPUIDEmulate(l log.Logger)
- func (s *State) ClearSingleStep()
- func (f State) FloatingPointData() *FloatingPointData
- func (s *State) Fork() State
- func (s *State) FullRestore() bool
- func (s State) Proto() *rpb.Registers
- func (s *State) PtraceGetFPRegs(dst io.Writer) (int, error)
- func (s *State) PtraceGetRegSet(regset uintptr, dst io.Writer, maxlen int) (int, error)
- func (s *State) PtraceGetRegs(dst io.Writer) (int, error)
- func (s *State) PtraceSetFPRegs(src io.Reader) (int, error)
- func (s *State) PtraceSetRegSet(regset uintptr, src io.Reader, maxlen int) (int, error)
- func (s *State) PtraceSetRegs(src io.Reader) (int, error)
- func (s *State) RegisterMap() (map[string]uintptr, error)
- func (s *State) SetSingleStep()
- func (s *State) SingleStep() bool
- func (s *State) StateData() *State
- func (s *State) StateFields() []string
- func (s *State) StateLoad(stateSourceObject state.Source)
- func (s *State) StateSave(stateSinkObject state.Sink)
- func (s *State) StateTypeName() string
- type SyscallArgument
- type SyscallArguments
- type UContext64
- func (u *UContext64) CopyIn(cc marshal.CopyContext, addr usermem.Addr) (int, error)
- func (u *UContext64) CopyOut(cc marshal.CopyContext, addr usermem.Addr) (int, error)
- func (u *UContext64) CopyOutN(cc marshal.CopyContext, addr usermem.Addr, limit int) (int, error)
- func (u *UContext64) MarshalBytes(dst []byte)
- func (u *UContext64) MarshalUnsafe(dst []byte)
- func (u *UContext64) Packed() bool
- func (u *UContext64) SizeBytes() int
- func (u *UContext64) UnmarshalBytes(src []byte)
- func (u *UContext64) UnmarshalUnsafe(src []byte)
- func (u *UContext64) WriteTo(writer io.Writer) (int64, error)
Constants ¶
const ( // SignalActDefault is SIG_DFL and specifies that the default behavior for // a signal should be taken. SignalActDefault = 0 // SignalActIgnore is SIG_IGN and specifies that a signal should be // ignored. SignalActIgnore = 1 )
Special values for SignalAct.Handler.
const ( SignalFlagNoCldStop = 0x00000001 SignalFlagNoCldWait = 0x00000002 SignalFlagSigInfo = 0x00000004 SignalFlagRestorer = 0x04000000 SignalFlagOnStack = 0x08000000 SignalFlagRestart = 0x10000000 SignalFlagInterrupt = 0x20000000 SignalFlagNoDefer = 0x40000000 SignalFlagResetHandler = 0x80000000 )
Available signal flags.
const ( // SignalInfoUser (properly SI_USER) indicates that a signal was sent from // a kill() or raise() syscall. SignalInfoUser = 0 // SignalInfoKernel (properly SI_KERNEL) indicates that the signal was sent // by the kernel. SignalInfoKernel = 0x80 // SignalInfoTimer (properly SI_TIMER) indicates that the signal was sent // by an expired timer. SignalInfoTimer = -2 // SignalInfoTkill (properly SI_TKILL) indicates that the signal was sent // from a tkill() or tgkill() syscall. SignalInfoTkill = -6 // CLD_EXITED indicates that a task exited. CLD_EXITED = 1 // CLD_KILLED indicates that a task was killed by a signal. CLD_KILLED = 2 // CLD_DUMPED indicates that a task was killed by a signal and then dumped // core. CLD_DUMPED = 3 // CLD_TRAPPED indicates that a task was stopped by ptrace. CLD_TRAPPED = 4 // CLD_STOPPED indicates that a thread group completed a group stop. CLD_STOPPED = 5 // CLD_CONTINUED indicates that a group-stopped thread group was continued. CLD_CONTINUED = 6 // SYS_SECCOMP indicates that a signal originates from seccomp. SYS_SECCOMP = 1 // TRAP_BRKPT indicates a breakpoint trap. TRAP_BRKPT = 1 )
Possible values for SignalInfo.Code. These values originate from the Linux kernel's include/uapi/asm-generic/siginfo.h.
const ( // SignalStackFlagOnStack is possible set on return from getaltstack, // in order to indicate that the thread is currently on the alt stack. SignalStackFlagOnStack = 1 // SignalStackFlagDisable is a flag to indicate the stack is disabled. SignalStackFlagDisable = 2 )
const Host = AMD64
Host specifies the host architecture.
const StackBottomMagic = ^usermem.Addr(0) // usermem.Addr(-1)
StackBottomMagic is the special address callers must past to all stack marshalling operations to cause the src/dst address to be computed based on the current end of the stack.
const (
// SyscallWidth is the width of syscall, sysenter, and int 80 insturctions.
SyscallWidth = 2
)
System-related constants for x86.
Variables ¶
var ( // TrapInstruction is the x86 trap instruction. TrapInstruction = [1]byte{0xcc} // CPUIDInstruction is the x86 CPUID instruction. CPUIDInstruction = [2]byte{0xf, 0xa2} // X86TrapFlag is an exported const for use by other packages. X86TrapFlag uint64 = (1 << 8) )
Functions ¶
This section is empty.
Types ¶
type AuxEntry ¶
An AuxEntry represents an entry in an ELF auxiliary vector.
+stateify savable
func (*AuxEntry) StateFields ¶
func (*AuxEntry) StateTypeName ¶
type Context ¶
type Context interface { // Arch returns the architecture for this Context. Arch() Arch // Native converts a generic type to a native value. // // Because the architecture is not specified here, we may be dealing // with return values of varying sizes (for example ARCH_GETFS). This // is a simple utility function to convert to the native size in these // cases, and then we can CopyOut. Native(val uintptr) marshal.Marshallable // Value converts a native type back to a generic value. // Once a value has been converted to native via the above call -- it // can be converted back here. Value(val marshal.Marshallable) uintptr // Width returns the number of bytes for a native value. Width() uint // Fork creates a clone of the context. Fork() Context // SyscallNo returns the syscall number. SyscallNo() uintptr // SyscallSaveOrig save orignal register value. SyscallSaveOrig() // SyscallArgs returns the syscall arguments in an array. SyscallArgs() SyscallArguments // Return returns the return value for a system call. Return() uintptr // SetReturn sets the return value for a system call. SetReturn(value uintptr) // RestartSyscall reverses over the current syscall instruction, such that // when the application resumes execution the syscall will be re-attempted. RestartSyscall() // RestartSyscallWithRestartBlock reverses over the current syscall // instraction and overwrites the current syscall number with that of // restart_syscall(2). This causes the application to restart the current // syscall with a custom function when execution resumes. RestartSyscallWithRestartBlock() // IP returns the current instruction pointer. IP() uintptr // SetIP sets the current instruction pointer. SetIP(value uintptr) // Stack returns the current stack pointer. Stack() uintptr // SetStack sets the current stack pointer. SetStack(value uintptr) // TLS returns the current TLS pointer. TLS() uintptr // SetTLS sets the current TLS pointer. Returns false if value is invalid. SetTLS(value uintptr) bool // SetOldRSeqInterruptedIP sets the register that contains the old IP // when an "old rseq" restartable sequence is interrupted. SetOldRSeqInterruptedIP(value uintptr) // StateData returns a pointer to underlying architecture state. StateData() *State // RegisterMap returns a map of all registers. RegisterMap() (map[string]uintptr, error) // NewSignalAct returns a new object that is equivalent to struct sigaction // in the guest architecture. NewSignalAct() NativeSignalAct // NewSignalStack returns a new object that is equivalent to stack_t in the // guest architecture. NewSignalStack() NativeSignalStack // SignalSetup modifies the context in preparation for handling the // given signal. // // st is the stack where the signal handler frame should be // constructed. // // act is the SignalAct that specifies how this signal is being // handled. // // info is the SignalInfo of the signal being delivered. // // alt is the alternate signal stack (even if the alternate signal // stack is not going to be used). // // sigset is the signal mask before entering the signal handler. SignalSetup(st *Stack, act *SignalAct, info *SignalInfo, alt *SignalStack, sigset linux.SignalSet) error // SignalRestore restores context after returning from a signal // handler. // // st is the current thread stack. // // rt is true if SignalRestore is being entered from rt_sigreturn and // false if SignalRestore is being entered from sigreturn. // SignalRestore returns the thread's new signal mask. SignalRestore(st *Stack, rt bool) (linux.SignalSet, SignalStack, error) // CPUIDEmulate emulates a CPUID instruction according to current register state. CPUIDEmulate(l log.Logger) // SingleStep returns true if single stepping is enabled. SingleStep() bool // SetSingleStep enables single stepping. SetSingleStep() // ClearSingleStep disables single stepping. ClearSingleStep() // FloatingPointData will be passed to underlying save routines. FloatingPointData() *FloatingPointData // NewMmapLayout returns a layout for a new MM, where MinAddr for the // returned layout must be no lower than min, and MaxAddr for the returned // layout must be no higher than max. Repeated calls to NewMmapLayout may // return different layouts. NewMmapLayout(min, max usermem.Addr, limits *limits.LimitSet) (MmapLayout, error) // PIELoadAddress returns a preferred load address for a // position-independent executable within l. PIELoadAddress(l MmapLayout) usermem.Addr // FeatureSet returns the FeatureSet in use in this context. FeatureSet() *cpuid.FeatureSet // PtracePeekUser implements ptrace(PTRACE_PEEKUSR). PtracePeekUser(addr uintptr) (marshal.Marshallable, error) // PtracePokeUser implements ptrace(PTRACE_POKEUSR). PtracePokeUser(addr, data uintptr) error // PtraceGetRegs implements ptrace(PTRACE_GETREGS) by writing the // general-purpose registers represented by this Context to dst and // returning the number of bytes written. PtraceGetRegs(dst io.Writer) (int, error) // PtraceSetRegs implements ptrace(PTRACE_SETREGS) by reading // general-purpose registers from src into this Context and returning the // number of bytes read. PtraceSetRegs(src io.Reader) (int, error) // PtraceGetFPRegs implements ptrace(PTRACE_GETFPREGS) by writing the // floating-point registers represented by this Context to addr in dst and // returning the number of bytes written. PtraceGetFPRegs(dst io.Writer) (int, error) // PtraceSetFPRegs implements ptrace(PTRACE_SETFPREGS) by reading // floating-point registers from src into this Context and returning the // number of bytes read. PtraceSetFPRegs(src io.Reader) (int, error) // PtraceGetRegSet implements ptrace(PTRACE_GETREGSET) by writing the // register set given by architecture-defined value regset from this // Context to dst and returning the number of bytes written, which must be // less than or equal to maxlen. PtraceGetRegSet(regset uintptr, dst io.Writer, maxlen int) (int, error) // PtraceSetRegSet implements ptrace(PTRACE_SETREGSET) by reading the // register set given by architecture-defined value regset from src and // returning the number of bytes read, which must be less than or equal to // maxlen. PtraceSetRegSet(regset uintptr, src io.Reader, maxlen int) (int, error) // FullRestore returns 'true' if all CPU registers must be restored // when switching to the untrusted application. Typically a task enters // and leaves the kernel via a system call. Platform.Switch() may // optimize for this by not saving/restoring all registers if allowed // by the ABI. For e.g. the amd64 ABI specifies that syscall clobbers // %rcx and %r11. If FullRestore returns true then these optimizations // must be disabled and all registers restored. FullRestore() bool }
Context provides architecture-dependent information for a specific thread.
NOTE(b/34169503): Currently we use uintptr here to refer to a generic native register value. While this will work for the foreseeable future, it isn't strictly correct. We may want to create some abstraction that makes this more clear or enables us to store values of arbitrary widths. This is particularly true for RegisterMap().
type ErrFloatingPoint ¶
type ErrFloatingPoint struct {
// contains filtered or unexported fields
}
ErrFloatingPoint indicates a failed restore due to unusable floating point state.
func (ErrFloatingPoint) Error ¶
func (e ErrFloatingPoint) Error() string
Error returns a sensible description of the restore error.
type FloatingPointData ¶
type FloatingPointData byte
FloatingPointData is a generic type, and will always be passed as a pointer. We rely on the individual arch implementations to meet all the necessary requirements. For example, on x86 the region must be 16-byte aligned and 512 bytes in size.
func NewFloatingPointData ¶
func NewFloatingPointData() *FloatingPointData
NewFloatingPointData returns a new floating point data blob.
This is primarily for use in tests.
type MmapDirection ¶
type MmapDirection int
MmapDirection is a search direction for mmaps.
const ( // MmapBottomUp instructs mmap to prefer lower addresses. MmapBottomUp MmapDirection = iota // MmapTopDown instructs mmap to prefer higher addresses. MmapTopDown )
type MmapLayout ¶
type MmapLayout struct { // MinAddr is the lowest mappable address. MinAddr usermem.Addr // MaxAddr is the highest mappable address. MaxAddr usermem.Addr // BottomUpBase is the lowest address that may be returned for a // MmapBottomUp mmap. BottomUpBase usermem.Addr // TopDownBase is the highest address that may be returned for a // MmapTopDown mmap. TopDownBase usermem.Addr // DefaultDirection is the direction for most non-fixed mmaps in this // layout. DefaultDirection MmapDirection // MaxStackRand is the maximum randomization to apply to stack // allocations to maintain a proper gap between the stack and // TopDownBase. MaxStackRand uint64 }
MmapLayout defines the layout of the user address space for a particular MemoryManager.
Note that "highest address" below is always exclusive.
+stateify savable
func (*MmapLayout) StateFields ¶
func (m *MmapLayout) StateFields() []string
func (*MmapLayout) StateLoad ¶
func (m *MmapLayout) StateLoad(stateSourceObject state.Source)
func (*MmapLayout) StateSave ¶
func (m *MmapLayout) StateSave(stateSinkObject state.Sink)
func (*MmapLayout) StateTypeName ¶
func (m *MmapLayout) StateTypeName() string
func (*MmapLayout) Valid ¶
func (m *MmapLayout) Valid() bool
Valid returns true if this layout is valid.
type NativeSignalAct ¶
type NativeSignalAct interface { marshal.Marshallable // SerializeFrom copies the data in the host SignalAct s into this object. SerializeFrom(s *SignalAct) // DeserializeTo copies the data in this object into the host SignalAct s. DeserializeTo(s *SignalAct) }
NativeSignalAct is a type that is equivalent to struct sigaction in the guest architecture.
type NativeSignalStack ¶
type NativeSignalStack interface { marshal.Marshallable // SerializeFrom copies the data in the host SignalStack s into this // object. SerializeFrom(s *SignalStack) // DeserializeTo copies the data in this object into the host SignalStack // s. DeserializeTo(s *SignalStack) }
NativeSignalStack is a type that is equivalent to stack_t in the guest architecture.
type Registers ¶
type Registers struct {
linux.PtraceRegs
}
Registers represents the CPU registers for this architecture.
+stateify savable
func (*Registers) StateFields ¶
func (*Registers) StateTypeName ¶
type SignalAct ¶
type SignalAct struct { Handler uint64 Flags uint64 Restorer uint64 // Only used on amd64. Mask linux.SignalSet }
SignalAct represents the action that should be taken when a signal is delivered, and is equivalent to struct sigaction.
+marshal +stateify savable
func (*SignalAct) DeserializeTo ¶
DeserializeTo implements NativeSignalAct.DeserializeTo.
func (SignalAct) HasRestorer ¶
HasRestorer returns true iff this SignalAct has the Restorer flag set.
func (SignalAct) IsResetHandler ¶
IsResetHandler returns true iff this SignalAct has the ResetHandler flag set.
func (*SignalAct) MarshalBytes ¶
MarshalBytes implements marshal.Marshallable.MarshalBytes.
func (*SignalAct) MarshalUnsafe ¶
MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
func (*SignalAct) SerializeFrom ¶
SerializeFrom implements NativeSignalAct.SerializeFrom.
func (*SignalAct) StateFields ¶
func (*SignalAct) StateTypeName ¶
func (*SignalAct) UnmarshalBytes ¶
UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
func (*SignalAct) UnmarshalUnsafe ¶
UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
type SignalContext64 ¶
type SignalContext64 struct { R8 uint64 R9 uint64 R10 uint64 R11 uint64 R12 uint64 R13 uint64 R14 uint64 R15 uint64 Rdi uint64 Rsi uint64 Rbp uint64 Rbx uint64 Rdx uint64 Rax uint64 Rcx uint64 Rsp uint64 Rip uint64 Eflags uint64 Cs uint16 Gs uint16 // always 0 on amd64. Fs uint16 // always 0 on amd64. Ss uint16 // only restored if _UC_STRICT_RESTORE_SS (unsupported). Err uint64 Trapno uint64 Oldmask linux.SignalSet Cr2 uint64 // Pointer to a struct _fpstate. See b/33003106#comment8. Fpstate uint64 Reserved [8]uint64 }
SignalContext64 is equivalent to struct sigcontext, the type passed as the second argument to signal handlers set by signal(2).
+marshal
func (*SignalContext64) CopyIn ¶
func (s *SignalContext64) CopyIn(cc marshal.CopyContext, addr usermem.Addr) (int, error)
CopyIn implements marshal.Marshallable.CopyIn.
func (*SignalContext64) CopyOut ¶
func (s *SignalContext64) CopyOut(cc marshal.CopyContext, addr usermem.Addr) (int, error)
CopyOut implements marshal.Marshallable.CopyOut.
func (*SignalContext64) CopyOutN ¶
func (s *SignalContext64) CopyOutN(cc marshal.CopyContext, addr usermem.Addr, limit int) (int, error)
CopyOutN implements marshal.Marshallable.CopyOutN.
func (*SignalContext64) MarshalBytes ¶
func (s *SignalContext64) MarshalBytes(dst []byte)
MarshalBytes implements marshal.Marshallable.MarshalBytes.
func (*SignalContext64) MarshalUnsafe ¶
func (s *SignalContext64) MarshalUnsafe(dst []byte)
MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
func (*SignalContext64) Packed ¶
func (s *SignalContext64) Packed() bool
Packed implements marshal.Marshallable.Packed.
func (*SignalContext64) SizeBytes ¶
func (s *SignalContext64) SizeBytes() int
SizeBytes implements marshal.Marshallable.SizeBytes.
func (*SignalContext64) UnmarshalBytes ¶
func (s *SignalContext64) UnmarshalBytes(src []byte)
UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
func (*SignalContext64) UnmarshalUnsafe ¶
func (s *SignalContext64) UnmarshalUnsafe(src []byte)
UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
type SignalInfo ¶
type SignalInfo struct { Signo int32 // Signal number Errno int32 // Errno value Code int32 // Signal code // struct siginfo::_sifields is a union. In SignalInfo, fields in the union // are accessed through methods. // // For reference, here is the definition of _sifields: (_sigfault._trapno, // which does not exist on x86, omitted for clarity) // // union { // int _pad[SI_PAD_SIZE]; // // /* kill() */ // struct { // __kernel_pid_t _pid; /* sender's pid */ // __ARCH_SI_UID_T _uid; /* sender's uid */ // } _kill; // // /* POSIX.1b timers */ // struct { // __kernel_timer_t _tid; /* timer id */ // int _overrun; /* overrun count */ // char _pad[sizeof( __ARCH_SI_UID_T) - sizeof(int)]; // sigval_t _sigval; /* same as below */ // int _sys_private; /* not to be passed to user */ // } _timer; // // /* POSIX.1b signals */ // struct { // __kernel_pid_t _pid; /* sender's pid */ // __ARCH_SI_UID_T _uid; /* sender's uid */ // sigval_t _sigval; // } _rt; // // /* SIGCHLD */ // struct { // __kernel_pid_t _pid; /* which child */ // __ARCH_SI_UID_T _uid; /* sender's uid */ // int _status; /* exit code */ // __ARCH_SI_CLOCK_T _utime; // __ARCH_SI_CLOCK_T _stime; // } _sigchld; // // /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */ // struct { // void *_addr; /* faulting insn/memory ref. */ // short _addr_lsb; /* LSB of the reported address */ // } _sigfault; // // /* SIGPOLL */ // struct { // __ARCH_SI_BAND_T _band; /* POLL_IN, POLL_OUT, POLL_MSG */ // int _fd; // } _sigpoll; // // /* SIGSYS */ // struct { // void *_call_addr; /* calling user insn */ // int _syscall; /* triggering system call number */ // unsigned int _arch; /* AUDIT_ARCH_* of syscall */ // } _sigsys; // } _sifields; // // _sifields is padded so that the size of siginfo is SI_MAX_SIZE = 128 // bytes. Fields [128 - 16]byte // contains filtered or unexported fields }
SignalInfo represents information about a signal being delivered, and is equivalent to struct siginfo in linux kernel(linux/include/uapi/asm-generic/siginfo.h).
+marshal +stateify savable
func (*SignalInfo) CallAddr ¶
func (s *SignalInfo) CallAddr() uint64
CallAddr returns the si_call_addr field.
func (*SignalInfo) CopyIn ¶
func (s *SignalInfo) CopyIn(cc marshal.CopyContext, addr usermem.Addr) (int, error)
CopyIn implements marshal.Marshallable.CopyIn.
func (*SignalInfo) CopyOut ¶
func (s *SignalInfo) CopyOut(cc marshal.CopyContext, addr usermem.Addr) (int, error)
CopyOut implements marshal.Marshallable.CopyOut.
func (*SignalInfo) CopyOutN ¶
func (s *SignalInfo) CopyOutN(cc marshal.CopyContext, addr usermem.Addr, limit int) (int, error)
CopyOutN implements marshal.Marshallable.CopyOutN.
func (*SignalInfo) FixSignalCodeForUser ¶
func (s *SignalInfo) FixSignalCodeForUser()
FixSignalCodeForUser fixes up si_code.
The si_code we get from Linux may contain the kernel-specific code in the top 16 bits if it's positive (e.g., from ptrace). Linux's copy_siginfo_to_user does
err |= __put_user((short)from->si_code, &to->si_code);
to mask out those bits and we need to do the same.
func (*SignalInfo) MarshalBytes ¶
func (s *SignalInfo) MarshalBytes(dst []byte)
MarshalBytes implements marshal.Marshallable.MarshalBytes.
func (*SignalInfo) MarshalUnsafe ¶
func (s *SignalInfo) MarshalUnsafe(dst []byte)
MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
func (*SignalInfo) Overrun ¶
func (s *SignalInfo) Overrun() int32
Overrun returns the si_overrun field.
func (*SignalInfo) Packed ¶
func (s *SignalInfo) Packed() bool
Packed implements marshal.Marshallable.Packed.
func (*SignalInfo) SetAddr ¶
func (s *SignalInfo) SetAddr(val uint64)
SetAddr sets the si_addr field.
func (*SignalInfo) SetArch ¶
func (s *SignalInfo) SetArch(val uint32)
SetArch mutates the si_arch field.
func (*SignalInfo) SetBand ¶
func (s *SignalInfo) SetBand(val int64)
SetBand mutates the si_band field.
func (*SignalInfo) SetCallAddr ¶
func (s *SignalInfo) SetCallAddr(val uint64)
SetCallAddr mutates the si_call_addr field.
func (*SignalInfo) SetOverrun ¶
func (s *SignalInfo) SetOverrun(val int32)
SetOverrun sets the si_overrun field.
func (*SignalInfo) SetSigval ¶
func (s *SignalInfo) SetSigval(val uint64)
SetSigval mutates the sigval field.
func (*SignalInfo) SetStatus ¶
func (s *SignalInfo) SetStatus(val int32)
SetStatus mutates the si_status field.
func (*SignalInfo) SetSyscall ¶
func (s *SignalInfo) SetSyscall(val int32)
SetSyscall mutates the si_syscall field.
func (*SignalInfo) SetTimerID ¶
func (s *SignalInfo) SetTimerID(val linux.TimerID)
SetTimerID sets the si_timerid field.
func (*SignalInfo) Sigval ¶
func (s *SignalInfo) Sigval() uint64
Sigval returns the sigval field, which is aliased to both si_int and si_ptr.
func (*SignalInfo) SizeBytes ¶
func (s *SignalInfo) SizeBytes() int
SizeBytes implements marshal.Marshallable.SizeBytes.
func (*SignalInfo) StateFields ¶
func (s *SignalInfo) StateFields() []string
func (*SignalInfo) StateLoad ¶
func (s *SignalInfo) StateLoad(stateSourceObject state.Source)
func (*SignalInfo) StateSave ¶
func (s *SignalInfo) StateSave(stateSinkObject state.Sink)
func (*SignalInfo) StateTypeName ¶
func (s *SignalInfo) StateTypeName() string
func (*SignalInfo) Syscall ¶
func (s *SignalInfo) Syscall() int32
Syscall returns the si_syscall field.
func (*SignalInfo) TimerID ¶
func (s *SignalInfo) TimerID() linux.TimerID
TimerID returns the si_timerid field.
func (*SignalInfo) UnmarshalBytes ¶
func (s *SignalInfo) UnmarshalBytes(src []byte)
UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
func (*SignalInfo) UnmarshalUnsafe ¶
func (s *SignalInfo) UnmarshalUnsafe(src []byte)
UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
type SignalStack ¶
type SignalStack struct { Addr uint64 Flags uint32 Size uint64 // contains filtered or unexported fields }
SignalStack represents information about a user stack, and is equivalent to stack_t.
+marshal +stateify savable
func (*SignalStack) Contains ¶
func (s *SignalStack) Contains(sp usermem.Addr) bool
Contains checks if the stack pointer is within this stack.
func (*SignalStack) CopyIn ¶
func (s *SignalStack) CopyIn(cc marshal.CopyContext, addr usermem.Addr) (int, error)
CopyIn implements marshal.Marshallable.CopyIn.
func (*SignalStack) CopyOut ¶
func (s *SignalStack) CopyOut(cc marshal.CopyContext, addr usermem.Addr) (int, error)
CopyOut implements marshal.Marshallable.CopyOut.
func (*SignalStack) CopyOutN ¶
func (s *SignalStack) CopyOutN(cc marshal.CopyContext, addr usermem.Addr, limit int) (int, error)
CopyOutN implements marshal.Marshallable.CopyOutN.
func (*SignalStack) DeserializeTo ¶
func (s *SignalStack) DeserializeTo(other *SignalStack)
DeserializeTo implements NativeSignalStack.DeserializeTo.
func (SignalStack) IsEnabled ¶
func (s SignalStack) IsEnabled() bool
IsEnabled returns true iff this signal stack is marked as enabled.
func (*SignalStack) MarshalBytes ¶
func (s *SignalStack) MarshalBytes(dst []byte)
MarshalBytes implements marshal.Marshallable.MarshalBytes.
func (*SignalStack) MarshalUnsafe ¶
func (s *SignalStack) MarshalUnsafe(dst []byte)
MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
func (*SignalStack) Packed ¶
func (s *SignalStack) Packed() bool
Packed implements marshal.Marshallable.Packed.
func (*SignalStack) SerializeFrom ¶
func (s *SignalStack) SerializeFrom(other *SignalStack)
SerializeFrom implements NativeSignalStack.SerializeFrom.
func (*SignalStack) SetOnStack ¶
func (s *SignalStack) SetOnStack()
SetOnStack marks this signal stack as in use.
Note that there is no corresponding ClearOnStack, and that this should only be called on copies that are serialized to userspace.
func (*SignalStack) SizeBytes ¶
func (s *SignalStack) SizeBytes() int
SizeBytes implements marshal.Marshallable.SizeBytes.
func (*SignalStack) StateFields ¶
func (s *SignalStack) StateFields() []string
func (*SignalStack) StateLoad ¶
func (s *SignalStack) StateLoad(stateSourceObject state.Source)
func (*SignalStack) StateSave ¶
func (s *SignalStack) StateSave(stateSinkObject state.Sink)
func (*SignalStack) StateTypeName ¶
func (s *SignalStack) StateTypeName() string
func (SignalStack) Top ¶
func (s SignalStack) Top() usermem.Addr
Top returns the stack's top address.
func (*SignalStack) UnmarshalBytes ¶
func (s *SignalStack) UnmarshalBytes(src []byte)
UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
func (*SignalStack) UnmarshalUnsafe ¶
func (s *SignalStack) UnmarshalUnsafe(src []byte)
UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
type Stack ¶
type Stack struct { // Our arch info. // We use this for automatic Native conversion of usermem.Addrs during // Push() and Pop(). Arch Context // The interface used to actually copy user memory. IO usermem.IO // Our current stack bottom. Bottom usermem.Addr // contains filtered or unexported fields }
Stack is a simple wrapper around a usermem.IO and an address. Stack implements marshal.CopyContext, and marshallable values can be pushed or popped from the stack through the marshal.Marshallable interface.
Stack is not thread-safe.
func (*Stack) CopyInBytes ¶
CopyInBytes implements marshal.CopyContext.CopyInBytes. CopyInBytes computes an appropriate address based on the current end of the stack. Callers must use the sentinel address StackBottomMagic to marshal methods to indicate this.
func (*Stack) CopyOutBytes ¶
CopyOutBytes implements marshal.CopyContext.CopyOutBytes. CopyOutBytes computes an appropriate address based on the current end of the stack. Callers use the sentinel address StackBottomMagic to marshal methods to indicate this.
func (*Stack) CopyScratchBuffer ¶
CopyScratchBuffer implements marshal.CopyContext.CopyScratchBuffer.
type StackLayout ¶
type StackLayout struct { // ArgvStart is the beginning of the argument vector. ArgvStart usermem.Addr // ArgvEnd is the end of the argument vector. ArgvEnd usermem.Addr // EnvvStart is the beginning of the environment vector. EnvvStart usermem.Addr // EnvvEnd is the end of the environment vector. EnvvEnd usermem.Addr }
StackLayout describes the location of the arguments and environment on the stack.
type State ¶
type State struct { // The system registers. Regs Registers // FeatureSet is a pointer to the currently active feature set. FeatureSet *cpuid.FeatureSet // contains filtered or unexported fields }
State contains the common architecture bits for X86 (the build tag of this file ensures it's only built on x86).
+stateify savable
func (*State) CPUIDEmulate ¶
CPUIDEmulate emulates a cpuid instruction.
func (*State) ClearSingleStep ¶
func (s *State) ClearSingleStep()
ClearSingleStep enables single stepping.
func (State) FloatingPointData ¶
func (f State) FloatingPointData() *FloatingPointData
FloatingPointData returns the raw data pointer.
func (*State) FullRestore ¶
FullRestore indicates whether a full restore is required.
func (*State) PtraceGetFPRegs ¶
PtraceGetFPRegs implements Context.PtraceGetFPRegs.
func (*State) PtraceGetRegSet ¶
PtraceGetRegSet implements Context.PtraceGetRegSet.
func (*State) PtraceGetRegs ¶
PtraceGetRegs implements Context.PtraceGetRegs.
func (*State) PtraceSetFPRegs ¶
PtraceSetFPRegs implements Context.PtraceSetFPRegs.
func (*State) PtraceSetRegSet ¶
PtraceSetRegSet implements Context.PtraceSetRegSet.
func (*State) PtraceSetRegs ¶
PtraceSetRegs implements Context.PtraceSetRegs.
func (*State) RegisterMap ¶
RegisterMap returns a map of all registers.
func (*State) SetSingleStep ¶
func (s *State) SetSingleStep()
SetSingleStep enables single stepping.
func (*State) SingleStep ¶
SingleStep implements Context.SingleStep.
func (*State) StateFields ¶
func (*State) StateTypeName ¶
type SyscallArgument ¶
type SyscallArgument struct { // Prefer to use accessor methods instead of 'Value' directly. Value uintptr }
SyscallArgument is an argument supplied to a syscall implementation. The methods used to access the arguments are named after the ***C type name*** and they convert to the closest Go type available. For example, Int() refers to a 32-bit signed integer argument represented in Go as an int32.
Using the accessor methods guarantees that the conversion between types is correct, taking into account size and signedness (i.e., zero-extension vs signed-extension).
func (SyscallArgument) Int ¶
func (a SyscallArgument) Int() int32
Int returns the int32 representation of a 32-bit signed integer argument.
func (SyscallArgument) Int64 ¶
func (a SyscallArgument) Int64() int64
Int64 returns the int64 representation of a 64-bit signed integer argument.
func (SyscallArgument) ModeT ¶
func (a SyscallArgument) ModeT() uint
ModeT returns the int representation of a mode_t argument.
func (SyscallArgument) Pointer ¶
func (a SyscallArgument) Pointer() usermem.Addr
Pointer returns the usermem.Addr representation of a pointer argument.
func (SyscallArgument) SizeT ¶
func (a SyscallArgument) SizeT() uint
SizeT returns the uint representation of a size_t argument.
func (SyscallArgument) Uint ¶
func (a SyscallArgument) Uint() uint32
Uint returns the uint32 representation of a 32-bit unsigned integer argument.
func (SyscallArgument) Uint64 ¶
func (a SyscallArgument) Uint64() uint64
Uint64 returns the uint64 representation of a 64-bit unsigned integer argument.
type SyscallArguments ¶
type SyscallArguments [6]SyscallArgument
SyscallArguments represents the set of arguments passed to a syscall.
type UContext64 ¶
type UContext64 struct { Flags uint64 Link uint64 Stack SignalStack MContext SignalContext64 Sigset linux.SignalSet }
UContext64 is equivalent to ucontext_t on 64-bit x86.
+marshal
func (*UContext64) CopyIn ¶
func (u *UContext64) CopyIn(cc marshal.CopyContext, addr usermem.Addr) (int, error)
CopyIn implements marshal.Marshallable.CopyIn.
func (*UContext64) CopyOut ¶
func (u *UContext64) CopyOut(cc marshal.CopyContext, addr usermem.Addr) (int, error)
CopyOut implements marshal.Marshallable.CopyOut.
func (*UContext64) CopyOutN ¶
func (u *UContext64) CopyOutN(cc marshal.CopyContext, addr usermem.Addr, limit int) (int, error)
CopyOutN implements marshal.Marshallable.CopyOutN.
func (*UContext64) MarshalBytes ¶
func (u *UContext64) MarshalBytes(dst []byte)
MarshalBytes implements marshal.Marshallable.MarshalBytes.
func (*UContext64) MarshalUnsafe ¶
func (u *UContext64) MarshalUnsafe(dst []byte)
MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
func (*UContext64) Packed ¶
func (u *UContext64) Packed() bool
Packed implements marshal.Marshallable.Packed.
func (*UContext64) SizeBytes ¶
func (u *UContext64) SizeBytes() int
SizeBytes implements marshal.Marshallable.SizeBytes.
func (*UContext64) UnmarshalBytes ¶
func (u *UContext64) UnmarshalBytes(src []byte)
UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
func (*UContext64) UnmarshalUnsafe ¶
func (u *UContext64) UnmarshalUnsafe(src []byte)
UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
Source Files ¶
- aligned.go
- arch.go
- arch_abi_autogen_unsafe.go
- arch_amd64.go
- arch_amd64_abi_autogen_unsafe.go
- arch_amd64_state_autogen.go
- arch_state_autogen.go
- arch_state_x86.go
- arch_unsafe_abi_autogen_unsafe.go
- arch_unsafe_state_autogen.go
- arch_x86.go
- arch_x86_abi_autogen_unsafe.go
- arch_x86_impl.go
- arch_x86_impl_abi_autogen_unsafe.go
- arch_x86_impl_state_autogen.go
- arch_x86_state_autogen.go
- auxv.go
- signal.go
- signal_act.go
- signal_amd64.go
- signal_info.go
- signal_stack.go
- stack.go
- stack_unsafe.go
- syscalls_amd64.go