machine

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LowRAMStart                 = 0x0
	EBDAPointer                 = 0x40e
	BootGDTStart                = 0x500
	BootIDTStart                = 0x520
	PVHInfoStart                = 0x6000
	PVHModListStart             = 0x6040
	PVHMemMapStart              = 0x7000
	KernelCmdLine               = 0x2_0000
	KernelCmdLineSizeMax        = 0x1_0000
	MPTableStart                = 0x9_FC00
	EBDAStart                   = 0xA_0000
	RSDPPointer                 = EBDAStart
	SMBIOSStart                 = 0xF_0000
	HighRAMStart                = 0x10_0000
	Mem32BitReservedStart       = 0xC000_0000
	Mem32BitReservedSize        = PCIMMConfigSize + Mem32BitDeviceSize
	Mem32BitDeviceStart         = Mem32BitReservedStart
	Mem32BitDeviceSize          = 640 << 20
	PCIMMConfigStart            = Mem32BitDeviceStart + Mem32BitDeviceSize
	PCIMMConfigSize             = 256 << 20
	PCIMMIOConfigSizePerSegment = 4096 * 256
	KVMTSSStart                 = PCIMMConfigStart + PCIMMConfigSize
	KVMTSSSize                  = (3 * 4) << 10
	KVMIdentityMapStart         = KVMTSSStart + KVMTSSSize
	KVMIdentityMapSize          = 4 << 10
	IOAPICStart                 = 0xFEC0_0000
	IOAPICSize                  = 0x20
	APICStart                   = 0xFEE0_0000
	RAM64BitStart               = 0x1_0000_0000
)
View Source
const (
	CPUIDFeatures   = 0x40000001
	CPUIDSignature  = 0x40000000
	CPUIDFuncPerMon = 0x0A
)
View Source
const (
	MPStateRunnable uint32 = 0 + iota
	MPStateUninitialized
	MPStateInitReceived
	MPStateHalted
	MPStateSipiReceived
	MPStateStopped
	MPStateCheckStop
	MPStateOperating
	MPStateLoad
	MPStateApResetHold
	MPStateSuspended
)
View Source
const (
	CR0xPE = 1
	CR0xMP = (1 << 1)
	CR0xEM = (1 << 2)
	CR0xTS = (1 << 3)
	CR0xET = (1 << 4)
	CR0xNE = (1 << 5)
	CR0xWP = (1 << 16)
	CR0xAM = (1 << 18)
	CR0xNW = (1 << 29)
	CR0xCD = (1 << 30)
	CR0xPG = (1 << 31)

	CR4xVME        = 1
	CR4xPVI        = (1 << 1)
	CR4xTSD        = (1 << 2)
	CR4xDE         = (1 << 3)
	CR4xPSE        = (1 << 4)
	CR4xPAE        = (1 << 5)
	CR4xMCE        = (1 << 6)
	CR4xPGE        = (1 << 7)
	CR4xPCE        = (1 << 8)
	CR4xOSFXSR     = (1 << 8)
	CR4xOSXMMEXCPT = (1 << 10)
	CR4xUMIP       = (1 << 11)
	CR4xVMXE       = (1 << 13)
	CR4xSMXE       = (1 << 14)
	CR4xFSGSBASE   = (1 << 16)
	CR4xPCIDE      = (1 << 17)
	CR4xOSXSAVE    = (1 << 18)
	CR4xSMEP       = (1 << 20)
	CR4xSMAP       = (1 << 21)

	EFERxSCE = 1
	EFERxLME = (1 << 8)
	EFERxLMA = (1 << 10)
	EFERxNXE = (1 << 11)

	PDE64xPRESENT  = 1
	PDE64xRW       = (1 << 1)
	PDE64xUSER     = (1 << 2)
	PDE64xACCESSED = (1 << 5)
	PDE64xDIRTY    = (1 << 6)
	PDE64xPS       = (1 << 7)
	PDE64xG        = (1 << 8)
)
View Source
const (
	MagicSignature = 0x53726448

	LoadedHigh   = uint8(1 << 0)
	KeepSegments = uint8(1 << 6)
	CanUseHeap   = uint8(1 << 7)

	EddMbrSigMax = 16
	E820Max      = 128
	E820Ram      = 1
	E820Reserved = 2

	RealModeIvtBegin = 0x00000000
	EBDAStarted      = 0x0009fc00
	VGARAMBegin      = 0x000a0000
	MBBIOSBegin      = 0x000f0000
	MBBIOSEnd        = 0x000fffff
)
View Source
const (
	BlkIOPortStart = 0x6300
	BlkIOPortSize  = 0x100

	SectorSize = 512
)
View Source
const (
	NetIOPortStart = 0x6200
	NetIOPortSize  = 0x100
)
View Source
const (
	COM1Addr = 0x03f8
)
View Source
const KVMIO = 0xAE
View Source
const LAPICRegSize = 0x400
View Source
const (
	MinMemSize = 1 << 25
)
View Source
const (
	PlatformDeviceAreaSize = 1 << 20
)
View Source
const (
	QueueSize = 32
)
View Source
const (
	RedZone = "\xB8\xBE\xBA\xFE\xCA\x90\x0F\x0B"
)

Variables

View Source
var (
	ErrInvalidSel           = errors.New("queue sel is invalid")
	ErrIONotPermit          = errors.New("IO is not permitted for virtio device")
	ErrNoTxPacket           = errors.New("no packet for tx")
	ErrNoRxPacket           = errors.New("no packet for rx")
	ErrVQNotInit            = errors.New("vq not initialized")
	ErrNoRxBuf              = errors.New("no buffer found for rx")
	ErrZeroSizeKernel       = errors.New("kernel is 0 bytes")
	ErrBadVA                = errors.New("bad virtual address")
	ErrBadCPU               = errors.New("bad cpu number")
	ErrUnsupported          = errors.New("unsupported")
	ErrMemTooSmall          = errors.New("mem request must be at least 1<<20")
	ErrNotELF64File         = errors.New("file is not ELF64")
	ErrPTNoteHasNoFSize     = errors.New("elf program PT_NOTE has file size equal zero")
	ErrBridgeNotPermit      = errors.New("IO is not permitted for PCI bridge")
	ErrSignatureNotMatch    = errors.New("signature not match in bzImage")
	ErrOldProtocolVersion   = errors.New("old protocol version")
	ErrAlign                = errors.New("alignment is not a power of 2")
	ErrPVHEntryNotFound     = errors.New("no pvh entry found")
	ErrDataLenInvalid       = errors.New("invalid data size on port")
	ErrWriteToCF9           = errors.New("power cycle via 0xcf9")
	ErrUnexpectedExitReason = errors.New("unexpected kvm exit reason")
	ErrDebug                = errors.New("debug exit")
	ErrBadRegister          = errors.New("bad register")
	ErrBadArg               = errors.New("arg count must be in range 1..6")
	ErrBadArgType           = errors.New("bad arg type")
)

Functions

func Asm

func Asm(d *x86asm.Inst, pc uint64) string

func BytesToNum

func BytesToNum(bytes []byte) uint64

func CallInfo

func CallInfo(inst *x86asm.Inst, r *Regs) string

func CheckPVH

func CheckPVH(kern io.ReaderAt) (bool, error)

func ClearUserMemoryRegion

func ClearUserMemoryRegion(vmFd P, i uint32) error

func CreateDev

