platform

package
v0.0.0-...-278237d Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2015 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

+build linux

+build linux

+build linux

+build linux

+build linux

+build linux

+build linux

+build linux

+build linux

+build linux i386 amd64

+build i386 amd64

Index

Constants

View Source
const (
	PageSize = 4096
)

x86 platform constants.

Variables

View Source
var AlreadyPaused = errors.New("Vcpu is already paused.")
View Source
var IrqChipIncompatible = errors.New("Incompatible IRQ chip state?")
View Source
var LApicIncompatible = errors.New("Incompatible LApic state?")
View Source
var MpStateHalted = MpState(C.MpStateHalted)
View Source
var MpStateInitReceived = MpState(C.MpStateInitReceived)
View Source
var MpStateRunnable = MpState(C.MpStateRunnable)
View Source
var MpStateSipiReceived = MpState(C.MpStateSipiReceived)
View Source
var MpStateUninitialized = MpState(C.MpStateUninitialized)
View Source
var NotPaused = errors.New("Vcpu is not paused?")

Vcpu state errors.

View Source
var PitIncompatible = errors.New("Incompatible PIT state?")
View Source
var UnknownRegister = errors.New("Unknown Register")

Register errors.

View Source
var UnknownState = errors.New("Unknown vcpu state?")
View Source
var VcpuIncompatible = errors.New("Incompatible VCPU data?")

Serialization.

Functions

func Align

func Align(addr uint64, alignment uint, up bool) uint64

func AlignBytes

func AlignBytes(data []byte) []byte

Types

type BoundEventFd

type BoundEventFd struct {

	// Our system eventfd.
	*EventFd

	// Our VM reference.
	*Vm
	// contains filtered or unexported fields
}

func (*BoundEventFd) Close

func (fd *BoundEventFd) Close() error

type Clock

type Clock struct {
	Time  uint64 `json:"time"`
	Flags uint32 `json:"flags"`
}

Our clock state.

type ControlRegister

type ControlRegister int

Special control registers.

const (
	CR0 ControlRegister = iota
	CR2
	CR3
	CR4
	CR8
	EFER
	APIC_BASE
)

type ControlRegisterValue

type ControlRegisterValue uint64

type Cpuid

type Cpuid struct {
	Function uint32 `json:"function"`
	Index    uint32 `json:"index"`
	Flags    uint32 `json:"flags"`

	EAX uint32
	EBX uint32
	ECX uint32
	EDX uint32
}

type Descriptor

type Descriptor int

Segment descriptor registers.

const (
	GDT Descriptor = iota
	IDT
)

type DescriptorValue

type DescriptorValue struct {
	Base  uint64 `json:"base"`
	Limit uint16 `json:"limit"`
}

type EventFd

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

func NewEventFd

func NewEventFd() (*EventFd, error)

func (*EventFd) Close

func (fd *EventFd) Close() error

func (*EventFd) Fd

func (fd *EventFd) Fd() int

func (*EventFd) Signal

func (fd *EventFd) Signal(val uint64) error

func (*EventFd) Wait

func (fd *EventFd) Wait() (uint64, error)

type Events

type Events struct {
	Exception *ExceptionEvent `json:"exception"`
	Interrupt *InterruptEvent `json:"interrupt"`

	NmiPending bool `json:"nmi-pending"`
	NmiMasked  bool `json:"nmi-masked"`

	SipiVector uint32 `json:"sipi-vector"`
	Flags      uint32 `json:"flags"`
}

type ExceptionEvent

type ExceptionEvent struct {
	Number    uint8   `json:"number"`
	ErrorCode *uint32 `json:"error-code"`
}

Our event state.

type ExitDebug

type ExitDebug struct {
}

func (*ExitDebug) Error

func (exit *ExitDebug) Error() string

type ExitException

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

func (*ExitException) Error

func (exit *ExitException) Error() string

type ExitInternalError

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

func (*ExitInternalError) Error

func (exit *ExitInternalError) Error() string

type ExitMmio

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

func (*ExitMmio) Addr

func (exitmmio *ExitMmio) Addr() Paddr

func (*ExitMmio) Data

func (exitmmio *ExitMmio) Data() *uint64

func (*ExitMmio) Error

func (exit *ExitMmio) Error() string

