github.com/SagerNet/gvisor@v0.0.0-20210707092255-7731c139d75c/pkg/sentry/platform/kvm/kvm_const.go (about) 1 // Copyright 2018 The gVisor Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package kvm 16 17 // KVM ioctls. 18 // 19 // Only the ioctls we need in Go appear here; some additional ioctls are used 20 // within the assembly stubs (KVM_INTERRUPT, etc.). 21 const ( 22 _KVM_CREATE_VM = 0xae01 23 _KVM_GET_VCPU_MMAP_SIZE = 0xae04 24 _KVM_CREATE_VCPU = 0xae41 25 _KVM_SET_TSS_ADDR = 0xae47 26 _KVM_RUN = 0xae80 27 _KVM_NMI = 0xae9a 28 _KVM_CHECK_EXTENSION = 0xae03 29 _KVM_GET_TSC_KHZ = 0xaea3 30 _KVM_SET_TSC_KHZ = 0xaea2 31 _KVM_INTERRUPT = 0x4004ae86 32 _KVM_SET_MSRS = 0x4008ae89 33 _KVM_SET_USER_MEMORY_REGION = 0x4020ae46 34 _KVM_SET_REGS = 0x4090ae82 35 _KVM_SET_SREGS = 0x4138ae84 36 _KVM_GET_MSRS = 0xc008ae88 37 _KVM_GET_REGS = 0x8090ae81 38 _KVM_GET_SREGS = 0x8138ae83 39 _KVM_GET_SUPPORTED_CPUID = 0xc008ae05 40 _KVM_SET_CPUID2 = 0x4008ae90 41 _KVM_SET_SIGNAL_MASK = 0x4004ae8b 42 _KVM_GET_VCPU_EVENTS = 0x8040ae9f 43 _KVM_SET_VCPU_EVENTS = 0x4040aea0 44 ) 45 46 // KVM exit reasons. 47 const ( 48 _KVM_EXIT_EXCEPTION = 0x1 49 _KVM_EXIT_IO = 0x2 50 _KVM_EXIT_HYPERCALL = 0x3 51 _KVM_EXIT_DEBUG = 0x4 52 _KVM_EXIT_HLT = 0x5 53 _KVM_EXIT_MMIO = 0x6 54 _KVM_EXIT_IRQ_WINDOW_OPEN = 0x7 55 _KVM_EXIT_SHUTDOWN = 0x8 56 _KVM_EXIT_FAIL_ENTRY = 0x9 57 _KVM_EXIT_INTERNAL_ERROR = 0x11 58 _KVM_EXIT_SYSTEM_EVENT = 0x18 59 _KVM_EXIT_ARM_NISV = 0x1c 60 ) 61 62 // KVM capability options. 63 const ( 64 _KVM_CAP_MAX_MEMSLOTS = 0x0a 65 _KVM_CAP_MAX_VCPUS = 0x42 66 _KVM_CAP_ARM_VM_IPA_SIZE = 0xa5 67 _KVM_CAP_VCPU_EVENTS = 0x29 68 _KVM_CAP_ARM_INJECT_SERROR_ESR = 0x9e 69 _KVM_CAP_TSC_CONTROL = 0x3c 70 ) 71 72 // KVM limits. 73 const ( 74 _KVM_NR_MEMSLOTS = 0x100 75 _KVM_NR_VCPUS = 0xff 76 _KVM_NR_INTERRUPTS = 0x100 77 _KVM_NR_CPUID_ENTRIES = 0x100 78 ) 79 80 // KVM kvm_memory_region::flags. 81 const ( 82 _KVM_MEM_LOG_DIRTY_PAGES = uint32(1) << 0 83 _KVM_MEM_READONLY = uint32(1) << 1 84 _KVM_MEM_FLAGS_NONE = 0 85 ) 86 87 // KVM hypercall list. 88 // 89 // Canonical list of hypercalls supported. 90 const ( 91 // On amd64, it uses 'HLT' to leave the guest. 92 // 93 // Unlike amd64, arm64 can only uses mmio_exit/psci to leave the guest. 94 // 95 // _KVM_HYPERCALL_VMEXIT is only used on arm64 for now. 96 _KVM_HYPERCALL_VMEXIT int = iota 97 _KVM_HYPERCALL_MAX 98 )