func CreateDev(vmFd P, dev *Device) error

func CreateIRQChip

func CreateIRQChip(vmFd P) error

func CreatePIT2

func CreatePIT2(vmFd P) error

func DebugEnabled

func DebugEnabled()

func GdtEntry

func GdtEntry(flags uint16, base uint32, limit uint32) uint64

func GetCPUID2

func GetCPUID2(vCpuFd P, kvmCPUID *CPUID) error

func GetClock

func GetClock(vmFd P, cd *ClockData) error

func GetDebugRegs

func GetDebugRegs(vCpuFd P, dregs *DebugRegs) error

func GetDirtyLog

func GetDirtyLog(vmFd P, dirtlog *DirtyLog) error

func GetEmulatedCPUID

func GetEmulatedCPUID(kvmFd P, kvmCPUID *CPUID) error

func GetIRQChip

func GetIRQChip(vmFd P, irqc *IRQChip) error

func GetLocalAPIC

func GetLocalAPIC(vCpuFd P, lapic *LAPICState) error

func GetMPState

func GetMPState(vCpuFd P, mps *MPState) error

func GetMSRFeatureIndexList

func GetMSRFeatureIndexList(kvmFd P, list *MSRList) error

func GetMSRIndexList

func GetMSRIndexList(kvmFd P, list *MSRList) error

func GetMSRs

func GetMSRs(vCpuFd P, msrs *MSRS) error

func GetNrMMUPages

func GetNrMMUPages(vmFd P, shadowMem *uint64) error

func GetPIT2

func GetPIT2(vmFd P, pstate *PITState2) error

func GetReg

func GetReg(r *Regs, reg x86asm.Reg) (*uint64, error)

func GetSRegs2

func GetSRegs2(vCpuFd P, sreg *SRegs2) error

func GetSupportedCPUID

func GetSupportedCPUID(kvmFd P, kvmCPUID *CPUID) error

func GetTSCKHz

func GetTSCKHz(vCpuFd P) (uint64, error)

func GetVCPUEvents

func GetVCPUEvents(vCpuFd P, event *VCPUEvents) error

func GetXCRS

func GetXCRS(vCpuFd P, xcrs *XCRS) error

func IRQLineStatus

func IRQLineStatus(vmFd P, irq, level uint32) error

func InitRegs

func InitRegs(vCpuFd P, bootIP uint64) error

func InitSRegs

func InitSRegs(vCpuFd P, gdttable GDT) error

func InjectInterrupt

func InjectInterrupt(vCpuFd P, intr uint32) error

func IsTerminal

func IsTerminal() bool

func KVMCapabilities

func KVMCapabilities() error

func NumToBytes

func NumToBytes(x interface{}) []byte

func ParsePVHEntry

func ParsePVHEntry(fwimg io.ReaderAt, phdr *elf.Prog) (uint32, error)

func Patch

func Patch(ids *CPUID, patches []*CPUIDPatch) error

func ProbeCPUID

func ProbeCPUID() error

func PutSMI

func PutSMI(vCpuFd P) error

func ReInjectControl

func ReInjectControl(vmFd P, mode uint8) error

func RegisterCoalescedMMIO

func RegisterCoalescedMMIO(vmFd P, addr uint64, size uint32) error

func Run

func Run(vCpuFd P) error

func SetCPUID2

func SetCPUID2(vCpuFd P, kvmCPUID *CPUID) error

func SetClock

func SetClock(vmFd P, cd *ClockData) error

func SetDebugRegs

func SetDebugRegs(vCpuFd P, dregs *DebugRegs) error

func SetGSIRouting

func SetGSIRouting(vmFd P, irqR *IRQRouting) error

func SetIRQChip

func SetIRQChip(vmFd P, irqc *IRQChip) error

func SetIdentityMapAddr

func SetIdentityMapAddr(vmFd P, addr uint32) error

func SetLocalAPIC

func SetLocalAPIC(vCpuFd P, lapic *LAPICState) error

func SetMPState

func SetMPState(vCpuFd P, mps *MPState) error

SetMPState sets the vcpu’s current multiprocessing state.

func SetMSRs

func SetMSRs(vCpuFd P, msrs *MSRS) error

func SetNrMMUPages

func SetNrMMUPages(vmFd P, shadowMem uint64) error

func SetPIT2

func SetPIT2(vmFd P, pstate *PITState2) error

func SetRawMode

func SetRawMode() (func(), error)

func SetRegs

func SetRegs(vCpuFd P, regs *Regs) error

func SetSRegs2

func SetSRegs2(vCpuFd P, sreg *SRegs2) error

func SetSregs

func SetSregs(vCpuFd P, sregs *Sregs) error

func SetTSCKHz

func SetTSCKHz(vCpuFd P, freq uint64) error

func SetTSSAddr

func SetTSSAddr(vmFd P, addr uint32) error

func SetUserMemoryRegion

func SetUserMemoryRegion(vmFd P, region *UserspaceMemoryRegion) error

func SetVCPUEvents

func SetVCPUEvents(vCpuFd P, event *VCPUEvents) error

func SetXCRS

func SetXCRS(vCpuFd P, xcrs *XCRS) error

func SizeToBits

func SizeToBits(size uint64) uint32

func TRPAccessReporting

func TRPAccessReporting(vCpuFd P, ctl *TRPAccessCtl) error

func Translate

func Translate(vCpuFd P, t *Translation) error

func UnregisterCoalescedMMIO

func UnregisterCoalescedMMIO(vmFd P, addr uint64, size uint32) error

func X86GetMCECapSupported

func X86GetMCECapSupported(kvmFd P, mceCap *uint64) error

func X86SetupMCE

func X86SetupMCE(vCpuFd P, mceCap *uint64) error

Types

type ACPIPMTimer

type ACPIPMTimer struct {
	Start time.Time
}

func NewACPIPMTimer

func NewACPIPMTimer() *ACPIPMTimer

func (*ACPIPMTimer) IOPort

func (a *ACPIPMTimer) IOPort() uint64

func (*ACPIPMTimer) In

func (a *ACPIPMTimer) In(base uint64, data []byte) error

func (*ACPIPMTimer) Out

func (a *ACPIPMTimer) Out(base uint64, data []byte) error

func (*ACPIPMTimer) Size

func (a *ACPIPMTimer) Size() uint64

type ACPIShutDown

type ACPIShutDown struct {
	Port       uint64
	ExitEvent  chan int
	ResetEvent chan int
}

func NewACPIShutDownEvent

func NewACPIShutDownEvent() *ACPIShutDown

func (*ACPIShutDown) IOPort

func (a *ACPIShutDown) IOPort() uint64

func (*ACPIShutDown) Read

func (a *ACPIShutDown) Read(base uint64, data []byte) error

func (*ACPIShutDown) Size

func (a *ACPIShutDown) Size() uint64

func (*ACPIShutDown) Write

func (a *ACPIShutDown) Write(base uint64, data []byte) error

type Blk

type Blk struct {
	Hdr          blkHdr
	Queues       [1]*VirtualQueue
	PhyMem       *PhysMemory
	LastAvailIdx [1]uint16

	IRQInjector IRQInjector
	// contains filtered or unexported fields
}

func NewBlk

func NewBlk(path string, irq uint8, irqInjector IRQInjector, m *PhysMemory) (*Blk, error)

func (*Blk) GetDeviceHeader

func (v *Blk) GetDeviceHeader() DeviceHeader

