package kvm
import "gvisor.dev/gvisor/pkg/sentry/platform/kvm"
Package kvm provides a kvm-based implementation of the platform interface.
Index ¶
- Constants
- Variables
- func OpenDevice(devicePath string) (*fd.FD, error)
- type Config
- type KVM
- func New(deviceFile *fd.FD, config Config) (*KVM, error)
- func (*KVM) CooperativelySchedulesAddressSpace() bool
- func (k *KVM) IoeventfdDisable(ev *eventfd.Eventfd)
- func (k *KVM) IoeventfdEnable(ev *eventfd.Eventfd) error
- func (*KVM) MapUnit() uint64
- func (*KVM) MaxUserAddress() hostarch.Addr
- func (*KVM) MinUserAddress() hostarch.Addr
- func (k *KVM) NewAddressSpace(any) (platform.AddressSpace, <-chan struct{}, error)
- func (k *KVM) NewContext(pkgcontext.Context) platform.Context
- func (k *KVM) SeccompInfo() platform.SeccompInfo
- func (*KVM) SupportsAddressSpaceIO() bool
Constants ¶
const ( KVM_CREATE_VM = 0xae01 KVM_GET_VCPU_MMAP_SIZE = 0xae04 KVM_CREATE_VCPU = 0xae41 KVM_SET_TSS_ADDR = 0xae47 KVM_RUN = 0xae80 KVM_NMI = 0xae9a KVM_CHECK_EXTENSION = 0xae03 KVM_GET_TSC_KHZ = 0xaea3 KVM_SET_TSC_KHZ = 0xaea2 KVM_INTERRUPT = 0x4004ae86 KVM_SET_MSRS = 0x4008ae89 KVM_SET_USER_MEMORY_REGION = 0x4020ae46 KVM_IOEVENTFD = 0x4040ae79 KVM_SET_REGS = 0x4090ae82 KVM_SET_SREGS = 0x4138ae84 KVM_GET_MSRS = 0xc008ae88 KVM_GET_REGS = 0x8090ae81 KVM_GET_SREGS = 0x8138ae83 KVM_GET_SUPPORTED_CPUID = 0xc008ae05 KVM_SET_CPUID2 = 0x4008ae90 KVM_SET_SIGNAL_MASK = 0x4004ae8b KVM_GET_VCPU_EVENTS = 0x8040ae9f KVM_SET_VCPU_EVENTS = 0x4040aea0 KVM_SET_DEVICE_ATTR = 0x4018aee1 KVM_ENABLE_CAP = 0x4068aea3 )
KVM ioctls.
Only the ioctls we need in Go appear here; some additional ioctls are used within the assembly stubs (KVM_INTERRUPT, etc.).
Variables ¶
var KVMProfiling = metric.FakeMetricBuilder{}
KVMProfiling is a builder that produces conditionally compiled metrics. Metrics made from this are compiled and active at runtime when the "kvm_profiling" go-tag is specified at compilation.
Functions ¶
func OpenDevice ¶
OpenDevice opens the KVM device and returns the File. If the devicePath is empty, it will default to /dev/kvm.
Types ¶
type Config ¶
type Config struct{}
Config sets configuration options for each platform instance.
type KVM ¶
type KVM struct { platform.NoCPUPreemptionDetection // KVM never changes mm_structs. platform.UseHostProcessMemoryBarrier // contains filtered or unexported fields }
KVM represents a lightweight VM context.
func New ¶
New returns a new KVM-based implementation of the platform interface.
func (*KVM) CooperativelySchedulesAddressSpace ¶
CooperativelySchedulesAddressSpace implements platform.Platform.CooperativelySchedulesAddressSpace.
func (*KVM) IoeventfdDisable ¶
IoeventfdDisable undoes the effect of a previous call to IoeventfdEnable.
func (*KVM) IoeventfdEnable ¶
IoeventfdEnable causes the given eventfd to use MMIO when Eventfd.Write() is called in k's guest mode.
Postconditions: Eventfd.Write() cannot be called while in the guest mode of any VM other than k, i.e. no other KVM platform instance may be in use.
func (*KVM) MapUnit ¶
MapUnit implements platform.Platform.MapUnit.
func (*KVM) MaxUserAddress ¶
MaxUserAddress returns the first address that may not be used.
func (*KVM) MinUserAddress ¶
MinUserAddress returns the lowest available address.
func (*KVM) NewAddressSpace ¶
func (k *KVM) NewAddressSpace(any) (platform.AddressSpace, <-chan struct{}, error)
NewAddressSpace returns a new pagetable root.
func (*KVM) NewContext ¶
func (k *KVM) NewContext(pkgcontext.Context) platform.Context
NewContext returns an interruptible context.
func (*KVM) SeccompInfo ¶
func (k *KVM) SeccompInfo() platform.SeccompInfo
SeccompInfo returns seccomp information for the KVM platform.
func (*KVM) SupportsAddressSpaceIO ¶
SupportsAddressSpaceIO implements platform.Platform.SupportsAddressSpaceIO.
Source Files ¶
address_space.go address_space_amd64.go bluepill.go bluepill_allocator.go bluepill_amd64.go bluepill_amd64_unsafe.go bluepill_fault.go bluepill_unsafe.go config.go context.go filters.go filters_amd64.go ioeventfd.go ioeventfd_unsafe.go kvm.go kvm_amd64.go kvm_amd64_unsafe.go kvm_const.go kvm_const_amd64.go kvm_profiling_fake.go machine.go machine_amd64.go machine_amd64_unsafe.go machine_cgo.go machine_unsafe.go physical_map.go physical_map_amd64.go seccomp_mmap_unsafe.go virtual_map.go
Directories ¶
Path | Synopsis |
---|---|
pkg/sentry/platform/kvm/testutil | Package testutil provides common assembly stubs for testing. |
- Version
- v0.0.0-20250605235530-a6711d1e1dc6 (latest)
- Published
- Jun 5, 2025
- Platform
- linux/amd64
- Imports
- 40 packages
- Last checked
- 4 hours ago –
Tools for package owners.