func (*ExitMmio) IsWrite

func (exitmmio *ExitMmio) IsWrite() bool

func (*ExitMmio) Length

func (exitmmio *ExitMmio) Length() uint

type ExitPio

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

func (*ExitPio) Data

func (exitio *ExitPio) Data() *uint64

func (*ExitPio) Error

func (exit *ExitPio) Error() string

func (*ExitPio) IsOut

func (exitio *ExitPio) IsOut() bool

func (*ExitPio) Port

func (exitio *ExitPio) Port() Paddr

func (*ExitPio) Size

func (exitio *ExitPio) Size() uint

type ExitShutdown

type ExitShutdown struct {
}

func (*ExitShutdown) Error

func (exit *ExitShutdown) Error() string

type ExitUnknown

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

Exit events. When running the vcpu (i.e. vcpu.Run()), you should check the return value to see if it matches these types. They should be handled appropriate and Run() can be called again to resume.

func (*ExitUnknown) Error

func (exit *ExitUnknown) Error() string

type Fpu

type Fpu struct {
	FPR  [8][16]uint8
	FCW  uint16
	FSW  uint16
	FTWX uint8

	LastOpcode uint16 `json:"last-opcode"`
	LastIp     uint64 `json:"last-ip"`
	LastDp     uint64 `json:"last-dp"`

	XMM   [16][16]uint8
	MXCSR uint32
}

Our FPU state.

type InterruptEvent

type InterruptEvent struct {
	Number uint8 `json:"number"`
	Soft   bool  `json:"soft"`
	Shadow bool  `json:"shadow"`
}

type Irq

type Irq uint32

Basic abstractions.

type IrqChip

type IrqChip struct {
	Pic1   []byte `json:"pic1"`
	Pic2   []byte `json:"pic2"`
	IOApic []byte `json:"ioapic"`
}

IrqChip --

The IrqChip state requires three different devices: pic1, pic2 and the I/O apic. Each of these devices can be represented with a simple blob of data (compatibility will be the responsibility of KVM internally).

type LApicState

type LApicState struct {
	Data []byte `json:"data"`
}

LApicState --

Just a blob of data. KVM will be ensure forward-compatibility.

type MpState

type MpState C.int

Our vcpus state.

func (*MpState) MarshalJSON

func (state *MpState) MarshalJSON() ([]byte, error)

func (*MpState) UnmarshalJSON

func (state *MpState) UnmarshalJSON(data []byte) error

type Msr

type Msr struct {
	Index uint32 `json:"index"`
	Value uint64 `json:"value"`
}

type Paddr

type Paddr uint64

func IOApic

func IOApic() Paddr

func LApic

func LApic() Paddr

func (Paddr) After

func (paddr Paddr) After(length uint64) Paddr

func (Paddr) Align

func (paddr Paddr) Align(alignment uint, up bool) Paddr

func (Paddr) OffsetFrom

func (paddr Paddr) OffsetFrom(base Paddr) uint64

type PitState

type PitState struct {
	Data []byte `json:"data"`
}

PitState --

We represent the PitState as a blob. This representation should be relatively safe from a forward-compatibility perspective, as KVM internally will take care of reserving bits and ensuring compatibility, etc.

type Register

type Register int

Our general purpose registers.

const (
	RAX Register = iota
	RBX
	RCX
	RDX
	RSI
	RDI
	RSP
	RBP
	R8
	R9
	R10
	R11
	R12
	R13
	R14
	R15
	RIP
	RFLAGS
)

type RegisterValue

type RegisterValue uint64

type RunInfo

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

type Segment

type Segment int

Segment registers.

const (
	CS Segment = iota
	DS
	ES
	FS
	GS
	SS
	TR
	LDT
)

type SegmentValue

type SegmentValue struct {
	Base     uint64 `json:"base"`
	Limit    uint32 `json:"limit"`
	Selector uint16 `json:"selector"`
	Type     uint8  `json:"type"`
	Present  uint8  `json:"present"`
	Dpl      uint8  `json:"dpl"`
	Db       uint8  `json:"db"`
	L        uint8  `json:"l"`
	S        uint8  `json:"s"`
	G        uint8  `json:"g"`
	Avl      uint8  `json:"avl"`
}

type Vaddr