func (*Blk) IO

func (v *Blk) IO() error

func (*Blk) IOPort

func (v *Blk) IOPort() uint64

func (*Blk) IOThreadEntry

func (v *Blk) IOThreadEntry()

func (*Blk) In

func (v *Blk) In(port uint64, bytes []byte) error

func (*Blk) Out

func (v *Blk) Out(port uint64, bytes []byte) error

func (*Blk) Size

func (v *Blk) Size() uint64

type BlkReq

type BlkReq struct {
	Type uint32

	Sector uint64
	// contains filtered or unexported fields
}

type CMOS

type CMOS struct {
	Index uint8
	Data  []uint8
}

func NewCMOS

func NewCMOS(memBelow4G, memAbove4G uint64) *CMOS

func (*CMOS) IOPort

func (c *CMOS) IOPort() uint64

func (*CMOS) In

func (c *CMOS) In(base uint64, data []byte) error

func (*CMOS) Out

func (c *CMOS) Out(base uint64, data []byte) error

func (*CMOS) Size

func (c *CMOS) Size() uint64

type CPUID

type CPUID struct {
	Nent    uint32
	Padding uint32
	Entries []CPUIDEntry2
}

func NewCPUID

func NewCPUID(data []byte) (*CPUID, error)

func (*CPUID) Bytes

func (c *CPUID) Bytes() ([]byte, error)

type CPUIDEntry2

type CPUIDEntry2 struct {
	Function uint32
	Index    uint32
	Flags    uint32
	Eax      uint32
	Ebx      uint32
	Ecx      uint32
	Edx      uint32
	Padding  [3]uint32
}

type CPUIDPatch

type CPUIDPatch struct {
	Function uint32
	Index    uint32
	Flags    uint32
	EAXBit   uint8
	EBXBit   uint8
	ECXBit   uint8
	EDXBit   uint8
}

type Cap

type Cap uint8
const (
	CapIRQChip                  Cap = 0
	CapHLT                      Cap = 1
	CapMMUShadowCacheControl    Cap = 2
	CapUserMemory               Cap = 3
	CapSetTSSAddr               Cap = 4
	CapVAPIC                    Cap = 6
	CapEXTCPUID                 Cap = 7
	CapClockSource              Cap = 8
	CapNRVCPUS                  Cap = 9  /* returns recommended max vcpus per vm */
	CapNRMemSlots               Cap = 10 /* returns max memory slots per vm */
	CapPIT                      Cap = 11
	CapNopIODelay               Cap = 12
	CapPVMMU                    Cap = 13
	CapMPState                  Cap = 14
	CapCoalescedMMIO            Cap = 15
	CapSyncMMU                  Cap = 16 /* Changes to host mmap are reflected in guest */
	CapIOMMU                    Cap = 18
	CapDestroyMemoryRegionWorks Cap = 21
	CapUserNMI                  Cap = 22
	CapSetGuestDebug            Cap = 23
	CapReinjectControl          Cap = 24
	CapIRQRouting               Cap = 25
	CapIRQInjectStatus          Cap = 26
	CapAssignDevIRQ             Cap = 29
	CapJoinMemoryRegionsWorks   Cap = 30
	CapMCE                      Cap = 31
	CapIRQFD                    Cap = 32
	CapPIT2                     Cap = 33
	CapSetBootCPUID             Cap = 34
	CapPITState2                Cap = 35
	CapIOEventFD                Cap = 36
	CapSetIdentityMapAddr       Cap = 37
	CapXENHVM                   Cap = 38
	CapAdjustClock              Cap = 39
	CapInternalErrorData        Cap = 40
	CapVCPUEvents               Cap = 41
	CapS390PSW                  Cap = 42
	CapPPCSegState              Cap = 43
	CapHyperV                   Cap = 44
	CapHyperVVAPIC              Cap = 45
	CapHyperVSPIN               Cap = 46
	CapPCISEgment               Cap = 47
	CapPPCPairedSingles         Cap = 48
	CapINTRShadow               Cap = 49
	CapDebugRegs                Cap = 50
	CapX86RobustSinglestep      Cap = 51
	CapPPCOSI                   Cap = 52
	CapPPCUnsetIRQ              Cap = 53
	CapEnableCap                Cap = 54
	CapXSave                    Cap = 55
	CapXCRS                     Cap = 56
	CapPPCGetPVInfo             Cap = 57
	CapPPCIRQLevel              Cap = 58
	CapASYNCPF                  Cap = 59
	CapTSCControl               Cap = 60
	CapGetTSCkHz                Cap = 61
	CapPPCBookeSREGS            Cap = 62
	CapSPAPRTCE                 Cap = 63
	CapPPCSMT                   Cap = 64
	CapPPCRMA                   Cap = 65
	CapMAXVCPUS                 Cap = 66 /* returns max vcpus per vm */
	CapPPCHIOR                  Cap = 67
	CapPPCPAPR                  Cap = 68
	CapSWTLB                    Cap = 69
	CapONEREG                   Cap = 70
	CapS390GMap                 Cap = 71
	CapTSCDeadlineTimer         Cap = 72
	CapS390UControl             Cap = 73
	CapSyncRegs                 Cap = 74
	CapPCI23                    Cap = 75
	CapKVMClockCtrl             Cap = 76
	CapSignalMSI                Cap = 77
	CapPPCGetSMMUInfo           Cap = 78
	CapS390COW                  Cap = 79
	CapPPCAllocHTAB             Cap = 80
	CapReadOnlyMEM              Cap = 81
	CapIRQFDResample            Cap = 82
	CapPPCBokkeWatchdog         Cap = 83
	CapPPCHTABFD                Cap = 84
	CapS390CSSSupport           Cap = 85
	CapPPCEPR                   Cap = 86
	CapARMPSCI                  Cap = 87
	CapARMSetDeviceAddr         Cap = 88
	CapDeviceCtrl               Cap = 89
	CapIRQMPIC                  Cap = 90
	CapPPCRTAS                  Cap = 91
	CapIRQXICS                  Cap = 92
	CapARMEL132BIT              Cap = 93
	CapSPAPRMultiTCE            Cap = 94
	CapEXTEmulCPUID             Cap = 95
	CapHyperVTIME               Cap = 96
	CapIOAPICPolarityIgnored    Cap = 97
	CapEnableCAPVM              Cap = 98
	CapS390IRQCHIP              Cap = 99
	CapIOEVENTFDNoLength        Cap = 100
	CapVMAttributes             Cap = 101
	CapARMPSCI02                Cap = 102
	CapPPCFixupHCALL            Cap = 103
	CapPPCEnableHCALL           Cap = 104
	CapCheckExtentionVM         Cap = 105
	CapS390UserSIGP             Cap = 106
	CapS390VectorRegisters      Cap = 107
	CapS390MemOp                Cap = 108
	CapS390UserSTSI             Cap = 109
	CapS390SKEYS                Cap = 110
	CapMIPSFPU                  Cap = 111
	CapMIPSMSA                  Cap = 112
	CapS390InjectIRQ            Cap = 113
	CapS390IRQState             Cap = 114
	CapPPCHWRNG                 Cap = 115
	CapDisableQuirks            Cap = 116
	CapX86SMM                   Cap = 117
	CapMultiAddressSpace        Cap = 118
	CapGuestDebugHWBPS          Cap = 119
	CapGuestDebugHWWPS          Cap = 120
	CapSplitIRQChip             Cap = 121
	CapIOEventFDAnyLength       Cap = 122
	CapHyperVSYNIC              Cap = 123
	CapS390RI                   Cap = 124
	CapSPAPRTCE64               Cap = 125
	CapARMPMUV3                 Cap = 126
	CapVCPUAttributes           Cap = 127
	CapMAXVCPUID                Cap = 128
	CapX2APICAPI                Cap = 129
	CapS390UserINSTR0           Cap = 130
	CapMSIDEVID                 Cap = 131
	CapPPCHTM                   Cap = 132
	CapSPAPRResizeHPT           Cap = 133
	CapPPCMMURADIX              Cap = 134
	CapPPCMMUHASHV3             Cap = 135
	CapImmediateExit            Cap = 136
	CapMIPSVZ                   Cap = 137
	CapMIPSTE                   Cap = 138
	CapMIPS64BIT                Cap = 139
	CapS390GS                   Cap = 140
	CapS390AIS                  Cap = 141
	CapSPAPRTCEVFIO             Cap = 142
	CapX86DisableExits          Cap = 143
	CapARMUserIRQ               Cap = 144
	CapS390CMMAMigration        Cap = 145
	CapPPCFWNMI                 Cap = 146
	CapPPCSMTPossible           Cap = 147
	CapHyperVSYNIC2             Cap = 148
	CapHyperVVPIndex            Cap = 149
	CapS390AISMigration         Cap = 150
	CapPPCGetCPUChar            Cap = 151
	CapS390BPB                  Cap = 152
	CapGETMSRFeatures           Cap = 153
	CapHyperVEventFD            Cap = 154
	CapHyperVTLBFlush           Cap = 155
	CapS390HPage1M              Cap = 156
	CapNestedState              Cap = 157
	CapARMInjectSErrorESR       Cap = 158
	CapMSRPlatformInfo          Cap = 159
	CapPPCNestedHV              Cap = 160
	CapHyperVSendIPI            Cap = 161
	CapCoalescedPIO             Cap = 162
	CapHyperVEnlightenedVMCS    Cap = 163
	CapExceptionPayload         Cap = 164
	CapARMVMIPASize             Cap = 165
	CapManualDirtyLogProtect    Cap = 166 /* Obsolete */
	CapHyerVCPUID               Cap = 167
	CapManualDirtyLogProtect2   Cap = 168
	CapPPCIRQXive               Cap = 169
	CapARMSVE                   Cap = 170
	CapARMPTRAuthAddress        Cap = 171
	CapARMPTRAuthGeneric        Cap = 172
	CapPMUEventFilter           Cap = 173
	CapARMIRQLineLayout2        Cap = 174
	CapHyperVDirectTLBFlush     Cap = 175
	CapPPCGuestDebugSStep       Cap = 176
	CapARMNISVToUser            Cap = 177
	CapARMInjectEXTDABT         Cap = 178
	CapS390VCPUResets           Cap = 179
	CapS390Protected            Cap = 180
	CapPPCSecureGuest           Cap = 181
	CapHALTPoll                 Cap = 182
	CapASYNCPFInt               Cap = 183
	CapLastCPU                  Cap = 184
	CapSmallerMaxPhyAddr        Cap = 185
	CapS390DIAG318              Cap = 186
	CapStealTime                Cap = 187
	CapX86UserSpaceMSR          Cap = 188
	CapX86MSRFilter             Cap = 189
	CapEnforcePVFeatureCPUID    Cap = 190
	CapSysHyperVCPUID           Cap = 191
	CapDirtyLogRing             Cap = 192
	CapX86BusLockExit           Cap = 193
	CapPPCDAWR1                 Cap = 194
	CapSetGuestDebug2           Cap = 195
	CapSGXAttribute             Cap = 196
	CapVMCopyEncContextFrom     Cap = 197
	CapPTPKVM                   Cap = 198
	CapHyperVEnforceCPUID       Cap = 199
	CapSREGS2                   Cap = 200
	CapEXitHyperCall            Cap = 201
	CapPPCRPTInvalidate         Cap = 202
	CapBinaryStatsFD            Cap = 203
	CapExitOnEmulationFailure   Cap = 204
	CapARMMTE                   Cap = 205
	CapVMMoveEncContextFrom     Cap = 206
	CapVMGPABits                Cap = 207
	CapXSave2                   Cap = 208
	CapSysAttributes            Cap = 209
	CapPPCAILMode3              Cap = 210
	CapS390MemOpExtention       Cap = 211
	CapPMUCap                   Cap = 212
	CapDisableQuirks2           Cap = 213
	CapVMTSCControl             Cap = 214
	CapSystemEventData          Cap = 215
	CapARMSystemSuspend         Cap = 216
	CapS390ProtectedDump        Cap = 217
	CapX86TripleFaultEvent      Cap = 218
	CapX86NotifyVMExit          Cap = 219
	CapVMDisableNXHugePages     Cap = 220
	CapS390ZPCIOP               Cap = 221
	CapS390CPUTOPOLOGY          Cap = 222
	CapDirtyLogRingACQRel       Cap = 223
)

