Documentation
¶
Overview ¶
Package kvm provides an interface to the kvm system call.
Package kvm provides an interface to the kvm system call.
Index ¶
- Constants
- Variables
- type CPUIDEntry
- type CPUIDInfo
- type ClearDirtyLog
- type CreateRegion
- type DebugControl
- type DirtyLog
- type Exit
- type IOEventFD
- type MemoryRegion
- type Region
- type SetSignalMask
- type TPRAccessCtl
- type Tracee
- func (t *Tracee) Close() error
- func (t *Tracee) Detach() error
- func (t *Tracee) Event() unix.SignalfdSiginfo
- func (t *Tracee) GetIPtr() (uintptr, error)
- func (t *Tracee) GetRegs() (*syscall.PtraceRegs, error)
- func (t *Tracee) GetSigInfo() (*unix.SignalfdSiginfo, error)
- func (t *Tracee) GetSiginfo() (*unix.SignalfdSiginfo, error)
- func (t *Tracee) NewProc(id int) error
- func (t *Tracee) PID() int
- func (t *Tracee) Read(address uintptr, data []byte) error
- func (t *Tracee) ReadWord(address uintptr) (uint64, error)
- func (t *Tracee) Run() error
- func (t *Tracee) SetRegs(pr *syscall.PtraceRegs) error
- func (t *Tracee) SingleStep(onoff bool) error
- func (t *Tracee) String() string
- func (t *Tracee) Tab() []byte
- func (t *Tracee) Write(address uintptr, data []byte) error
- func (t *Tracee) WriteWord(address uintptr, word uint64) error
- type Translate
- type UserRegion
- type VAPICAddr
- type VMRun
Constants ¶
const ( /* CR0 bits */ CR0_PE = 1 CR0_MP = (1 << 1) CR0_EM = (1 << 2) CR0_TS = (1 << 3) CR0_ET = (1 << 4) CR0_NE = (1 << 5) CR0_WP = (1 << 16) CR0_AM = (1 << 18) CR0_NW = (1 << 29) CR0_CD = (1 << 30) CR0_PG = (1 << 31) /* CR4= bits */ CR4_VME = 1 CR4_PVI = (1 << 1) CR4_TSD = (1 << 2) CR4_DE = (1 << 3) CR4_PSE = (1 << 4) CR4_PAE = (1 << 5) CR4_MCE = (1 << 6) CR4_PGE = (1 << 7) CR4_PCE = (1 << 8) CR4_OSFXSR = (1 << 8) CR4_OSXMMEXCPT = (1 << 10) CR4_UMIP = (1 << 11) CR4_VMXE = (1 << 13) CR4_SMXE = (1 << 14) CR4_FSGSBASE = (1 << 16) CR4_PCIDE = (1 << 17) CR4_OSXSAVE = (1 << 18) CR4_SMEP = (1 << 20) CR4_SMAP = (1 << 21) EFER_SCE = 1 EFER_LME = (1 << 8) EFER_LMA = (1 << 10) EFER_NXE = (1 << 11) /* 64-bit page * entry bits */ PDE64_PRESENT = 1 PDE64_RW = (1 << 1) PDE64_USER = (1 << 2) PDE64_ACCESSED = (1 << 5) PDE64_DIRTY = (1 << 6) PDE64_PS = (1 << 7) PDE64_G = (1 << 8) )
const ( // Enable enables debug options in the guest Enable = 1 // SingleStep enables single step. SingleStep = 2 )
const ( ExitUnknown = 0 ExitException = 1 ExitIo = 2 ExitHypercall = 3 ExitDebug = 4 ExitHlt = 5 ExitMmio = 6 ExitIrqWindowOpen = 7 ExitShutdown = 8 ExitFailEntry = 9 ExitIntr = 10 ExitSetTPR = 11 ExitTPRAccess = 12 ExitNmi = 16 ExitInternalError = 17 ExitOsi = 18 // ExitPapr_hcall = 19 ExitWatchdog = 21 ExitEpr = 23 ExitSystemEvent = 24 ExitIoapicEOI = 26 )
KVM exit values.
const APIVersion = 12
APIVersion is the KVM API version. The only API version we support. The only API version anyway. This was a mistake remedied by the capability stuff.
const KVMIO = 0xAE
KVMIO is for the KVMIO ioctl.
const PageTableBase = 0xffff0000
PageTableBase is where our initial page tables go. EFI apps should not go near this.
Variables ¶
var ( // ErrTraceeExited is returned when a command is executed on a tracee // that has already exited. ErrTraceeExited = errors.New("tracee exited") // Debug can be set externally to trace activity. Debug = func(string, ...interface{}) {} )
Functions ¶
This section is empty.
Types ¶
type CPUIDEntry ¶
type CPUIDEntry struct {
// contains filtered or unexported fields
}
CPUIDEntry is one cpuid entry returned by KVM.
func (*CPUIDEntry) String ¶
func (e *CPUIDEntry) String() string
String implements String. It returns a string formatted as strace formats it: {nent=54, entries=[{function=0, index=0, flags=0, eax=0xd, ebx=0x68747541, ecx=0x444d4163, edx=0x69746e65},
type CPUIDInfo ¶
type CPUIDInfo struct {
// contains filtered or unexported fields
}
CPUIDInfo contains information about CPUID information. We've learned the hard way that it's best for the ents array to be really large -- too large -- 256 seems appropriate. KVM does not provide partial results; it just returns an error if len(ents) is too small.
func (*CPUIDInfo) String ¶
String implements String. It returns a string formatted as strace would format it: {nent=54, entries=[{function=0, index=0, flags=0, eax=0xd, ebx=0x68747541, ecx=0x444d4163, edx=0x69746e65}, ... With the one difference that there is a single line per cpuid (makes finding issues way easier)
type ClearDirtyLog ¶
ClearDirtyLog clears the dirty page log.
type CreateRegion ¶
CreateRegion is used for KVM_CREATE_MEMORY_REGION
type DebugControl ¶
type DebugControl struct { Control uint32 // contains filtered or unexported fields }
DebugControl controls guest debug.
type DirtyLog ¶
type DirtyLog struct { Slot uint32 // contains filtered or unexported fields }
DirtyLog gets a log of dirty pages.
type IOEventFD ¶
type IOEventFD struct { Datamatch uint64 Addr uint64 /* legal pio/mmio address */ Len uint32 /* 1, 2, 4, or 8 or 0 to ignore length */ FD int32 Flags uint32 // contains filtered or unexported fields }
IOEventFD controls how events are managed.
type MemoryRegion ¶
MemoryRegion is used for CREATE_MEMORY_REGION
type Region ¶
type Region struct {
// contains filtered or unexported fields
}
A Region defines a memory region. This is likely overkill; we likely don't want anything more than a single 2G region starting at 0.
type SetSignalMask ¶
type SetSignalMask struct {
// contains filtered or unexported fields
}
SetSignalMask sets the signal mask
type TPRAccessCtl ¶
TPRAccessCtl controls how TPRAccess is reported.
type Tracee ¶
type Tracee struct {
// contains filtered or unexported fields
}
A Tracee is a process that is being traced.
func New ¶
New returns a new Tracee. It will fail if the kvm device can not be opened. All the work done here is complex, but it all has to work or ... no kvm. But as soon as possible we shift to using the goroutine. FWIW.
func (*Tracee) Event ¶
func (t *Tracee) Event() unix.SignalfdSiginfo
func (*Tracee) GetRegs ¶
func (t *Tracee) GetRegs() (*syscall.PtraceRegs, error)
GetRegs reads the registers from the inferior.
func (*Tracee) GetSigInfo ¶
func (t *Tracee) GetSigInfo() (*unix.SignalfdSiginfo, error)
GetSigInfo gets the signal info for a pid into a *unix.SignalfdSiginfo
func (*Tracee) GetSiginfo ¶
func (t *Tracee) GetSiginfo() (*unix.SignalfdSiginfo, error)
GetSiginfo reads the signal information for the signal that stopped the inferior. Only valid on Unix if the inferior is stopped due to a signal.
func (*Tracee) NewProc ¶
NewProc creates a CPU, given an id. TODO :we're getting sloppy about the t.do stuff, fix.
func (*Tracee) ReadWord ¶
ReadWord reads the given word from the inferior's address space. Only allowed to read from Region 0 for now.
func (*Tracee) Run ¶
SingleStep continues the tracee for one instruction. Todo: see if we are in single step mode, if not, set, etc.
func (*Tracee) SetRegs ¶
func (t *Tracee) SetRegs(pr *syscall.PtraceRegs) error
SetRegs sets regs for a Tracee. The ability to set sregs is limited by what can be set in ptraceregs.
func (*Tracee) SingleStep ¶
EnableSingleStep enables single stepping the guest
type Translate ¶
type Translate struct { // LinearAddress is input. LinearAddress uint64 // This is output PhysicalAddress uint64 Valid uint8 Writeable uint8 Usermode uint8 // contains filtered or unexported fields }
Translate translates guest linear to physical? This is for for TRANSLATE
type UserRegion ¶
UserRegion is used for SET_USER_MEMORY_REGION