type Vaddr uint64

Address types.

type Vcpu

type Vcpu struct {
	// The VCPU id.
	Id uint

	// Our run information.
	RunInfo
	// contains filtered or unexported fields
}

func (*Vcpu) Dispose

func (vcpu *Vcpu) Dispose() error

func (*Vcpu) GetControlRegister

func (vcpu *Vcpu) GetControlRegister(reg ControlRegister) (ControlRegisterValue, error)

func (*Vcpu) GetCpuid

func (vcpu *Vcpu) GetCpuid() ([]Cpuid, error)

func (*Vcpu) GetDescriptor

func (vcpu *Vcpu) GetDescriptor(desc Descriptor) (DescriptorValue, error)

func (*Vcpu) GetEvents

func (vcpu *Vcpu) GetEvents() (Events, error)

func (*Vcpu) GetExitError

func (vcpu *Vcpu) GetExitError() error

func (*Vcpu) GetFpuState

func (vcpu *Vcpu) GetFpuState() (Fpu, error)

func (*Vcpu) GetLApic

func (vcpu *Vcpu) GetLApic() (LApicState, error)

func (*Vcpu) GetMpState

func (vcpu *Vcpu) GetMpState() (MpState, error)

func (*Vcpu) GetMsr

func (vcpu *Vcpu) GetMsr(index uint32) (uint64, error)

func (*Vcpu) GetMsrs

func (vcpu *Vcpu) GetMsrs() ([]Msr, error)

func (*Vcpu) GetRegister

func (vcpu *Vcpu) GetRegister(reg Register) (RegisterValue, error)

func (*Vcpu) GetRegisters

func (vcpu *Vcpu) GetRegisters() (Registers, error)

func (*Vcpu) GetSegment

func (vcpu *Vcpu) GetSegment(seg Segment) (SegmentValue, error)

func (*Vcpu) GetXSave

func (vcpu *Vcpu) GetXSave() (XSave, error)

func (*Vcpu) GetXcrs

func (vcpu *Vcpu) GetXcrs() ([]Xcr, error)

func (*Vcpu) IsStepping

func (vcpu *Vcpu) IsStepping() bool

func (*Vcpu) Load

func (vcpu *Vcpu) Load(info VcpuInfo) error

func (*Vcpu) Pause

func (vcpu *Vcpu) Pause(manual bool) error

func (*Vcpu) Run

func (vcpu *Vcpu) Run() error

func (*Vcpu) SetControlRegister

func (vcpu *Vcpu) SetControlRegister(
	reg ControlRegister,
	val ControlRegisterValue,
	sync bool) error

func (*Vcpu) SetCpuid

func (vcpu *Vcpu) SetCpuid(cpuids []Cpuid) error

func (*Vcpu) SetDescriptor

func (vcpu *Vcpu) SetDescriptor(
	desc Descriptor,
	val DescriptorValue,
	sync bool) error

func (*Vcpu) SetEvents

func (vcpu *Vcpu) SetEvents(events Events) error

func (*Vcpu) SetFpuState

func (vcpu *Vcpu) SetFpuState(state Fpu) error

func (*Vcpu) SetLApic

func (vcpu *Vcpu) SetLApic(state LApicState) error

func (*Vcpu) SetMpState

func (vcpu *Vcpu) SetMpState(state MpState) error

func (*Vcpu) SetMsr

func (vcpu *Vcpu) SetMsr(index uint32, value uint64) error

func (*Vcpu) SetMsrs

func (vcpu *Vcpu) SetMsrs(msrs []Msr) error

func (*Vcpu) SetRegister

func (vcpu *Vcpu) SetRegister(reg Register, val RegisterValue) error

func (*Vcpu) SetRegisters

func (vcpu *Vcpu) SetRegisters(regs Registers) error

func (*Vcpu) SetSegment

func (vcpu *Vcpu) SetSegment(
	seg Segment,
	val SegmentValue,
	sync bool) error

func (*Vcpu) SetStepping

func (vcpu *Vcpu) SetStepping(step bool) error

func (*Vcpu) SetXSave

func (vcpu *Vcpu) SetXSave(state XSave) error

func (*Vcpu) SetXcrs

func (vcpu *Vcpu) SetXcrs(xcrs []Xcr) error