func (Cap) String

func (i Cap) String() string

type ClockData

type ClockData struct {
	Clock uint64
	Flags uint32

	Realtime uint64
	HostTSC  uint64
	// contains filtered or unexported fields
}

type ClockFlag

type ClockFlag uint32
const (
	TSCStable ClockFlag = 2
	Realtime  ClockFlag = (1 << 2)
	HostTSC   ClockFlag = (1 << 3)
)

type DebugRegs

type DebugRegs struct {
	DB    [4]uint64
	DR6   uint64
	DR7   uint64
	Flags uint64
	// contains filtered or unexported fields
}

type Descriptor

type Descriptor struct {
	Base  uint64
	Limit uint16
	// contains filtered or unexported fields
}

type Dev

type Dev struct {
	Type  uint32
	Fd    uint32
	Flags uint32
}

type DevType

type DevType uint32
const (
	DevFSLMPIC20 DevType = 1 + iota
	DevFSLMPIC42
	DevXICS
	DevVFIO

	DevFLIC

	DevXIVE

	DevMAX
)

type Device

type Device interface {
	PortIO
	IOPort() uint64
	Size() uint64
}

type DeviceHeader

type DeviceHeader struct {
	VendorID uint16
	DeviceID uint16
	Command  uint16

	HeaderType uint8

	BAR [6]uint32

	SubsystemID uint16

	InterruptLine uint8
	InterruptPin  uint8
	// contains filtered or unexported fields
}

func (DeviceHeader) Bytes

func (h DeviceHeader) Bytes() ([]byte, error)

type DeviceNoop

type DeviceNoop struct {
	Port  uint64
	Psize uint64
}

func (*DeviceNoop) IOPort

func (r *DeviceNoop) IOPort() uint64

func (*DeviceNoop) In

func (r *DeviceNoop) In(port uint64, data []byte) error

func (*DeviceNoop) Out

func (r *DeviceNoop) Out(port uint64, data []byte) error

func (*DeviceNoop) Size

func (r *DeviceNoop) Size() uint64

type DirtyLog

type DirtyLog struct {
	Slot uint32

	BitMap uint64
	// contains filtered or unexported fields
}

type E820Entry

type E820Entry struct {
	Addr uint64
	Size uint64
	Type uint32
}

type EBDA

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

func NewEBDA

func NewEBDA(nCPUs int) (*EBDA, error)

func (*EBDA) Bytes

func (e *EBDA) Bytes() ([]byte, error)

type Exception

type Exception struct {
	Inject       uint8
	Nr           uint8
	HadErrorCode uint8
	Pending      uint8
	ErrorCode    uint32
}

type Exit

type Exit uint
const (
	EXITUNKNOWN       Exit = 0
	EXITEXCEPTION     Exit = 1
	EXITIO            Exit = 2
	EXITHYPERCALL     Exit = 3
	EXITDEBUG         Exit = 4
	EXITHLT           Exit = 5
	EXITMMIO          Exit = 6
	EXITIRQWINDOWOPEN Exit = 7
	EXITSHUTDOWN      Exit = 8
	EXITFAILENTRY     Exit = 9
	EXITINTR          Exit = 10
	EXITSETTPR        Exit = 11
	EXITTPRACCESS     Exit = 12
	EXITS390SIEIC     Exit = 13
	EXITS390RESET     Exit = 14
	EXITDCR           Exit = 15
	EXITNMI           Exit = 16
	EXITINTERNALERROR Exit = 17

	EXITIOIN  = 0
	EXITIOOUT = 1
)

func (Exit) String

func (i Exit) String() string

type FWDebug

type FWDebug struct{}

func (*FWDebug) IOPort

func (f *FWDebug) IOPort() uint64

func (*FWDebug) In

func (f *FWDebug) In(port uint64, data []byte) error

func (*FWDebug) Out

func (f *FWDebug) Out(port uint64, data []byte) error

func (*FWDebug) Size

func (f *FWDebug) Size() uint64

type GDT

type GDT [4]uint64

func CreateGDT

func CreateGDT() GDT

func (GDT) Bytes

func (gdt GDT) Bytes() []byte

type HVMMemMapTableEntry

type HVMMemMapTableEntry struct {
	Addr uint64
	Size uint64
	Type uint32
	// contains filtered or unexported fields
}

func NewMemMapTableEntry

func NewMemMapTableEntry(addr, size uint64, t uint32) *HVMMemMapTableEntry

func (*HVMMemMapTableEntry) Bytes

func (h *HVMMemMapTableEntry) Bytes() ([]byte, error)

type HVMModListEntry

type HVMModListEntry struct {
	Addr        uint64
	Size        uint64
	CmdLineAddr uint64
	// contains filtered or unexported fields
}

func NewModListEntry

func NewModListEntry(addr, size, cmdaddr uint64) *HVMModListEntry

func (*HVMModListEntry) Bytes

func (h *HVMModListEntry) Bytes() ([]byte, error)

type HVMStartInfo

type HVMStartInfo struct {
	Magic         uint32
	Version       uint32
	Flags         uint32
	NrModules     uint32
	ModlistPAddr  uint64
	CmdLinePAddr  uint64
	RSDPPAddr     uint64
	MemMapPAddr   uint64
	MemMapEntries uint32
	// contains filtered or unexported fields
}

func NewStartInfo

func NewStartInfo(rsdpPAddr, cmdLinePAddr uint64) *HVMStartInfo

func (*HVMStartInfo) Bytes

func (h *HVMStartInfo) Bytes() ([]byte, error)

type IOFunc

type IOFunc func(port uint64, bytes []byte) error

type IRQChip

type IRQChip struct {
	ChipID uint32

	Chip [512]byte
	// contains filtered or unexported fields
}

type IRQInjector

type IRQInjector interface {
	VirtualIONetIRQ() error
	VirtualIOBlkIRQ() error
}

type IRQRouting

type IRQRouting struct {
	Nr      uint32
	Flags   uint32
	Entries []IRQRoutingEntry
}

func NewIRQRouting

func NewIRQRouting(data []byte) (*IRQRouting, error)

func (*IRQRouting) Bytes

func (r *IRQRouting) Bytes() ([]byte, error)

type IRQRoutingEntry

type IRQRoutingEntry struct {
	GSI   uint32
	Type  uint32
	Flags uint32

	IRQRoutingIRQChip
	// contains filtered or unexported fields
}

type IRQRoutingIRQChip

type IRQRoutingIRQChip struct {
	IRQChip uint32
	Pin     uint32
}

type If

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

func NewIf

func NewIf(name string, flag uint16) (*If, error)

func (*If) Close

func (t *If) Close() error

func (*If) Read

func (t *If) Read(buf []byte) (n int, err error)

func (*If) Write

func (t *If) Write(buf []byte) (n int, err error)

type Interrupt

type Interrupt struct {
	Inject uint8
	Nr     uint8
	Soft   uint8
	Shadow uint8
}

type KVM

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

func NewKVM

func NewKVM(cpus int) (*KVM, error)

func (*KVM) CPUToFD

func (k *KVM) CPUToFD(cpu int) (P, error)

func (*KVM) GetExitReasonByCpu

func (k *KVM) GetExitReasonByCpu(cpu int) Exit

func (*KVM) GetIOByCpu

func (k *KVM) GetIOByCpu(cpu int) (uint64, uint64, uint64, uint64, uint64)

func (*KVM) GetVmFd

func (k *KVM) GetVmFd() P

func (*KVM) Init

func (k *KVM) Init(m *PhysMemory) error

func (*KVM) RunData

func (k *KVM) RunData() []*RunData

func (*KVM) RunDataByCpu

func (k *KVM) RunDataByCpu(cpu int) *RunData

func (*KVM) SingleStep

func (k *KVM) SingleStep(cpu int, onOff bool) error

func (*KVM) Translate

func (k *KVM) Translate(vaddr uint64) ([]*Translation, error)

type KernParam

type KernParam struct {
	Padding             [0x1e8]uint8
	E820Entries         uint8
	EddbufEntries       uint8
	EddMbrSigBufEntries uint8
	KdbStatus           uint8
	Padding2            [5]uint8
	Hdr                 SetupHeader
	Padding3            [0x290 - 0x1f1 - unsafe.Sizeof(SetupHeader{})]uint8
	Padding4            [0x3d]uint8
	EddMbrSigBuffer     [EddMbrSigMax]uint8
	E820Map             [E820Max]E820Entry
}

func NewKernParam

func NewKernParam(r io.ReaderAt) (*KernParam, error)

func (*KernParam) AddE820Entry

func (k *KernParam) AddE820Entry(addr, size uint64, typ uint32)

func (*KernParam) Bytes

func (k *KernParam) Bytes() ([]byte, error)

type LAPICState

type LAPICState struct {
	Regs [LAPICRegSize]byte
}

type MPState

type MPState struct {
	State uint32
}

type MSR