func (*Vcpu) Translate

func (vcpu *Vcpu) Translate(
	vaddr Vaddr) (Paddr, bool, bool, bool, error)

func (*Vcpu) Unpause

func (vcpu *Vcpu) Unpause(manual bool) error

type VcpuInfo

type VcpuInfo struct {

	// Our optional id.
	// If this is not provided, we
	// assume that it is in order.
	Id *uint `json:"id"`

	// Full register state.
	Registers Registers `json:"registers"`

	// Optional multiprocessor state.
	MpState *MpState `json:"state"`

	// Our cpuid (not optional).
	Cpuid []Cpuid `json:"cpuid"`

	// Our LApic state.
	// This is optional, but is handled
	// within kvm_apic.go and not here.
	LApic LApicState `json:"lapic"`

	// Our msrs (not optional).
	Msrs []Msr `json:"msrs"`

	// Our pending vcpu events.
	Events Events `json:"events"`

	// Optional FRU state.
	Fpu *Fpu `json:"fpu"`

	// Extended control registers.
	Xcrs []Xcr `json:"xcrs"`

	// Optional xsave state.
	XSave *XSave `json:"xsave"`
}

func NewVcpuInfo

func NewVcpuInfo(vcpu *Vcpu) (VcpuInfo, error)

type Vm

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

func NewVm

func NewVm() (*Vm, error)

func (*Vm) CreateIrqChip

func (vm *Vm) CreateIrqChip() error

func (*Vm) CreatePit

func (vm *Vm) CreatePit() error

func (*Vm) CreateVcpus

func (vm *Vm) CreateVcpus(spec []VcpuInfo) ([]*Vcpu, error)

func (*Vm) Dispose

func (vm *Vm) Dispose() error

func (*Vm) GetClock

func (vm *Vm) GetClock() (Clock, error)

func (*Vm) GetIrqChip

func (vm *Vm) GetIrqChip() (IrqChip, error)

func (*Vm) GetPit

func (vm *Vm) GetPit() (PitState, error)

func (*Vm) Interrupt

func (vm *Vm) Interrupt(
	irq Irq,
	level bool) error

func (*Vm) MapReservedMemory

func (vm *Vm) MapReservedMemory(
	start Paddr,
	size uint64) error

func (*Vm) MapSpecialMemory

func (vm *Vm) MapSpecialMemory(addr Paddr) error

func (*Vm) MapUserMemory

func (vm *Vm) MapUserMemory(
	start Paddr,
	size uint64,
	mmap []byte) error

func (*Vm) NewBoundEventFd

func (vm *Vm) NewBoundEventFd(
	paddr Paddr,
	size uint,
	is_pio bool,
	has_value bool,
	value uint64) (*BoundEventFd, error)

func (*Vm) NewVcpu

func (vm *Vm) NewVcpu(id uint) (*Vcpu, error)

func (*Vm) Pause

func (vm *Vm) Pause(manual bool) error

func (*Vm) SetClock

func (vm *Vm) SetClock(clock Clock) error

func (*Vm) SetEventFd

func (vm *Vm) SetEventFd(
	eventfd *EventFd,
	paddr Paddr,
	size uint,
	is_pio bool,
	unbind bool,
	has_value bool,
	value uint64) error

func (*Vm) SetIrqChip

func (vm *Vm) SetIrqChip(state IrqChip) error

func (*Vm) SetPit

func (vm *Vm) SetPit(state PitState) error

func (*Vm) SignalMSI

func (vm *Vm) SignalMSI(
	addr Paddr,
	data uint32,
	flags uint32) error

func (*Vm) SizeSpecialMemory

func (vm *Vm) SizeSpecialMemory() uint64

func (*Vm) Unpause

func (vm *Vm) Unpause(manual bool) error

func (*Vm) VcpuInfo

func (vm *Vm) VcpuInfo() ([]VcpuInfo, error)

func (*Vm) Vcpus

func (vm *Vm) Vcpus() []*Vcpu

type XSave

type XSave struct {
	Region [1024]uint32 `json:"region"`
}

Our xsave state.

type Xcr

type Xcr struct {
	Id    uint32 `json:"xcr"`
	Value uint64 `json:"value"`
}

A single XCR.

Jump to

Keyboard shortcuts

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