type MSR uint32
const (
	MSRIA32TSC            MSR = 0x10
	MSRIA32APICBASE       MSR = 0x1b
	MSRIA32FEATURECONTROL MSR = 0x0000003a
	MSRTSCADJUST          MSR = 0x0000003b
	MSRIA32SPECCTRL       MSR = 0x48
	MSRVIRTSSBD           MSR = 0xc001011f
	MSRIA32PREDCMD        MSR = 0x49
	MSRIA32UCODEREV       MSR = 0x8b
	MSRIA32CORECAPABILITY MSR = 0xcf

	MSRIA32ARCHCAPABILITIES MSR = 0x10a
	MSRIA32PERFCAPABILITIES MSR = 0x345
	MSRIA32TSXCTRL          MSR = 0x122
	MSRIA32TSCDEADLINE      MSR = 0x6e0
	MSRIA32PKRS             MSR = 0x6e1
	MSRARCHLBRCTL           MSR = 0x000014ce
	MSRARCHLBRDEPTH         MSR = 0x000014cf
	MSRARCHLBRFROM0         MSR = 0x00001500
	MSRARCHLBRTO0           MSR = 0x00001600
	MSRARCHLBRINFO0         MSR = 0x00001200
	MSRIA32SGXLEPUBKEYHASH0 MSR = 0x8c
	MSRIA32SGXLEPUBKEYHASH1 MSR = 0x8d
	MSRIA32SGXLEPUBKEYHASH2 MSR = 0x8e
	MSRIA32SGXLEPUBKEYHASH3 MSR = 0x8f

	MSRP6PERFCTR0 MSR = 0xc1

	MSRIA32SMBASE      MSR = 0x9e
	MSRSMICOUNT        MSR = 0x34
	MSRCORETHREADCOUNT MSR = 0x35
	MSRMTRRcap         MSR = 0xfe
	MSRIA32SYSENTERCS  MSR = 0x174
	MSRIA32SYSENTERESP MSR = 0x175
	MSRIA32SYSENTEREIP MSR = 0x176

	MSRMCGCAP    MSR = 0x179
	MSRMCGSTATUS MSR = 0x17a
	MSRMCGCTL    MSR = 0x17b
	MSRMCGEXTCTL MSR = 0x4d0

	MSRP6EVNTSEL0 MSR = 0x186

	MSRIA32PERFSTATUS MSR = 0x198

	MSRIA32MISCENABLE  MSR = 0x1a0
	MSRMTRRfix64K00000 MSR = 0x250
	MSRMTRRfix16K80000 MSR = 0x258
	MSRMTRRfix16KA0000 MSR = 0x259
	MSRMTRRfix4KC0000  MSR = 0x268
	MSRMTRRfix4KC8000  MSR = 0x269
	MSRMTRRfix4KD0000  MSR = 0x26a
	MSRMTRRfix4KD8000  MSR = 0x26b
	MSRMTRRfix4KE0000  MSR = 0x26c
	MSRMTRRfix4KE8000  MSR = 0x26d
	MSRMTRRfix4KF0000  MSR = 0x26e
	MSRMTRRfix4KF8000  MSR = 0x26f

	MSRPAT MSR = 0x277

	MSRMTRRdefType MSR = 0x2ff

	MSRCOREPERFFIXEDCTR0     MSR = 0x309
	MSRCOREPERFFIXEDCTR1     MSR = 0x30a
	MSRCOREPERFFIXEDCTR2     MSR = 0x30b
	MSRCOREPERFFIXEDCTRCTRL  MSR = 0x38d
	MSRCOREPERFGLOBALSTATUS  MSR = 0x38e
	MSRCOREPERFGLOBALCTRL    MSR = 0x38f
	MSRCOREPERFGLOBALOVFCTRL MSR = 0x390

	MSRMC0CTL    MSR = 0x400
	MSRMC0STATUS MSR = 0x401
	MSRMC0ADDR   MSR = 0x402
	MSRMC0MISC   MSR = 0x403

	MSRIA32RTITOUTPUTBASE MSR = 0x560
	MSRIA32RTITOUTPUTMASK MSR = 0x561
	MSRIA32RTITCTL        MSR = 0x570
	MSRIA32RTITSTATUS     MSR = 0x571
	MSRIA32RTITCR3MATCH   MSR = 0x572
	MSRIA32RTITADDR0A     MSR = 0x580
	MSRIA32RTITADDR0B     MSR = 0x581
	MSRIA32RTITADDR1A     MSR = 0x582
	MSRIA32RTITADDR1B     MSR = 0x583
	MSRIA32RTITADDR2A     MSR = 0x584
	MSRIA32RTITADDR2B     MSR = 0x585
	MSRIA32RTITADDR3A     MSR = 0x586
	MSRIA32RTITADDR3B     MSR = 0x587
	MSRSTAR               MSR = 0xc0000081
	MSRLSTAR              MSR = 0xc0000082
	MSRCSTAR              MSR = 0xc0000083
	MSRFMASK              MSR = 0xc0000084
	MSRFSBASE             MSR = 0xc0000100
	MSRGSBASE             MSR = 0xc0000101
	MSRKERNELGSBASE       MSR = 0xc0000102
	MSRTSCAUX             MSR = 0xc0000103
	MSRAMD64TSCRATIO      MSR = 0xc0000104

	MSRVMHSAVEPA MSR = 0xc0010117

	MSRIA32XFD    MSR = 0x000001c4
	MSRIA32XFDERR MSR = 0x000001c5

	MSRIA32BNDCFGS       MSR = 0x00000d90
	MSRIA32XSS           MSR = 0x00000da0
	MSRIA32UMWAITCONTROL MSR = 0xe1

	MSRIA32VMXBASIC             MSR = 0x00000480
	MSRIA32VMXPINBASEDCTLS      MSR = 0x00000481
	MSRIA32VMXPROCBASEDCTLS     MSR = 0x00000482
	MSRIA32VMXEXITCTLS          MSR = 0x00000483
	MSRIA32VMXENTRYCTLS         MSR = 0x00000484
	MSRIA32VMXMISC              MSR = 0x00000485
	MSRIA32VMXCR0FIXED0         MSR = 0x00000486
	MSRIA32VMXCR0FIXED1         MSR = 0x00000487
	MSRIA32VMXCR4FIXED0         MSR = 0x00000488
	MSRIA32VMXCR4FIXED1         MSR = 0x00000489
	MSRIA32VMXVMCSENUM          MSR = 0x0000048a
	MSRIA32VMXPROCBASEDCTLS2    MSR = 0x0000048b
	MSRIA32VMXEPTVPIDCAP        MSR = 0x0000048c
	MSRIA32VMXTRUEPINBASEDCTLS  MSR = 0x0000048d
	MSRIA32VMXTRUEPROCBASEDCTLS MSR = 0x0000048e
	MSRIA32VMXTRUEEXITCTLS      MSR = 0x0000048f
	MSRIA32VMXTRUEENTRYCTLS     MSR = 0x00000490
	MSRIA32VMXVMFUNC            MSR = 0x00000491
)

type MSREntry

type MSREntry struct {
	Index   uint32
	Padding uint32
	Data    uint64
}

type MSRList

type MSRList struct {
	NMSRs    uint32
	Indicies [1000]uint32
}

type MSRS

type MSRS struct {
	NMSRs   uint32
	Padding uint32
	Entries []MSREntry
}

func NewMSRS

func NewMSRS(data []byte) (*MSRS, error)

func (*MSRS) Bytes

func (m *MSRS) Bytes() ([]byte, error)

type Machine

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

func New

func New(cpus int, memSize int) (*Machine, error)

func (*Machine) AddDevice

func (m *Machine) AddDevice(dev Device)

func (*Machine) AddDisk

func (m *Machine) AddDisk(diskPath string) error

func (*Machine) AddIf

func (m *Machine) AddIf(ifName, net string) error

func (*Machine) Args

func (m *Machine) Args(cpu int, r *Regs, nargs int) ([]P, error)

func (*Machine) GetInputChan

func (m *Machine) GetInputChan() chan<- byte

func (*Machine) GetRegs

func (m *Machine) GetRegs(cpu int) (*Regs, error)

func (*Machine) GetSRegs

func (m *Machine) GetSRegs(cpu int) (*Sregs, error)

func (*Machine) GetSerial

func (m *Machine) GetSerial() *Serial

func (*Machine) Halt

func (m *Machine) Halt()

func (*Machine) InjectSerialIRQ

func (m *Machine) InjectSerialIRQ() error

func (*Machine) Inst

func (m *Machine) Inst(cpu int) (*x86asm.Inst, *Regs, string, error)

func (*Machine) LoadLinux

func (m *Machine) LoadLinux(kernel, initrd io.ReaderAt, params string) error

func (*Machine) LoadPVH

func (m *Machine) LoadPVH(kern, initrd *os.File, cmdline string) error

func (*Machine) Pointer

func (m *Machine) Pointer(inst *x86asm.Inst, r *Regs, arg uint) (P, error)

func (*Machine) Pop

func (m *Machine) Pop(cpu int, r *Regs) (uint64, error)

func (*Machine) ReadBytes

func (m *Machine) ReadBytes(cpu int, b []byte, vaddr uint64) (int, error)

func (*Machine) ReadWord

func (m *Machine) ReadWord(cpu int, vaddr uint64) (uint64, error)

func (*Machine) RunInfiniteLoop

func (m *Machine) RunInfiniteLoop(cpu int) error

func (*Machine) RunOnce

func (m *Machine) RunOnce(cpu int) (bool, error)

func (*Machine) SetRegs

func (m *Machine) SetRegs(cpu int, r *Regs) error

func (*Machine) SetSRegs

func (m *Machine) SetSRegs(cpu int, s *Sregs) error

func (*Machine) SetupRegs

func (m *Machine) SetupRegs(rip, bp uint64, amd64 bool) error

func (*Machine) SingleStep

func (m *Machine) SingleStep(onOff bool) error

func (*Machine) VCPU

func (m *Machine) VCPU(cpu, traceCount int) error

func (*Machine) VirtualIOBlkIRQ

func (m *Machine) VirtualIOBlkIRQ() error

func (*Machine) VirtualIONetIRQ

func (m *Machine) VirtualIONetIRQ() error

func (*Machine) VtoP

func (m *Machine) VtoP(cpu int, vaddr uint64) (int64, error)

func (*Machine) WriteWord

func (m *Machine) WriteWord(cpu int, vaddr uint64, word uint64) error

type NMI

type NMI struct {
	Inject  uint8
	Pending uint8
	Masked  uint8
	// contains filtered or unexported fields
}

type Net

type Net struct {
	Hdr          netHdr
	Queues       [2]*VirtualQueue
	PhyMem       *PhysMemory
	LastAvailIdx [2]uint16
	If           io.ReadWriter

	IRQInjector IRQInjector
	// contains filtered or unexported fields
}

func NewNet

func NewNet(irq uint8, irqInjector IRQInjector, ioIf io.ReadWriter, m *PhysMemory) *Net

func (*Net) GetDeviceHeader

func (v *Net) GetDeviceHeader() DeviceHeader

func (*Net) IOPort

func (v *Net) IOPort() uint64

func (*Net) In

func (v *Net) In(port uint64, bytes []byte) error

func (*Net) Out

func (v *Net) Out(port uint64, bytes []byte) error

func (*Net) Rx

func (v *Net) Rx() error

func (*Net) RxThreadEntry

func (v *Net) RxThreadEntry()

func (*Net) Size

func (v *Net) Size() uint64

func (*Net) Tx

func (v *Net) Tx() error

func (*Net) TxThreadEntry

func (v *Net) TxThreadEntry()

type P

type P uintptr

func CheckExtension

func CheckExtension(kvmFd P, c Cap) (P, error)

func CreateVCPU

func CreateVCPU(vmFd P, vCpuID int) (P, error)

func CreateVM

func CreateVM(kvmFd P) (P, error)

func GetAPIVersion

func GetAPIVersion(kvmFd P) (P, error)

func GetVCPUMMmapSize

func GetVCPUMMmapSize(kvmFd P) (P, error)

func IIO

func IIO(nr P) P

func IIOC

func IIOC(dir, nr, size P) P

func IIOR

func IIOR(nr, size P) P

func IIOW

func IIOW(nr, size P) P

func IIOWR

func IIOWR(nr, size P) P

func Ioctl

func Ioctl(fd, op, arg P) (P, error)

type PCI

type PCI struct {
	Devices []PCIDevice
	// contains filtered or unexported fields
}

func NewPCI

func NewPCI(devices ...PCIDevice) *PCI

func (*PCI) In

func (p *PCI) In(port uint64, values []byte) error

func (*PCI) Out

func (p *PCI) Out(port uint64, values []byte) error

func (*PCI) PciConfDataIn

func (p *PCI) PciConfDataIn(port uint64, values []byte) error

func (*PCI) PciConfDataOut

func (p *PCI) PciConfDataOut(port uint64, values []byte) error

type PCIConf

type PCIConf struct {
	*PCI
}

func (*PCIConf) In

func (c *PCIConf) In(port uint64, values []byte) error

func (*PCIConf) Out

func (c *PCIConf) Out(port uint64, values []byte) error

type PCIDevice

type PCIDevice interface {
	PortIO
	GetDeviceHeader() DeviceHeader
	IOPort() uint64
	Size() uint64
}

func NewBridge

func NewBridge() PCIDevice

type PICState

type PICState struct {
	LastIRR                uint8
	IRR                    uint8
	IMR                    uint8
	ISR                    uint8
	PriorityAdd            uint8
	IRQBase                uint8
	ReadRegSelect          uint8
	Poll                   uint8
	SpecialMask            uint8
	InitState              uint8
	AutoEOI                uint8
	RotateOnAutoEOI        uint8
	SpecialFullyNestedMode uint8
	Init4                  uint8
	ELCR                   uint8
	ELCRMask               uint8
}

type PITChannelState

type PITChannelState struct {
	Count         uint32
	LatchedCount  uint16
	CountLatched  uint8
	StatusLatched uint8
	Status        uint8
	ReadState     uint8
	WriteState    uint8
	WriteLatch    uint8
	RWMode        uint8
	Mode          uint8
	BCD           uint8
	Gate          uint8
	CountLoadTime int64
}

type PITState2

type PITState2 struct {
	Channels [3]PITChannelState
	Flags    uint32
	// contains filtered or unexported fields
}

type PhysMemory

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

func NewPhysMemory

func NewPhysMemory(size int) *PhysMemory

func (*PhysMemory) CopyStart

func (p *PhysMemory) CopyStart(start uint64, data []byte)

func (*PhysMemory) Free

func (p *PhysMemory) Free()

func (*PhysMemory) Get

func (p *PhysMemory) Get(start, end uint64) []byte

func (*PhysMemory) GetFromStart

func (p *PhysMemory) GetFromStart(pos uint64) []byte

func (*PhysMemory) GetRamPtr

func (p *PhysMemory) GetRamPtr(addr uint32) Ptr

func (*PhysMemory) Len

func (p *PhysMemory) Len() uint64

func (*PhysMemory) ReadAt

func (p *PhysMemory) ReadAt(b []byte, off int64) (int, error)

func (*PhysMemory) SetZero

func (p *PhysMemory) SetZero(pos int)

func (*PhysMemory) WriteAt

func (p *PhysMemory) WriteAt(b []byte, off int64) (int, error)

type PortIO

type PortIO interface {
	In(uint64, []byte) error
	Out(uint64, []byte) error
}

type PortIONoop

type PortIONoop struct {
}

func (*PortIONoop) In

func (r *PortIONoop) In(port uint64, data []byte) error

func (*PortIONoop) Out

func (r *PortIONoop) Out(port uint64, data []byte) error

type PostCode

type PostCode struct{}

func (*PostCode) IOPort

func (p *PostCode) IOPort() uint64

func (*PostCode) In

func (p *PostCode) In(port uint64, data []byte) error

func (*PostCode) Out

func (p *PostCode) Out(port uint64, data []byte) error

func (*PostCode) Size

func (p *PostCode) Size() uint64

type Ptr

type Ptr unsafe.Pointer

type Regs

type Regs struct {
	RAX    uint64
	RBX    uint64
	RCX    uint64
	RDX    uint64
	RSI    uint64
	RDI    uint64
	RSP    uint64
	RBP    uint64
	R8     uint64
	R9     uint64
	R10    uint64
	R11    uint64
	R12    uint64
	R13    uint64
	R14    uint64
	R15    uint64
	RIP    uint64
	RFLAGS uint64
}

func GetRegs

func GetRegs(vCpuFd P) (*Regs, error)

type RunData

type RunData struct {
	RequestInterruptWindow uint8
	ImmediateExit          uint8

	ExitReason                 uint32
	ReadyForInterruptInjection uint8
	IfFlag                     uint8

	CR8      uint64
	ApicBase uint64
	Data     [32]uint64
	// contains filtered or unexported fields
}

func (*RunData) IO

func (r *RunData) IO() (uint64, uint64, uint64, uint64, uint64)

type SMI

type SMI struct {
	SMM          uint8
	Pening       uint8
	SMMInsideNMI uint8
	LatchedInit  uint8
}

type SRegs2

type SRegs2 struct {
	CS       Segment
	DS       Segment
	ES       Segment
	FS       Segment
	GS       Segment
	SS       Segment
	TR       Segment
	LDT      Segment
	GDT      Descriptor
	IDT      Descriptor
	CR0      uint64
	CR2      uint64
	CR3      uint64
	CR4      uint64
	CR8      uint64
	EFER     uint64
	APICBase uint64
	Flags    uint64
	PDptrs   [4]uint64
}

type Segment

type Segment struct {
	Base     uint64
	Limit    uint32
	Selector uint16
	Typ      uint8
	Present  uint8
	DPL      uint8
	DB       uint8
	S        uint8
	L        uint8
	G        uint8
	AVL      uint8
	Unusable uint8
	// contains filtered or unexported fields
}

func SegmentFromGDT

func SegmentFromGDT(entry uint64, tableIndex uint8) Segment

type Serial

type Serial struct {
	IER byte
	LCR byte
	// contains filtered or unexported fields
}

func NewSerial

func NewSerial(irqInjector SerialIRQInjector) (*Serial, error)

func (*Serial) GetInputChan

func (s *Serial) GetInputChan() chan<- byte

func (*Serial) In

func (s *Serial) In(port uint64, values []byte) error

func (*Serial) Out

func (s *Serial) Out(port uint64, values []byte) error

func (*Serial) Start

func (s *Serial) Start(in bufio.Reader, restoreMode func(), irqInject func() error) error

type SerialIRQInjector

type SerialIRQInjector interface {
	InjectSerialIRQ() error
}

type SetupHeader

type SetupHeader struct {
	SetupSects          uint8
	RootFlags           uint16
	SysSize             uint32
	RAMSize             uint16
	VidMode             uint16
	RootDev             uint16
	BootFlag            uint16
	Jump                uint16
	Header              uint32
	Version             uint16
	ReadModeSwitch      uint32
	StartSysSeg         uint16
	KernelVersion       uint16
	TypeOfLoader        uint8
	LoadFlags           uint8
	SetupMoveSize       uint16
	Code32Start         uint32
	RamdiskImage        uint32
	RamdiskSize         uint32
	BootsectKludge      uint32
	HeapEndPtr          uint16
	ExtLoaderVer        uint8
	ExtLoaderType       uint8
	CmdlinePtr          uint32
	InitrdAddrMax       uint32
	KernelAlignment     uint32
	RelocatableKernel   uint8
	MinAlignment        uint8
	XloadFlags          uint16
	CmdlineSize         uint32
	HardwareSubarch     uint32
	HardwareSubarchData uint64
	PayloadOffset       uint32
	PayloadLength       uint32
	SetupData           uint64
	PrefAddress         uint64
	InitSize            uint32
	HandoverOffset      uint32
	KernelInfoOffset    uint32
}

type Sregs

type Sregs struct {
	CS              Segment
	DS              Segment
	ES              Segment
	FS              Segment
	GS              Segment
	SS              Segment
	TR              Segment
	LDT             Segment
	GDT             Descriptor
	IDT             Descriptor
	CR0             uint64
	CR2             uint64
	CR3             uint64
	CR4             uint64
	CR8             uint64
	EFER            uint64
	ApicBase        uint64
	InterruptBitmap [(numInterrupts + 63) / 64]uint64
}

func GetSregs

func GetSregs(vCpuFd P) (*Sregs, error)

type TRPAccessCtl

type TRPAccessCtl struct {
	Enable uint32
	Flags  uint32
	// contains filtered or unexported fields
}

type Translation

type Translation struct {
	LinearAddress   uint64
	PhysicalAddress uint64
	Valid           uint8
	Writeable       uint8
	Usermode        uint8
	// contains filtered or unexported fields
}

type UserspaceMemoryRegion

type UserspaceMemoryRegion struct {
	Slot          uint32
	Flags         uint32
	GuestPhysAddr uint64
	MemorySize    uint64
	UserspaceAddr uint64
}

func (*UserspaceMemoryRegion) SetMemLogDirtyPages

func (r *UserspaceMemoryRegion) SetMemLogDirtyPages()

func (*UserspaceMemoryRegion) SetMemReadonly

func (r *UserspaceMemoryRegion) SetMemReadonly()

type VCPUEvents

type VCPUEvents struct {
	E           Exception
	I           Interrupt
	N           NMI
	SipiVector  uint32
	Flags       uint32
	S           SMI
	TripleFault uint8

	ExceptionHasPayload uint8
	ExceptionPayload    uint64
	// contains filtered or unexported fields
}

type VirtualQueue

type VirtualQueue struct {
	DescTable [QueueSize]struct {
		Addr  uint64
		Len   uint32
		Flags uint16
		Next  uint16
	}

	AvailRing struct {
		Flags     uint16
		Idx       uint16
		Ring      [QueueSize]uint16
		UsedEvent uint16
	}

	UsedRing struct {
		Flags uint16
		Idx   uint16
		Ring  [QueueSize]struct {
			Idx uint32
			Len uint32
		}
		// contains filtered or unexported fields
	}
	// contains filtered or unexported fields
}

type X86MCE

type X86MCE struct {
	Status    uint64
	Addr      uint64
	Misc      uint64
	MCGStatus uint64
	Bank      uint8
	// contains filtered or unexported fields
}

type XCRS

type XCRS struct {
	NrXRCS    uint32
	Flags     uint32
	Registers [16]XRC
	// contains filtered or unexported fields
}

type XRC

type XRC struct {
	XRC uint32

	Value uint64
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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