Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 1 | The Definitive KVM (Kernel-based Virtual Machine) API Documentation |
| 2 | =================================================================== |
| 3 | |
| 4 | 1. General description |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 5 | ---------------------- |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 6 | |
| 7 | The kvm API is a set of ioctls that are issued to control various aspects |
| 8 | of a virtual machine. The ioctls belong to three classes |
| 9 | |
| 10 | - System ioctls: These query and set global attributes which affect the |
| 11 | whole kvm subsystem. In addition a system ioctl is used to create |
| 12 | virtual machines |
| 13 | |
| 14 | - VM ioctls: These query and set attributes that affect an entire virtual |
| 15 | machine, for example memory layout. In addition a VM ioctl is used to |
| 16 | create virtual cpus (vcpus). |
| 17 | |
| 18 | Only run VM ioctls from the same process (address space) that was used |
| 19 | to create the VM. |
| 20 | |
| 21 | - vcpu ioctls: These query and set attributes that control the operation |
| 22 | of a single virtual cpu. |
| 23 | |
| 24 | Only run vcpu ioctls from the same thread that was used to create the |
| 25 | vcpu. |
| 26 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 27 | |
Wu Fengguang | 2044892d | 2009-12-24 09:04:16 +0800 | [diff] [blame] | 28 | 2. File descriptors |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 29 | ------------------- |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 30 | |
| 31 | The kvm API is centered around file descriptors. An initial |
| 32 | open("/dev/kvm") obtains a handle to the kvm subsystem; this handle |
| 33 | can be used to issue system ioctls. A KVM_CREATE_VM ioctl on this |
Wu Fengguang | 2044892d | 2009-12-24 09:04:16 +0800 | [diff] [blame] | 34 | handle will create a VM file descriptor which can be used to issue VM |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 35 | ioctls. A KVM_CREATE_VCPU ioctl on a VM fd will create a virtual cpu |
| 36 | and return a file descriptor pointing to it. Finally, ioctls on a vcpu |
| 37 | fd can be used to control the vcpu, including the important task of |
| 38 | actually running guest code. |
| 39 | |
| 40 | In general file descriptors can be migrated among processes by means |
| 41 | of fork() and the SCM_RIGHTS facility of unix domain socket. These |
| 42 | kinds of tricks are explicitly not supported by kvm. While they will |
| 43 | not cause harm to the host, their actual behavior is not guaranteed by |
| 44 | the API. The only supported use is one virtual machine per process, |
| 45 | and one vcpu per thread. |
| 46 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 47 | |
Sean Christopherson | eca6be5 | 2019-02-15 12:48:40 -0800 | [diff] [blame^] | 48 | It is important to note that althought VM ioctls may only be issued from |
| 49 | the process that created the VM, a VM's lifecycle is associated with its |
| 50 | file descriptor, not its creator (process). In other words, the VM and |
| 51 | its resources, *including the associated address space*, are not freed |
| 52 | until the last reference to the VM's file descriptor has been released. |
| 53 | For example, if fork() is issued after ioctl(KVM_CREATE_VM), the VM will |
| 54 | not be freed until both the parent (original) process and its child have |
| 55 | put their references to the VM's file descriptor. |
| 56 | |
| 57 | Because a VM's resources are not freed until the last reference to its |
| 58 | file descriptor is released, creating additional references to a VM via |
| 59 | via fork(), dup(), etc... without careful consideration is strongly |
| 60 | discouraged and may have unwanted side effects, e.g. memory allocated |
| 61 | by and on behalf of the VM's process may not be freed/unaccounted when |
| 62 | the VM is shut down. |
| 63 | |
| 64 | |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 65 | 3. Extensions |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 66 | ------------- |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 67 | |
| 68 | As of Linux 2.6.22, the KVM ABI has been stabilized: no backward |
| 69 | incompatible change are allowed. However, there is an extension |
| 70 | facility that allows backward-compatible extensions to the API to be |
| 71 | queried and used. |
| 72 | |
Masanari Iida | c9f3f2d | 2013-07-18 01:29:12 +0900 | [diff] [blame] | 73 | The extension mechanism is not based on the Linux version number. |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 74 | Instead, kvm defines extension identifiers and a facility to query |
| 75 | whether a particular extension identifier is available. If it is, a |
| 76 | set of ioctls is available for application use. |
| 77 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 78 | |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 79 | 4. API description |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 80 | ------------------ |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 81 | |
| 82 | This section describes ioctls that can be used to control kvm guests. |
| 83 | For each ioctl, the following information is provided along with a |
| 84 | description: |
| 85 | |
| 86 | Capability: which KVM extension provides this ioctl. Can be 'basic', |
| 87 | which means that is will be provided by any kernel that supports |
Michael S. Tsirkin | 7f05db6 | 2014-10-12 11:34:00 +0300 | [diff] [blame] | 88 | API version 12 (see section 4.1), a KVM_CAP_xyz constant, which |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 89 | means availability needs to be checked with KVM_CHECK_EXTENSION |
Michael S. Tsirkin | 7f05db6 | 2014-10-12 11:34:00 +0300 | [diff] [blame] | 90 | (see section 4.4), or 'none' which means that while not all kernels |
| 91 | support this ioctl, there's no capability bit to check its |
| 92 | availability: for kernels that don't support the ioctl, |
| 93 | the ioctl returns -ENOTTY. |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 94 | |
| 95 | Architectures: which instruction set architectures provide this ioctl. |
| 96 | x86 includes both i386 and x86_64. |
| 97 | |
| 98 | Type: system, vm, or vcpu. |
| 99 | |
| 100 | Parameters: what parameters are accepted by the ioctl. |
| 101 | |
| 102 | Returns: the return value. General error numbers (EBADF, ENOMEM, EINVAL) |
| 103 | are not detailed, but errors with specific meanings are. |
| 104 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 105 | |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 106 | 4.1 KVM_GET_API_VERSION |
| 107 | |
| 108 | Capability: basic |
| 109 | Architectures: all |
| 110 | Type: system ioctl |
| 111 | Parameters: none |
| 112 | Returns: the constant KVM_API_VERSION (=12) |
| 113 | |
| 114 | This identifies the API version as the stable kvm API. It is not |
| 115 | expected that this number will change. However, Linux 2.6.20 and |
| 116 | 2.6.21 report earlier versions; these are not documented and not |
| 117 | supported. Applications should refuse to run if KVM_GET_API_VERSION |
| 118 | returns a value other than 12. If this check passes, all ioctls |
| 119 | described as 'basic' will be available. |
| 120 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 121 | |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 122 | 4.2 KVM_CREATE_VM |
| 123 | |
| 124 | Capability: basic |
| 125 | Architectures: all |
| 126 | Type: system ioctl |
Carsten Otte | e08b963 | 2012-01-04 10:25:20 +0100 | [diff] [blame] | 127 | Parameters: machine type identifier (KVM_VM_*) |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 128 | Returns: a VM fd that can be used to control the new virtual machine. |
| 129 | |
Jann Horn | bcb85c8 | 2017-04-24 11:16:49 +0200 | [diff] [blame] | 130 | The new VM has no virtual cpus and no memory. |
James Hogan | a8a3c42 | 2017-03-14 10:15:19 +0000 | [diff] [blame] | 131 | You probably want to use 0 as machine type. |
Carsten Otte | e08b963 | 2012-01-04 10:25:20 +0100 | [diff] [blame] | 132 | |
| 133 | In order to create user controlled virtual machines on S390, check |
| 134 | KVM_CAP_S390_UCONTROL and use the flag KVM_VM_S390_UCONTROL as |
| 135 | privileged user (CAP_SYS_ADMIN). |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 136 | |
James Hogan | a8a3c42 | 2017-03-14 10:15:19 +0000 | [diff] [blame] | 137 | To use hardware assisted virtualization on MIPS (VZ ASE) rather than |
| 138 | the default trap & emulate implementation (which changes the virtual |
| 139 | memory layout to fit in user mode), check KVM_CAP_MIPS_VZ and use the |
| 140 | flag KVM_VM_MIPS_VZ. |
| 141 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 142 | |
Suzuki K Poulose | 233a7cb | 2018-09-26 17:32:54 +0100 | [diff] [blame] | 143 | On arm64, the physical address size for a VM (IPA Size limit) is limited |
| 144 | to 40bits by default. The limit can be configured if the host supports the |
| 145 | extension KVM_CAP_ARM_VM_IPA_SIZE. When supported, use |
| 146 | KVM_VM_TYPE_ARM_IPA_SIZE(IPA_Bits) to set the size in the machine type |
| 147 | identifier, where IPA_Bits is the maximum width of any physical |
| 148 | address used by the VM. The IPA_Bits is encoded in bits[7-0] of the |
| 149 | machine type identifier. |
| 150 | |
| 151 | e.g, to configure a guest to use 48bit physical address size : |
| 152 | |
| 153 | vm_fd = ioctl(dev_fd, KVM_CREATE_VM, KVM_VM_TYPE_ARM_IPA_SIZE(48)); |
| 154 | |
| 155 | The requested size (IPA_Bits) must be : |
| 156 | 0 - Implies default size, 40bits (for backward compatibility) |
| 157 | |
| 158 | or |
| 159 | |
| 160 | N - Implies N bits, where N is a positive integer such that, |
| 161 | 32 <= N <= Host_IPA_Limit |
| 162 | |
| 163 | Host_IPA_Limit is the maximum possible value for IPA_Bits on the host and |
| 164 | is dependent on the CPU capability and the kernel configuration. The limit can |
| 165 | be retrieved using KVM_CAP_ARM_VM_IPA_SIZE of the KVM_CHECK_EXTENSION |
| 166 | ioctl() at run-time. |
| 167 | |
| 168 | Please note that configuring the IPA size does not affect the capability |
| 169 | exposed by the guest CPUs in ID_AA64MMFR0_EL1[PARange]. It only affects |
| 170 | size of the address translated by the stage2 level (guest physical to |
| 171 | host physical address translations). |
| 172 | |
| 173 | |
Tom Lendacky | 801e459 | 2018-02-21 13:39:51 -0600 | [diff] [blame] | 174 | 4.3 KVM_GET_MSR_INDEX_LIST, KVM_GET_MSR_FEATURE_INDEX_LIST |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 175 | |
Tom Lendacky | 801e459 | 2018-02-21 13:39:51 -0600 | [diff] [blame] | 176 | Capability: basic, KVM_CAP_GET_MSR_FEATURES for KVM_GET_MSR_FEATURE_INDEX_LIST |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 177 | Architectures: x86 |
Tom Lendacky | 801e459 | 2018-02-21 13:39:51 -0600 | [diff] [blame] | 178 | Type: system ioctl |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 179 | Parameters: struct kvm_msr_list (in/out) |
| 180 | Returns: 0 on success; -1 on error |
| 181 | Errors: |
Tom Lendacky | 801e459 | 2018-02-21 13:39:51 -0600 | [diff] [blame] | 182 | EFAULT: the msr index list cannot be read from or written to |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 183 | E2BIG: the msr index list is to be to fit in the array specified by |
| 184 | the user. |
| 185 | |
| 186 | struct kvm_msr_list { |
| 187 | __u32 nmsrs; /* number of msrs in entries */ |
| 188 | __u32 indices[0]; |
| 189 | }; |
| 190 | |
Tom Lendacky | 801e459 | 2018-02-21 13:39:51 -0600 | [diff] [blame] | 191 | The user fills in the size of the indices array in nmsrs, and in return |
| 192 | kvm adjusts nmsrs to reflect the actual number of msrs and fills in the |
| 193 | indices array with their numbers. |
| 194 | |
| 195 | KVM_GET_MSR_INDEX_LIST returns the guest msrs that are supported. The list |
| 196 | varies by kvm version and host processor, but does not change otherwise. |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 197 | |
Avi Kivity | 2e2602c | 2010-07-07 14:09:39 +0300 | [diff] [blame] | 198 | Note: if kvm indicates supports MCE (KVM_CAP_MCE), then the MCE bank MSRs are |
| 199 | not returned in the MSR list, as different vcpus can have a different number |
| 200 | of banks, as set via the KVM_X86_SETUP_MCE ioctl. |
| 201 | |
Tom Lendacky | 801e459 | 2018-02-21 13:39:51 -0600 | [diff] [blame] | 202 | KVM_GET_MSR_FEATURE_INDEX_LIST returns the list of MSRs that can be passed |
| 203 | to the KVM_GET_MSRS system ioctl. This lets userspace probe host capabilities |
| 204 | and processor features that are exposed via MSRs (e.g., VMX capabilities). |
| 205 | This list also varies by kvm version and host processor, but does not change |
| 206 | otherwise. |
| 207 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 208 | |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 209 | 4.4 KVM_CHECK_EXTENSION |
| 210 | |
Alexander Graf | 92b591a | 2014-07-14 18:33:08 +0200 | [diff] [blame] | 211 | Capability: basic, KVM_CAP_CHECK_EXTENSION_VM for vm ioctl |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 212 | Architectures: all |
Alexander Graf | 92b591a | 2014-07-14 18:33:08 +0200 | [diff] [blame] | 213 | Type: system ioctl, vm ioctl |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 214 | Parameters: extension identifier (KVM_CAP_*) |
| 215 | Returns: 0 if unsupported; 1 (or some other positive integer) if supported |
| 216 | |
| 217 | The API allows the application to query about extensions to the core |
| 218 | kvm API. Userspace passes an extension identifier (an integer) and |
| 219 | receives an integer that describes the extension availability. |
| 220 | Generally 0 means no and 1 means yes, but some extensions may report |
| 221 | additional information in the integer return value. |
| 222 | |
Alexander Graf | 92b591a | 2014-07-14 18:33:08 +0200 | [diff] [blame] | 223 | Based on their initialization different VMs may have different capabilities. |
| 224 | It is thus encouraged to use the vm ioctl to query for capabilities (available |
| 225 | with KVM_CAP_CHECK_EXTENSION_VM on the vm fd) |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 226 | |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 227 | 4.5 KVM_GET_VCPU_MMAP_SIZE |
| 228 | |
| 229 | Capability: basic |
| 230 | Architectures: all |
| 231 | Type: system ioctl |
| 232 | Parameters: none |
| 233 | Returns: size of vcpu mmap area, in bytes |
| 234 | |
| 235 | The KVM_RUN ioctl (cf.) communicates with userspace via a shared |
| 236 | memory region. This ioctl returns the size of that region. See the |
| 237 | KVM_RUN documentation for details. |
| 238 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 239 | |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 240 | 4.6 KVM_SET_MEMORY_REGION |
| 241 | |
| 242 | Capability: basic |
| 243 | Architectures: all |
| 244 | Type: vm ioctl |
| 245 | Parameters: struct kvm_memory_region (in) |
| 246 | Returns: 0 on success, -1 on error |
| 247 | |
Avi Kivity | b74a07b | 2010-06-21 11:48:05 +0300 | [diff] [blame] | 248 | This ioctl is obsolete and has been removed. |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 249 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 250 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 251 | 4.7 KVM_CREATE_VCPU |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 252 | |
| 253 | Capability: basic |
| 254 | Architectures: all |
| 255 | Type: vm ioctl |
| 256 | Parameters: vcpu id (apic id on x86) |
| 257 | Returns: vcpu fd on success, -1 on error |
| 258 | |
Greg Kurz | 0b1b1df | 2016-05-09 18:13:37 +0200 | [diff] [blame] | 259 | This API adds a vcpu to a virtual machine. No more than max_vcpus may be added. |
| 260 | The vcpu id is an integer in the range [0, max_vcpu_id). |
Sasha Levin | 8c3ba33 | 2011-07-18 17:17:15 +0300 | [diff] [blame] | 261 | |
| 262 | The recommended max_vcpus value can be retrieved using the KVM_CAP_NR_VCPUS of |
| 263 | the KVM_CHECK_EXTENSION ioctl() at run-time. |
| 264 | The maximum possible value for max_vcpus can be retrieved using the |
| 265 | KVM_CAP_MAX_VCPUS of the KVM_CHECK_EXTENSION ioctl() at run-time. |
| 266 | |
Pekka Enberg | 76d2540 | 2011-05-09 22:48:54 +0300 | [diff] [blame] | 267 | If the KVM_CAP_NR_VCPUS does not exist, you should assume that max_vcpus is 4 |
| 268 | cpus max. |
Sasha Levin | 8c3ba33 | 2011-07-18 17:17:15 +0300 | [diff] [blame] | 269 | If the KVM_CAP_MAX_VCPUS does not exist, you should assume that max_vcpus is |
| 270 | same as the value returned from KVM_CAP_NR_VCPUS. |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 271 | |
Greg Kurz | 0b1b1df | 2016-05-09 18:13:37 +0200 | [diff] [blame] | 272 | The maximum possible value for max_vcpu_id can be retrieved using the |
| 273 | KVM_CAP_MAX_VCPU_ID of the KVM_CHECK_EXTENSION ioctl() at run-time. |
| 274 | |
| 275 | If the KVM_CAP_MAX_VCPU_ID does not exist, you should assume that max_vcpu_id |
| 276 | is the same as the value returned from KVM_CAP_MAX_VCPUS. |
| 277 | |
Paul Mackerras | 371fefd | 2011-06-29 00:23:08 +0000 | [diff] [blame] | 278 | On powerpc using book3s_hv mode, the vcpus are mapped onto virtual |
| 279 | threads in one or more virtual CPU cores. (This is because the |
| 280 | hardware requires all the hardware threads in a CPU core to be in the |
| 281 | same partition.) The KVM_CAP_PPC_SMT capability indicates the number |
| 282 | of vcpus per virtual core (vcore). The vcore id is obtained by |
| 283 | dividing the vcpu id by the number of vcpus per vcore. The vcpus in a |
| 284 | given vcore will always be in the same physical core as each other |
| 285 | (though that might be a different physical core from time to time). |
| 286 | Userspace can control the threading (SMT) mode of the guest by its |
| 287 | allocation of vcpu ids. For example, if userspace wants |
| 288 | single-threaded guest vcpus, it should make all vcpu ids be a multiple |
| 289 | of the number of vcpus per vcore. |
| 290 | |
Carsten Otte | 5b1c149 | 2012-01-04 10:25:23 +0100 | [diff] [blame] | 291 | For virtual cpus that have been created with S390 user controlled virtual |
| 292 | machines, the resulting vcpu fd can be memory mapped at page offset |
| 293 | KVM_S390_SIE_PAGE_OFFSET in order to obtain a memory map of the virtual |
| 294 | cpu's hardware control block. |
| 295 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 296 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 297 | 4.8 KVM_GET_DIRTY_LOG (vm ioctl) |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 298 | |
| 299 | Capability: basic |
| 300 | Architectures: x86 |
| 301 | Type: vm ioctl |
| 302 | Parameters: struct kvm_dirty_log (in/out) |
| 303 | Returns: 0 on success, -1 on error |
| 304 | |
| 305 | /* for KVM_GET_DIRTY_LOG */ |
| 306 | struct kvm_dirty_log { |
| 307 | __u32 slot; |
| 308 | __u32 padding; |
| 309 | union { |
| 310 | void __user *dirty_bitmap; /* one bit per page */ |
| 311 | __u64 padding; |
| 312 | }; |
| 313 | }; |
| 314 | |
| 315 | Given a memory slot, return a bitmap containing any pages dirtied |
| 316 | since the last call to this ioctl. Bit 0 is the first page in the |
| 317 | memory slot. Ensure the entire structure is cleared to avoid padding |
| 318 | issues. |
| 319 | |
Paolo Bonzini | f481b06 | 2015-05-17 17:30:37 +0200 | [diff] [blame] | 320 | If KVM_CAP_MULTI_ADDRESS_SPACE is available, bits 16-31 specifies |
| 321 | the address space for which you want to return the dirty bitmap. |
| 322 | They must be less than the value that KVM_CHECK_EXTENSION returns for |
| 323 | the KVM_CAP_MULTI_ADDRESS_SPACE capability. |
| 324 | |
Paolo Bonzini | 2a31b9d | 2018-10-23 02:36:47 +0200 | [diff] [blame] | 325 | The bits in the dirty bitmap are cleared before the ioctl returns, unless |
| 326 | KVM_CAP_MANUAL_DIRTY_LOG_PROTECT is enabled. For more information, |
| 327 | see the description of the capability. |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 328 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 329 | 4.9 KVM_SET_MEMORY_ALIAS |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 330 | |
| 331 | Capability: basic |
| 332 | Architectures: x86 |
| 333 | Type: vm ioctl |
| 334 | Parameters: struct kvm_memory_alias (in) |
| 335 | Returns: 0 (success), -1 (error) |
| 336 | |
Avi Kivity | a1f4d395 | 2010-06-21 11:44:20 +0300 | [diff] [blame] | 337 | This ioctl is obsolete and has been removed. |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 338 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 339 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 340 | 4.10 KVM_RUN |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 341 | |
| 342 | Capability: basic |
| 343 | Architectures: all |
| 344 | Type: vcpu ioctl |
| 345 | Parameters: none |
| 346 | Returns: 0 on success, -1 on error |
| 347 | Errors: |
| 348 | EINTR: an unmasked signal is pending |
| 349 | |
| 350 | This ioctl is used to run a guest virtual cpu. While there are no |
| 351 | explicit parameters, there is an implicit parameter block that can be |
| 352 | obtained by mmap()ing the vcpu fd at offset 0, with the size given by |
| 353 | KVM_GET_VCPU_MMAP_SIZE. The parameter block is formatted as a 'struct |
| 354 | kvm_run' (see below). |
| 355 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 356 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 357 | 4.11 KVM_GET_REGS |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 358 | |
| 359 | Capability: basic |
Marc Zyngier | 379e04c7 | 2013-04-02 17:46:31 +0100 | [diff] [blame] | 360 | Architectures: all except ARM, arm64 |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 361 | Type: vcpu ioctl |
| 362 | Parameters: struct kvm_regs (out) |
| 363 | Returns: 0 on success, -1 on error |
| 364 | |
| 365 | Reads the general purpose registers from the vcpu. |
| 366 | |
| 367 | /* x86 */ |
| 368 | struct kvm_regs { |
| 369 | /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */ |
| 370 | __u64 rax, rbx, rcx, rdx; |
| 371 | __u64 rsi, rdi, rsp, rbp; |
| 372 | __u64 r8, r9, r10, r11; |
| 373 | __u64 r12, r13, r14, r15; |
| 374 | __u64 rip, rflags; |
| 375 | }; |
| 376 | |
James Hogan | c2d2c21 | 2014-07-04 15:11:35 +0100 | [diff] [blame] | 377 | /* mips */ |
| 378 | struct kvm_regs { |
| 379 | /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */ |
| 380 | __u64 gpr[32]; |
| 381 | __u64 hi; |
| 382 | __u64 lo; |
| 383 | __u64 pc; |
| 384 | }; |
| 385 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 386 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 387 | 4.12 KVM_SET_REGS |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 388 | |
| 389 | Capability: basic |
Marc Zyngier | 379e04c7 | 2013-04-02 17:46:31 +0100 | [diff] [blame] | 390 | Architectures: all except ARM, arm64 |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 391 | Type: vcpu ioctl |
| 392 | Parameters: struct kvm_regs (in) |
| 393 | Returns: 0 on success, -1 on error |
| 394 | |
| 395 | Writes the general purpose registers into the vcpu. |
| 396 | |
| 397 | See KVM_GET_REGS for the data structure. |
| 398 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 399 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 400 | 4.13 KVM_GET_SREGS |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 401 | |
| 402 | Capability: basic |
Scott Wood | 5ce941e | 2011-04-27 17:24:21 -0500 | [diff] [blame] | 403 | Architectures: x86, ppc |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 404 | Type: vcpu ioctl |
| 405 | Parameters: struct kvm_sregs (out) |
| 406 | Returns: 0 on success, -1 on error |
| 407 | |
| 408 | Reads special registers from the vcpu. |
| 409 | |
| 410 | /* x86 */ |
| 411 | struct kvm_sregs { |
| 412 | struct kvm_segment cs, ds, es, fs, gs, ss; |
| 413 | struct kvm_segment tr, ldt; |
| 414 | struct kvm_dtable gdt, idt; |
| 415 | __u64 cr0, cr2, cr3, cr4, cr8; |
| 416 | __u64 efer; |
| 417 | __u64 apic_base; |
| 418 | __u64 interrupt_bitmap[(KVM_NR_INTERRUPTS + 63) / 64]; |
| 419 | }; |
| 420 | |
Mihai Caraman | 68e2ffe | 2012-12-11 03:38:23 +0000 | [diff] [blame] | 421 | /* ppc -- see arch/powerpc/include/uapi/asm/kvm.h */ |
Scott Wood | 5ce941e | 2011-04-27 17:24:21 -0500 | [diff] [blame] | 422 | |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 423 | interrupt_bitmap is a bitmap of pending external interrupts. At most |
| 424 | one bit may be set. This interrupt has been acknowledged by the APIC |
| 425 | but not yet injected into the cpu core. |
| 426 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 427 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 428 | 4.14 KVM_SET_SREGS |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 429 | |
| 430 | Capability: basic |
Scott Wood | 5ce941e | 2011-04-27 17:24:21 -0500 | [diff] [blame] | 431 | Architectures: x86, ppc |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 432 | Type: vcpu ioctl |
| 433 | Parameters: struct kvm_sregs (in) |
| 434 | Returns: 0 on success, -1 on error |
| 435 | |
| 436 | Writes special registers into the vcpu. See KVM_GET_SREGS for the |
| 437 | data structures. |
| 438 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 439 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 440 | 4.15 KVM_TRANSLATE |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 441 | |
| 442 | Capability: basic |
| 443 | Architectures: x86 |
| 444 | Type: vcpu ioctl |
| 445 | Parameters: struct kvm_translation (in/out) |
| 446 | Returns: 0 on success, -1 on error |
| 447 | |
| 448 | Translates a virtual address according to the vcpu's current address |
| 449 | translation mode. |
| 450 | |
| 451 | struct kvm_translation { |
| 452 | /* in */ |
| 453 | __u64 linear_address; |
| 454 | |
| 455 | /* out */ |
| 456 | __u64 physical_address; |
| 457 | __u8 valid; |
| 458 | __u8 writeable; |
| 459 | __u8 usermode; |
| 460 | __u8 pad[5]; |
| 461 | }; |
| 462 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 463 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 464 | 4.16 KVM_INTERRUPT |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 465 | |
| 466 | Capability: basic |
James Hogan | c2d2c21 | 2014-07-04 15:11:35 +0100 | [diff] [blame] | 467 | Architectures: x86, ppc, mips |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 468 | Type: vcpu ioctl |
| 469 | Parameters: struct kvm_interrupt (in) |
Steve Rutherford | 1c1a9ce | 2015-07-30 11:27:16 +0200 | [diff] [blame] | 470 | Returns: 0 on success, negative on failure. |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 471 | |
Steve Rutherford | 1c1a9ce | 2015-07-30 11:27:16 +0200 | [diff] [blame] | 472 | Queues a hardware interrupt vector to be injected. |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 473 | |
| 474 | /* for KVM_INTERRUPT */ |
| 475 | struct kvm_interrupt { |
| 476 | /* in */ |
| 477 | __u32 irq; |
| 478 | }; |
| 479 | |
Alexander Graf | 6f7a2bd | 2010-08-31 02:03:32 +0200 | [diff] [blame] | 480 | X86: |
| 481 | |
Steve Rutherford | 1c1a9ce | 2015-07-30 11:27:16 +0200 | [diff] [blame] | 482 | Returns: 0 on success, |
| 483 | -EEXIST if an interrupt is already enqueued |
| 484 | -EINVAL the the irq number is invalid |
| 485 | -ENXIO if the PIC is in the kernel |
| 486 | -EFAULT if the pointer is invalid |
| 487 | |
| 488 | Note 'irq' is an interrupt vector, not an interrupt pin or line. This |
| 489 | ioctl is useful if the in-kernel PIC is not used. |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 490 | |
Alexander Graf | 6f7a2bd | 2010-08-31 02:03:32 +0200 | [diff] [blame] | 491 | PPC: |
| 492 | |
| 493 | Queues an external interrupt to be injected. This ioctl is overleaded |
| 494 | with 3 different irq values: |
| 495 | |
| 496 | a) KVM_INTERRUPT_SET |
| 497 | |
| 498 | This injects an edge type external interrupt into the guest once it's ready |
| 499 | to receive interrupts. When injected, the interrupt is done. |
| 500 | |
| 501 | b) KVM_INTERRUPT_UNSET |
| 502 | |
| 503 | This unsets any pending interrupt. |
| 504 | |
| 505 | Only available with KVM_CAP_PPC_UNSET_IRQ. |
| 506 | |
| 507 | c) KVM_INTERRUPT_SET_LEVEL |
| 508 | |
| 509 | This injects a level type external interrupt into the guest context. The |
| 510 | interrupt stays pending until a specific ioctl with KVM_INTERRUPT_UNSET |
| 511 | is triggered. |
| 512 | |
| 513 | Only available with KVM_CAP_PPC_IRQ_LEVEL. |
| 514 | |
| 515 | Note that any value for 'irq' other than the ones stated above is invalid |
| 516 | and incurs unexpected behavior. |
| 517 | |
James Hogan | c2d2c21 | 2014-07-04 15:11:35 +0100 | [diff] [blame] | 518 | MIPS: |
| 519 | |
| 520 | Queues an external interrupt to be injected into the virtual CPU. A negative |
| 521 | interrupt number dequeues the interrupt. |
| 522 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 523 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 524 | 4.17 KVM_DEBUG_GUEST |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 525 | |
| 526 | Capability: basic |
| 527 | Architectures: none |
| 528 | Type: vcpu ioctl |
| 529 | Parameters: none) |
| 530 | Returns: -1 on error |
| 531 | |
| 532 | Support for this has been removed. Use KVM_SET_GUEST_DEBUG instead. |
| 533 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 534 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 535 | 4.18 KVM_GET_MSRS |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 536 | |
Tom Lendacky | 801e459 | 2018-02-21 13:39:51 -0600 | [diff] [blame] | 537 | Capability: basic (vcpu), KVM_CAP_GET_MSR_FEATURES (system) |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 538 | Architectures: x86 |
Tom Lendacky | 801e459 | 2018-02-21 13:39:51 -0600 | [diff] [blame] | 539 | Type: system ioctl, vcpu ioctl |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 540 | Parameters: struct kvm_msrs (in/out) |
Tom Lendacky | 801e459 | 2018-02-21 13:39:51 -0600 | [diff] [blame] | 541 | Returns: number of msrs successfully returned; |
| 542 | -1 on error |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 543 | |
Tom Lendacky | 801e459 | 2018-02-21 13:39:51 -0600 | [diff] [blame] | 544 | When used as a system ioctl: |
| 545 | Reads the values of MSR-based features that are available for the VM. This |
| 546 | is similar to KVM_GET_SUPPORTED_CPUID, but it returns MSR indices and values. |
| 547 | The list of msr-based features can be obtained using KVM_GET_MSR_FEATURE_INDEX_LIST |
| 548 | in a system ioctl. |
| 549 | |
| 550 | When used as a vcpu ioctl: |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 551 | Reads model-specific registers from the vcpu. Supported msr indices can |
Tom Lendacky | 801e459 | 2018-02-21 13:39:51 -0600 | [diff] [blame] | 552 | be obtained using KVM_GET_MSR_INDEX_LIST in a system ioctl. |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 553 | |
| 554 | struct kvm_msrs { |
| 555 | __u32 nmsrs; /* number of msrs in entries */ |
| 556 | __u32 pad; |
| 557 | |
| 558 | struct kvm_msr_entry entries[0]; |
| 559 | }; |
| 560 | |
| 561 | struct kvm_msr_entry { |
| 562 | __u32 index; |
| 563 | __u32 reserved; |
| 564 | __u64 data; |
| 565 | }; |
| 566 | |
| 567 | Application code should set the 'nmsrs' member (which indicates the |
| 568 | size of the entries array) and the 'index' member of each array entry. |
| 569 | kvm will fill in the 'data' member. |
| 570 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 571 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 572 | 4.19 KVM_SET_MSRS |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 573 | |
| 574 | Capability: basic |
| 575 | Architectures: x86 |
| 576 | Type: vcpu ioctl |
| 577 | Parameters: struct kvm_msrs (in) |
| 578 | Returns: 0 on success, -1 on error |
| 579 | |
| 580 | Writes model-specific registers to the vcpu. See KVM_GET_MSRS for the |
| 581 | data structures. |
| 582 | |
| 583 | Application code should set the 'nmsrs' member (which indicates the |
| 584 | size of the entries array), and the 'index' and 'data' members of each |
| 585 | array entry. |
| 586 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 587 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 588 | 4.20 KVM_SET_CPUID |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 589 | |
| 590 | Capability: basic |
| 591 | Architectures: x86 |
| 592 | Type: vcpu ioctl |
| 593 | Parameters: struct kvm_cpuid (in) |
| 594 | Returns: 0 on success, -1 on error |
| 595 | |
| 596 | Defines the vcpu responses to the cpuid instruction. Applications |
| 597 | should use the KVM_SET_CPUID2 ioctl if available. |
| 598 | |
| 599 | |
| 600 | struct kvm_cpuid_entry { |
| 601 | __u32 function; |
| 602 | __u32 eax; |
| 603 | __u32 ebx; |
| 604 | __u32 ecx; |
| 605 | __u32 edx; |
| 606 | __u32 padding; |
| 607 | }; |
| 608 | |
| 609 | /* for KVM_SET_CPUID */ |
| 610 | struct kvm_cpuid { |
| 611 | __u32 nent; |
| 612 | __u32 padding; |
| 613 | struct kvm_cpuid_entry entries[0]; |
| 614 | }; |
| 615 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 616 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 617 | 4.21 KVM_SET_SIGNAL_MASK |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 618 | |
| 619 | Capability: basic |
James Hogan | 572e092 | 2014-07-04 15:11:33 +0100 | [diff] [blame] | 620 | Architectures: all |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 621 | Type: vcpu ioctl |
| 622 | Parameters: struct kvm_signal_mask (in) |
| 623 | Returns: 0 on success, -1 on error |
| 624 | |
| 625 | Defines which signals are blocked during execution of KVM_RUN. This |
| 626 | signal mask temporarily overrides the threads signal mask. Any |
| 627 | unblocked signal received (except SIGKILL and SIGSTOP, which retain |
| 628 | their traditional behaviour) will cause KVM_RUN to return with -EINTR. |
| 629 | |
| 630 | Note the signal will only be delivered if not blocked by the original |
| 631 | signal mask. |
| 632 | |
| 633 | /* for KVM_SET_SIGNAL_MASK */ |
| 634 | struct kvm_signal_mask { |
| 635 | __u32 len; |
| 636 | __u8 sigset[0]; |
| 637 | }; |
| 638 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 639 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 640 | 4.22 KVM_GET_FPU |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 641 | |
| 642 | Capability: basic |
| 643 | Architectures: x86 |
| 644 | Type: vcpu ioctl |
| 645 | Parameters: struct kvm_fpu (out) |
| 646 | Returns: 0 on success, -1 on error |
| 647 | |
| 648 | Reads the floating point state from the vcpu. |
| 649 | |
| 650 | /* for KVM_GET_FPU and KVM_SET_FPU */ |
| 651 | struct kvm_fpu { |
| 652 | __u8 fpr[8][16]; |
| 653 | __u16 fcw; |
| 654 | __u16 fsw; |
| 655 | __u8 ftwx; /* in fxsave format */ |
| 656 | __u8 pad1; |
| 657 | __u16 last_opcode; |
| 658 | __u64 last_ip; |
| 659 | __u64 last_dp; |
| 660 | __u8 xmm[16][16]; |
| 661 | __u32 mxcsr; |
| 662 | __u32 pad2; |
| 663 | }; |
| 664 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 665 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 666 | 4.23 KVM_SET_FPU |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 667 | |
| 668 | Capability: basic |
| 669 | Architectures: x86 |
| 670 | Type: vcpu ioctl |
| 671 | Parameters: struct kvm_fpu (in) |
| 672 | Returns: 0 on success, -1 on error |
| 673 | |
| 674 | Writes the floating point state to the vcpu. |
| 675 | |
| 676 | /* for KVM_GET_FPU and KVM_SET_FPU */ |
| 677 | struct kvm_fpu { |
| 678 | __u8 fpr[8][16]; |
| 679 | __u16 fcw; |
| 680 | __u16 fsw; |
| 681 | __u8 ftwx; /* in fxsave format */ |
| 682 | __u8 pad1; |
| 683 | __u16 last_opcode; |
| 684 | __u64 last_ip; |
| 685 | __u64 last_dp; |
| 686 | __u8 xmm[16][16]; |
| 687 | __u32 mxcsr; |
| 688 | __u32 pad2; |
| 689 | }; |
| 690 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 691 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 692 | 4.24 KVM_CREATE_IRQCHIP |
Avi Kivity | 5dadbfd | 2009-08-23 17:08:04 +0300 | [diff] [blame] | 693 | |
Cornelia Huck | 8422359 | 2013-07-15 13:36:01 +0200 | [diff] [blame] | 694 | Capability: KVM_CAP_IRQCHIP, KVM_CAP_S390_IRQCHIP (s390) |
Tiejun Chen | c32a427 | 2014-11-20 11:07:18 +0100 | [diff] [blame] | 695 | Architectures: x86, ARM, arm64, s390 |
Avi Kivity | 5dadbfd | 2009-08-23 17:08:04 +0300 | [diff] [blame] | 696 | Type: vm ioctl |
| 697 | Parameters: none |
| 698 | Returns: 0 on success, -1 on error |
| 699 | |
Andre Przywara | ac3d373 | 2014-06-03 10:26:30 +0200 | [diff] [blame] | 700 | Creates an interrupt controller model in the kernel. |
| 701 | On x86, creates a virtual ioapic, a virtual PIC (two PICs, nested), and sets up |
| 702 | future vcpus to have a local APIC. IRQ routing for GSIs 0-15 is set to both |
| 703 | PIC and IOAPIC; GSI 16-23 only go to the IOAPIC. |
| 704 | On ARM/arm64, a GICv2 is created. Any other GIC versions require the usage of |
| 705 | KVM_CREATE_DEVICE, which also supports creating a GICv2. Using |
| 706 | KVM_CREATE_DEVICE is preferred over KVM_CREATE_IRQCHIP for GICv2. |
| 707 | On s390, a dummy irq routing table is created. |
Cornelia Huck | 8422359 | 2013-07-15 13:36:01 +0200 | [diff] [blame] | 708 | |
| 709 | Note that on s390 the KVM_CAP_S390_IRQCHIP vm capability needs to be enabled |
| 710 | before KVM_CREATE_IRQCHIP can be used. |
Avi Kivity | 5dadbfd | 2009-08-23 17:08:04 +0300 | [diff] [blame] | 711 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 712 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 713 | 4.25 KVM_IRQ_LINE |
Avi Kivity | 5dadbfd | 2009-08-23 17:08:04 +0300 | [diff] [blame] | 714 | |
| 715 | Capability: KVM_CAP_IRQCHIP |
Tiejun Chen | c32a427 | 2014-11-20 11:07:18 +0100 | [diff] [blame] | 716 | Architectures: x86, arm, arm64 |
Avi Kivity | 5dadbfd | 2009-08-23 17:08:04 +0300 | [diff] [blame] | 717 | Type: vm ioctl |
| 718 | Parameters: struct kvm_irq_level |
| 719 | Returns: 0 on success, -1 on error |
| 720 | |
| 721 | Sets the level of a GSI input to the interrupt controller model in the kernel. |
Christoffer Dall | 86ce853 | 2013-01-20 18:28:08 -0500 | [diff] [blame] | 722 | On some architectures it is required that an interrupt controller model has |
| 723 | been previously created with KVM_CREATE_IRQCHIP. Note that edge-triggered |
| 724 | interrupts require the level to be set to 1 and then back to 0. |
| 725 | |
Gabriel L. Somlo | 100943c | 2014-02-27 23:06:17 -0500 | [diff] [blame] | 726 | On real hardware, interrupt pins can be active-low or active-high. This |
| 727 | does not matter for the level field of struct kvm_irq_level: 1 always |
| 728 | means active (asserted), 0 means inactive (deasserted). |
| 729 | |
| 730 | x86 allows the operating system to program the interrupt polarity |
| 731 | (active-low/active-high) for level-triggered interrupts, and KVM used |
| 732 | to consider the polarity. However, due to bitrot in the handling of |
| 733 | active-low interrupts, the above convention is now valid on x86 too. |
| 734 | This is signaled by KVM_CAP_X86_IOAPIC_POLARITY_IGNORED. Userspace |
| 735 | should not present interrupts to the guest as active-low unless this |
| 736 | capability is present (or unless it is not using the in-kernel irqchip, |
| 737 | of course). |
| 738 | |
| 739 | |
Marc Zyngier | 379e04c7 | 2013-04-02 17:46:31 +0100 | [diff] [blame] | 740 | ARM/arm64 can signal an interrupt either at the CPU level, or at the |
| 741 | in-kernel irqchip (GIC), and for in-kernel irqchip can tell the GIC to |
| 742 | use PPIs designated for specific cpus. The irq field is interpreted |
| 743 | like this: |
Christoffer Dall | 86ce853 | 2013-01-20 18:28:08 -0500 | [diff] [blame] | 744 | |
| 745 | bits: | 31 ... 24 | 23 ... 16 | 15 ... 0 | |
| 746 | field: | irq_type | vcpu_index | irq_id | |
| 747 | |
| 748 | The irq_type field has the following values: |
| 749 | - irq_type[0]: out-of-kernel GIC: irq_id 0 is IRQ, irq_id 1 is FIQ |
| 750 | - irq_type[1]: in-kernel GIC: SPI, irq_id between 32 and 1019 (incl.) |
| 751 | (the vcpu_index field is ignored) |
| 752 | - irq_type[2]: in-kernel GIC: PPI, irq_id between 16 and 31 (incl.) |
| 753 | |
| 754 | (The irq_id field thus corresponds nicely to the IRQ ID in the ARM GIC specs) |
| 755 | |
Gabriel L. Somlo | 100943c | 2014-02-27 23:06:17 -0500 | [diff] [blame] | 756 | In both cases, level is used to assert/deassert the line. |
Avi Kivity | 5dadbfd | 2009-08-23 17:08:04 +0300 | [diff] [blame] | 757 | |
| 758 | struct kvm_irq_level { |
| 759 | union { |
| 760 | __u32 irq; /* GSI */ |
| 761 | __s32 status; /* not used for KVM_IRQ_LEVEL */ |
| 762 | }; |
| 763 | __u32 level; /* 0 or 1 */ |
| 764 | }; |
| 765 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 766 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 767 | 4.26 KVM_GET_IRQCHIP |
Avi Kivity | 5dadbfd | 2009-08-23 17:08:04 +0300 | [diff] [blame] | 768 | |
| 769 | Capability: KVM_CAP_IRQCHIP |
Tiejun Chen | c32a427 | 2014-11-20 11:07:18 +0100 | [diff] [blame] | 770 | Architectures: x86 |
Avi Kivity | 5dadbfd | 2009-08-23 17:08:04 +0300 | [diff] [blame] | 771 | Type: vm ioctl |
| 772 | Parameters: struct kvm_irqchip (in/out) |
| 773 | Returns: 0 on success, -1 on error |
| 774 | |
| 775 | Reads the state of a kernel interrupt controller created with |
| 776 | KVM_CREATE_IRQCHIP into a buffer provided by the caller. |
| 777 | |
| 778 | struct kvm_irqchip { |
| 779 | __u32 chip_id; /* 0 = PIC1, 1 = PIC2, 2 = IOAPIC */ |
| 780 | __u32 pad; |
| 781 | union { |
| 782 | char dummy[512]; /* reserving space */ |
| 783 | struct kvm_pic_state pic; |
| 784 | struct kvm_ioapic_state ioapic; |
| 785 | } chip; |
| 786 | }; |
| 787 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 788 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 789 | 4.27 KVM_SET_IRQCHIP |
Avi Kivity | 5dadbfd | 2009-08-23 17:08:04 +0300 | [diff] [blame] | 790 | |
| 791 | Capability: KVM_CAP_IRQCHIP |
Tiejun Chen | c32a427 | 2014-11-20 11:07:18 +0100 | [diff] [blame] | 792 | Architectures: x86 |
Avi Kivity | 5dadbfd | 2009-08-23 17:08:04 +0300 | [diff] [blame] | 793 | Type: vm ioctl |
| 794 | Parameters: struct kvm_irqchip (in) |
| 795 | Returns: 0 on success, -1 on error |
| 796 | |
| 797 | Sets the state of a kernel interrupt controller created with |
| 798 | KVM_CREATE_IRQCHIP from a buffer provided by the caller. |
| 799 | |
| 800 | struct kvm_irqchip { |
| 801 | __u32 chip_id; /* 0 = PIC1, 1 = PIC2, 2 = IOAPIC */ |
| 802 | __u32 pad; |
| 803 | union { |
| 804 | char dummy[512]; /* reserving space */ |
| 805 | struct kvm_pic_state pic; |
| 806 | struct kvm_ioapic_state ioapic; |
| 807 | } chip; |
| 808 | }; |
| 809 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 810 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 811 | 4.28 KVM_XEN_HVM_CONFIG |
Ed Swierk | ffde22a | 2009-10-15 15:21:43 -0700 | [diff] [blame] | 812 | |
| 813 | Capability: KVM_CAP_XEN_HVM |
| 814 | Architectures: x86 |
| 815 | Type: vm ioctl |
| 816 | Parameters: struct kvm_xen_hvm_config (in) |
| 817 | Returns: 0 on success, -1 on error |
| 818 | |
| 819 | Sets the MSR that the Xen HVM guest uses to initialize its hypercall |
| 820 | page, and provides the starting address and size of the hypercall |
| 821 | blobs in userspace. When the guest writes the MSR, kvm copies one |
| 822 | page of a blob (32- or 64-bit, depending on the vcpu mode) to guest |
| 823 | memory. |
| 824 | |
| 825 | struct kvm_xen_hvm_config { |
| 826 | __u32 flags; |
| 827 | __u32 msr; |
| 828 | __u64 blob_addr_32; |
| 829 | __u64 blob_addr_64; |
| 830 | __u8 blob_size_32; |
| 831 | __u8 blob_size_64; |
| 832 | __u8 pad2[30]; |
| 833 | }; |
| 834 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 835 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 836 | 4.29 KVM_GET_CLOCK |
Glauber Costa | afbcf7a | 2009-10-16 15:28:36 -0400 | [diff] [blame] | 837 | |
| 838 | Capability: KVM_CAP_ADJUST_CLOCK |
| 839 | Architectures: x86 |
| 840 | Type: vm ioctl |
| 841 | Parameters: struct kvm_clock_data (out) |
| 842 | Returns: 0 on success, -1 on error |
| 843 | |
| 844 | Gets the current timestamp of kvmclock as seen by the current guest. In |
| 845 | conjunction with KVM_SET_CLOCK, it is used to ensure monotonicity on scenarios |
| 846 | such as migration. |
| 847 | |
Paolo Bonzini | e3fd9a9 | 2016-11-09 17:48:15 +0100 | [diff] [blame] | 848 | When KVM_CAP_ADJUST_CLOCK is passed to KVM_CHECK_EXTENSION, it returns the |
| 849 | set of bits that KVM can return in struct kvm_clock_data's flag member. |
| 850 | |
| 851 | The only flag defined now is KVM_CLOCK_TSC_STABLE. If set, the returned |
| 852 | value is the exact kvmclock value seen by all VCPUs at the instant |
| 853 | when KVM_GET_CLOCK was called. If clear, the returned value is simply |
| 854 | CLOCK_MONOTONIC plus a constant offset; the offset can be modified |
| 855 | with KVM_SET_CLOCK. KVM will try to make all VCPUs follow this clock, |
| 856 | but the exact value read by each VCPU could differ, because the host |
| 857 | TSC is not stable. |
| 858 | |
Glauber Costa | afbcf7a | 2009-10-16 15:28:36 -0400 | [diff] [blame] | 859 | struct kvm_clock_data { |
| 860 | __u64 clock; /* kvmclock current value */ |
| 861 | __u32 flags; |
| 862 | __u32 pad[9]; |
| 863 | }; |
| 864 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 865 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 866 | 4.30 KVM_SET_CLOCK |
Glauber Costa | afbcf7a | 2009-10-16 15:28:36 -0400 | [diff] [blame] | 867 | |
| 868 | Capability: KVM_CAP_ADJUST_CLOCK |
| 869 | Architectures: x86 |
| 870 | Type: vm ioctl |
| 871 | Parameters: struct kvm_clock_data (in) |
| 872 | Returns: 0 on success, -1 on error |
| 873 | |
Wu Fengguang | 2044892d | 2009-12-24 09:04:16 +0800 | [diff] [blame] | 874 | Sets the current timestamp of kvmclock to the value specified in its parameter. |
Glauber Costa | afbcf7a | 2009-10-16 15:28:36 -0400 | [diff] [blame] | 875 | In conjunction with KVM_GET_CLOCK, it is used to ensure monotonicity on scenarios |
| 876 | such as migration. |
| 877 | |
| 878 | struct kvm_clock_data { |
| 879 | __u64 clock; /* kvmclock current value */ |
| 880 | __u32 flags; |
| 881 | __u32 pad[9]; |
| 882 | }; |
| 883 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 884 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 885 | 4.31 KVM_GET_VCPU_EVENTS |
Jan Kiszka | 3cfc309 | 2009-11-12 01:04:25 +0100 | [diff] [blame] | 886 | |
| 887 | Capability: KVM_CAP_VCPU_EVENTS |
Jan Kiszka | 48005f6 | 2010-02-19 19:38:07 +0100 | [diff] [blame] | 888 | Extended by: KVM_CAP_INTR_SHADOW |
James Morse | b0960b9 | 2018-07-19 16:24:25 +0100 | [diff] [blame] | 889 | Architectures: x86, arm, arm64 |
Dongjiu Geng | b7b27fa | 2018-07-19 16:24:22 +0100 | [diff] [blame] | 890 | Type: vcpu ioctl |
Jan Kiszka | 3cfc309 | 2009-11-12 01:04:25 +0100 | [diff] [blame] | 891 | Parameters: struct kvm_vcpu_event (out) |
| 892 | Returns: 0 on success, -1 on error |
| 893 | |
Dongjiu Geng | b7b27fa | 2018-07-19 16:24:22 +0100 | [diff] [blame] | 894 | X86: |
| 895 | |
Jan Kiszka | 3cfc309 | 2009-11-12 01:04:25 +0100 | [diff] [blame] | 896 | Gets currently pending exceptions, interrupts, and NMIs as well as related |
| 897 | states of the vcpu. |
| 898 | |
| 899 | struct kvm_vcpu_events { |
| 900 | struct { |
| 901 | __u8 injected; |
| 902 | __u8 nr; |
| 903 | __u8 has_error_code; |
Jim Mattson | 59073aa | 2018-10-16 14:29:20 -0700 | [diff] [blame] | 904 | __u8 pending; |
Jan Kiszka | 3cfc309 | 2009-11-12 01:04:25 +0100 | [diff] [blame] | 905 | __u32 error_code; |
| 906 | } exception; |
| 907 | struct { |
| 908 | __u8 injected; |
| 909 | __u8 nr; |
| 910 | __u8 soft; |
Jan Kiszka | 48005f6 | 2010-02-19 19:38:07 +0100 | [diff] [blame] | 911 | __u8 shadow; |
Jan Kiszka | 3cfc309 | 2009-11-12 01:04:25 +0100 | [diff] [blame] | 912 | } interrupt; |
| 913 | struct { |
| 914 | __u8 injected; |
| 915 | __u8 pending; |
| 916 | __u8 masked; |
| 917 | __u8 pad; |
| 918 | } nmi; |
| 919 | __u32 sipi_vector; |
Jan Kiszka | dab4b91 | 2009-12-06 18:24:15 +0100 | [diff] [blame] | 920 | __u32 flags; |
Paolo Bonzini | f077825 | 2015-04-01 15:06:40 +0200 | [diff] [blame] | 921 | struct { |
| 922 | __u8 smm; |
| 923 | __u8 pending; |
| 924 | __u8 smm_inside_nmi; |
| 925 | __u8 latched_init; |
| 926 | } smi; |
Jim Mattson | 59073aa | 2018-10-16 14:29:20 -0700 | [diff] [blame] | 927 | __u8 reserved[27]; |
| 928 | __u8 exception_has_payload; |
| 929 | __u64 exception_payload; |
Jan Kiszka | 3cfc309 | 2009-11-12 01:04:25 +0100 | [diff] [blame] | 930 | }; |
| 931 | |
Jim Mattson | 59073aa | 2018-10-16 14:29:20 -0700 | [diff] [blame] | 932 | The following bits are defined in the flags field: |
Jan Kiszka | 48005f6 | 2010-02-19 19:38:07 +0100 | [diff] [blame] | 933 | |
Jim Mattson | 59073aa | 2018-10-16 14:29:20 -0700 | [diff] [blame] | 934 | - KVM_VCPUEVENT_VALID_SHADOW may be set to signal that |
Paolo Bonzini | f077825 | 2015-04-01 15:06:40 +0200 | [diff] [blame] | 935 | interrupt.shadow contains a valid state. |
| 936 | |
Jim Mattson | 59073aa | 2018-10-16 14:29:20 -0700 | [diff] [blame] | 937 | - KVM_VCPUEVENT_VALID_SMM may be set to signal that smi contains a |
| 938 | valid state. |
| 939 | |
| 940 | - KVM_VCPUEVENT_VALID_PAYLOAD may be set to signal that the |
| 941 | exception_has_payload, exception_payload, and exception.pending |
| 942 | fields contain a valid state. This bit will be set whenever |
| 943 | KVM_CAP_EXCEPTION_PAYLOAD is enabled. |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 944 | |
James Morse | b0960b9 | 2018-07-19 16:24:25 +0100 | [diff] [blame] | 945 | ARM/ARM64: |
Dongjiu Geng | b7b27fa | 2018-07-19 16:24:22 +0100 | [diff] [blame] | 946 | |
| 947 | If the guest accesses a device that is being emulated by the host kernel in |
| 948 | such a way that a real device would generate a physical SError, KVM may make |
| 949 | a virtual SError pending for that VCPU. This system error interrupt remains |
| 950 | pending until the guest takes the exception by unmasking PSTATE.A. |
| 951 | |
| 952 | Running the VCPU may cause it to take a pending SError, or make an access that |
| 953 | causes an SError to become pending. The event's description is only valid while |
| 954 | the VPCU is not running. |
| 955 | |
| 956 | This API provides a way to read and write the pending 'event' state that is not |
| 957 | visible to the guest. To save, restore or migrate a VCPU the struct representing |
| 958 | the state can be read then written using this GET/SET API, along with the other |
| 959 | guest-visible registers. It is not possible to 'cancel' an SError that has been |
| 960 | made pending. |
| 961 | |
| 962 | A device being emulated in user-space may also wish to generate an SError. To do |
| 963 | this the events structure can be populated by user-space. The current state |
| 964 | should be read first, to ensure no existing SError is pending. If an existing |
| 965 | SError is pending, the architecture's 'Multiple SError interrupts' rules should |
| 966 | be followed. (2.5.3 of DDI0587.a "ARM Reliability, Availability, and |
| 967 | Serviceability (RAS) Specification"). |
| 968 | |
Dongjiu Geng | be26b3a | 2018-07-19 16:24:23 +0100 | [diff] [blame] | 969 | SError exceptions always have an ESR value. Some CPUs have the ability to |
| 970 | specify what the virtual SError's ESR value should be. These systems will |
Dongjiu Geng | 688e058 | 2018-08-20 17:39:25 -0400 | [diff] [blame] | 971 | advertise KVM_CAP_ARM_INJECT_SERROR_ESR. In this case exception.has_esr will |
Dongjiu Geng | be26b3a | 2018-07-19 16:24:23 +0100 | [diff] [blame] | 972 | always have a non-zero value when read, and the agent making an SError pending |
| 973 | should specify the ISS field in the lower 24 bits of exception.serror_esr. If |
Dongjiu Geng | 688e058 | 2018-08-20 17:39:25 -0400 | [diff] [blame] | 974 | the system supports KVM_CAP_ARM_INJECT_SERROR_ESR, but user-space sets the events |
Dongjiu Geng | be26b3a | 2018-07-19 16:24:23 +0100 | [diff] [blame] | 975 | with exception.has_esr as zero, KVM will choose an ESR. |
| 976 | |
| 977 | Specifying exception.has_esr on a system that does not support it will return |
| 978 | -EINVAL. Setting anything other than the lower 24bits of exception.serror_esr |
| 979 | will return -EINVAL. |
| 980 | |
Dongjiu Geng | b7b27fa | 2018-07-19 16:24:22 +0100 | [diff] [blame] | 981 | struct kvm_vcpu_events { |
| 982 | struct { |
| 983 | __u8 serror_pending; |
| 984 | __u8 serror_has_esr; |
| 985 | /* Align it to 8 bytes */ |
| 986 | __u8 pad[6]; |
| 987 | __u64 serror_esr; |
| 988 | } exception; |
| 989 | __u32 reserved[12]; |
| 990 | }; |
| 991 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 992 | 4.32 KVM_SET_VCPU_EVENTS |
Jan Kiszka | 3cfc309 | 2009-11-12 01:04:25 +0100 | [diff] [blame] | 993 | |
| 994 | Capability: KVM_CAP_VCPU_EVENTS |
Jan Kiszka | 48005f6 | 2010-02-19 19:38:07 +0100 | [diff] [blame] | 995 | Extended by: KVM_CAP_INTR_SHADOW |
James Morse | b0960b9 | 2018-07-19 16:24:25 +0100 | [diff] [blame] | 996 | Architectures: x86, arm, arm64 |
Dongjiu Geng | b7b27fa | 2018-07-19 16:24:22 +0100 | [diff] [blame] | 997 | Type: vcpu ioctl |
Jan Kiszka | 3cfc309 | 2009-11-12 01:04:25 +0100 | [diff] [blame] | 998 | Parameters: struct kvm_vcpu_event (in) |
| 999 | Returns: 0 on success, -1 on error |
| 1000 | |
Dongjiu Geng | b7b27fa | 2018-07-19 16:24:22 +0100 | [diff] [blame] | 1001 | X86: |
| 1002 | |
Jan Kiszka | 3cfc309 | 2009-11-12 01:04:25 +0100 | [diff] [blame] | 1003 | Set pending exceptions, interrupts, and NMIs as well as related states of the |
| 1004 | vcpu. |
| 1005 | |
| 1006 | See KVM_GET_VCPU_EVENTS for the data structure. |
| 1007 | |
Jan Kiszka | dab4b91 | 2009-12-06 18:24:15 +0100 | [diff] [blame] | 1008 | Fields that may be modified asynchronously by running VCPUs can be excluded |
Paolo Bonzini | f077825 | 2015-04-01 15:06:40 +0200 | [diff] [blame] | 1009 | from the update. These fields are nmi.pending, sipi_vector, smi.smm, |
| 1010 | smi.pending. Keep the corresponding bits in the flags field cleared to |
| 1011 | suppress overwriting the current in-kernel state. The bits are: |
Jan Kiszka | dab4b91 | 2009-12-06 18:24:15 +0100 | [diff] [blame] | 1012 | |
| 1013 | KVM_VCPUEVENT_VALID_NMI_PENDING - transfer nmi.pending to the kernel |
| 1014 | KVM_VCPUEVENT_VALID_SIPI_VECTOR - transfer sipi_vector |
Paolo Bonzini | f077825 | 2015-04-01 15:06:40 +0200 | [diff] [blame] | 1015 | KVM_VCPUEVENT_VALID_SMM - transfer the smi sub-struct. |
Jan Kiszka | dab4b91 | 2009-12-06 18:24:15 +0100 | [diff] [blame] | 1016 | |
Jan Kiszka | 48005f6 | 2010-02-19 19:38:07 +0100 | [diff] [blame] | 1017 | If KVM_CAP_INTR_SHADOW is available, KVM_VCPUEVENT_VALID_SHADOW can be set in |
| 1018 | the flags field to signal that interrupt.shadow contains a valid state and |
| 1019 | shall be written into the VCPU. |
| 1020 | |
Paolo Bonzini | f077825 | 2015-04-01 15:06:40 +0200 | [diff] [blame] | 1021 | KVM_VCPUEVENT_VALID_SMM can only be set if KVM_CAP_X86_SMM is available. |
| 1022 | |
Jim Mattson | 59073aa | 2018-10-16 14:29:20 -0700 | [diff] [blame] | 1023 | If KVM_CAP_EXCEPTION_PAYLOAD is enabled, KVM_VCPUEVENT_VALID_PAYLOAD |
| 1024 | can be set in the flags field to signal that the |
| 1025 | exception_has_payload, exception_payload, and exception.pending fields |
| 1026 | contain a valid state and shall be written into the VCPU. |
| 1027 | |
James Morse | b0960b9 | 2018-07-19 16:24:25 +0100 | [diff] [blame] | 1028 | ARM/ARM64: |
Dongjiu Geng | b7b27fa | 2018-07-19 16:24:22 +0100 | [diff] [blame] | 1029 | |
| 1030 | Set the pending SError exception state for this VCPU. It is not possible to |
| 1031 | 'cancel' an Serror that has been made pending. |
| 1032 | |
| 1033 | See KVM_GET_VCPU_EVENTS for the data structure. |
| 1034 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1035 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1036 | 4.33 KVM_GET_DEBUGREGS |
Jan Kiszka | a1efbe7 | 2010-02-15 10:45:43 +0100 | [diff] [blame] | 1037 | |
| 1038 | Capability: KVM_CAP_DEBUGREGS |
| 1039 | Architectures: x86 |
| 1040 | Type: vm ioctl |
| 1041 | Parameters: struct kvm_debugregs (out) |
| 1042 | Returns: 0 on success, -1 on error |
| 1043 | |
| 1044 | Reads debug registers from the vcpu. |
| 1045 | |
| 1046 | struct kvm_debugregs { |
| 1047 | __u64 db[4]; |
| 1048 | __u64 dr6; |
| 1049 | __u64 dr7; |
| 1050 | __u64 flags; |
| 1051 | __u64 reserved[9]; |
| 1052 | }; |
| 1053 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1054 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1055 | 4.34 KVM_SET_DEBUGREGS |
Jan Kiszka | a1efbe7 | 2010-02-15 10:45:43 +0100 | [diff] [blame] | 1056 | |
| 1057 | Capability: KVM_CAP_DEBUGREGS |
| 1058 | Architectures: x86 |
| 1059 | Type: vm ioctl |
| 1060 | Parameters: struct kvm_debugregs (in) |
| 1061 | Returns: 0 on success, -1 on error |
| 1062 | |
| 1063 | Writes debug registers into the vcpu. |
| 1064 | |
| 1065 | See KVM_GET_DEBUGREGS for the data structure. The flags field is unused |
| 1066 | yet and must be cleared on entry. |
| 1067 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1068 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1069 | 4.35 KVM_SET_USER_MEMORY_REGION |
Avi Kivity | 0f2d8f4 | 2010-03-25 12:16:48 +0200 | [diff] [blame] | 1070 | |
| 1071 | Capability: KVM_CAP_USER_MEM |
| 1072 | Architectures: all |
| 1073 | Type: vm ioctl |
| 1074 | Parameters: struct kvm_userspace_memory_region (in) |
| 1075 | Returns: 0 on success, -1 on error |
| 1076 | |
| 1077 | struct kvm_userspace_memory_region { |
| 1078 | __u32 slot; |
| 1079 | __u32 flags; |
| 1080 | __u64 guest_phys_addr; |
| 1081 | __u64 memory_size; /* bytes */ |
| 1082 | __u64 userspace_addr; /* start of the userspace allocated memory */ |
| 1083 | }; |
| 1084 | |
| 1085 | /* for kvm_memory_region::flags */ |
Xiao Guangrong | 4d8b81a | 2012-08-21 11:02:51 +0800 | [diff] [blame] | 1086 | #define KVM_MEM_LOG_DIRTY_PAGES (1UL << 0) |
| 1087 | #define KVM_MEM_READONLY (1UL << 1) |
Avi Kivity | 0f2d8f4 | 2010-03-25 12:16:48 +0200 | [diff] [blame] | 1088 | |
| 1089 | This ioctl allows the user to create or modify a guest physical memory |
| 1090 | slot. When changing an existing slot, it may be moved in the guest |
| 1091 | physical memory space, or its flags may be modified. It may not be |
| 1092 | resized. Slots may not overlap in guest physical address space. |
Linu Cherian | a677e70 | 2017-03-08 11:38:32 +0530 | [diff] [blame] | 1093 | Bits 0-15 of "slot" specifies the slot id and this value should be |
| 1094 | less than the maximum number of user memory slots supported per VM. |
| 1095 | The maximum allowed slots can be queried using KVM_CAP_NR_MEMSLOTS, |
| 1096 | if this capability is supported by the architecture. |
Avi Kivity | 0f2d8f4 | 2010-03-25 12:16:48 +0200 | [diff] [blame] | 1097 | |
Paolo Bonzini | f481b06 | 2015-05-17 17:30:37 +0200 | [diff] [blame] | 1098 | If KVM_CAP_MULTI_ADDRESS_SPACE is available, bits 16-31 of "slot" |
| 1099 | specifies the address space which is being modified. They must be |
| 1100 | less than the value that KVM_CHECK_EXTENSION returns for the |
| 1101 | KVM_CAP_MULTI_ADDRESS_SPACE capability. Slots in separate address spaces |
| 1102 | are unrelated; the restriction on overlapping slots only applies within |
| 1103 | each address space. |
| 1104 | |
Avi Kivity | 0f2d8f4 | 2010-03-25 12:16:48 +0200 | [diff] [blame] | 1105 | Memory for the region is taken starting at the address denoted by the |
| 1106 | field userspace_addr, which must point at user addressable memory for |
| 1107 | the entire memory slot size. Any object may back this memory, including |
| 1108 | anonymous memory, ordinary files, and hugetlbfs. |
| 1109 | |
| 1110 | It is recommended that the lower 21 bits of guest_phys_addr and userspace_addr |
| 1111 | be identical. This allows large pages in the guest to be backed by large |
| 1112 | pages in the host. |
| 1113 | |
Takuya Yoshikawa | 75d61fb | 2013-01-30 19:40:41 +0900 | [diff] [blame] | 1114 | The flags field supports two flags: KVM_MEM_LOG_DIRTY_PAGES and |
| 1115 | KVM_MEM_READONLY. The former can be set to instruct KVM to keep track of |
| 1116 | writes to memory within the slot. See KVM_GET_DIRTY_LOG ioctl to know how to |
| 1117 | use it. The latter can be set, if KVM_CAP_READONLY_MEM capability allows it, |
| 1118 | to make a new slot read-only. In this case, writes to this memory will be |
| 1119 | posted to userspace as KVM_EXIT_MMIO exits. |
Avi Kivity | 0f2d8f4 | 2010-03-25 12:16:48 +0200 | [diff] [blame] | 1120 | |
Jan Kiszka | 7efd8fa | 2012-09-07 13:17:47 +0200 | [diff] [blame] | 1121 | When the KVM_CAP_SYNC_MMU capability is available, changes in the backing of |
| 1122 | the memory region are automatically reflected into the guest. For example, an |
| 1123 | mmap() that affects the region will be made visible immediately. Another |
| 1124 | example is madvise(MADV_DROP). |
Avi Kivity | 0f2d8f4 | 2010-03-25 12:16:48 +0200 | [diff] [blame] | 1125 | |
| 1126 | It is recommended to use this API instead of the KVM_SET_MEMORY_REGION ioctl. |
| 1127 | The KVM_SET_MEMORY_REGION does not allow fine grained control over memory |
| 1128 | allocation and is deprecated. |
Jan Kiszka | 3cfc309 | 2009-11-12 01:04:25 +0100 | [diff] [blame] | 1129 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1130 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1131 | 4.36 KVM_SET_TSS_ADDR |
Avi Kivity | 8a5416d | 2010-03-25 12:27:30 +0200 | [diff] [blame] | 1132 | |
| 1133 | Capability: KVM_CAP_SET_TSS_ADDR |
| 1134 | Architectures: x86 |
| 1135 | Type: vm ioctl |
| 1136 | Parameters: unsigned long tss_address (in) |
| 1137 | Returns: 0 on success, -1 on error |
| 1138 | |
| 1139 | This ioctl defines the physical address of a three-page region in the guest |
| 1140 | physical address space. The region must be within the first 4GB of the |
| 1141 | guest physical address space and must not conflict with any memory slot |
| 1142 | or any mmio address. The guest may malfunction if it accesses this memory |
| 1143 | region. |
| 1144 | |
| 1145 | This ioctl is required on Intel-based hosts. This is needed on Intel hardware |
| 1146 | because of a quirk in the virtualization implementation (see the internals |
| 1147 | documentation when it pops into existence). |
| 1148 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1149 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1150 | 4.37 KVM_ENABLE_CAP |
Alexander Graf | 71fbfd5 | 2010-03-24 21:48:29 +0100 | [diff] [blame] | 1151 | |
Paolo Bonzini | e5d83c7 | 2017-02-16 10:40:56 +0100 | [diff] [blame] | 1152 | Capability: KVM_CAP_ENABLE_CAP |
| 1153 | Architectures: mips, ppc, s390 |
| 1154 | Type: vcpu ioctl |
| 1155 | Parameters: struct kvm_enable_cap (in) |
| 1156 | Returns: 0 on success; -1 on error |
| 1157 | |
| 1158 | Capability: KVM_CAP_ENABLE_CAP_VM |
| 1159 | Architectures: all |
| 1160 | Type: vcpu ioctl |
Alexander Graf | 71fbfd5 | 2010-03-24 21:48:29 +0100 | [diff] [blame] | 1161 | Parameters: struct kvm_enable_cap (in) |
| 1162 | Returns: 0 on success; -1 on error |
| 1163 | |
| 1164 | +Not all extensions are enabled by default. Using this ioctl the application |
| 1165 | can enable an extension, making it available to the guest. |
| 1166 | |
| 1167 | On systems that do not support this ioctl, it always fails. On systems that |
| 1168 | do support it, it only works for extensions that are supported for enablement. |
| 1169 | |
| 1170 | To check if a capability can be enabled, the KVM_CHECK_EXTENSION ioctl should |
| 1171 | be used. |
| 1172 | |
| 1173 | struct kvm_enable_cap { |
| 1174 | /* in */ |
| 1175 | __u32 cap; |
| 1176 | |
| 1177 | The capability that is supposed to get enabled. |
| 1178 | |
| 1179 | __u32 flags; |
| 1180 | |
| 1181 | A bitfield indicating future enhancements. Has to be 0 for now. |
| 1182 | |
| 1183 | __u64 args[4]; |
| 1184 | |
| 1185 | Arguments for enabling a feature. If a feature needs initial values to |
| 1186 | function properly, this is the place to put them. |
| 1187 | |
| 1188 | __u8 pad[64]; |
| 1189 | }; |
| 1190 | |
Cornelia Huck | d938dc5 | 2013-10-23 18:26:34 +0200 | [diff] [blame] | 1191 | The vcpu ioctl should be used for vcpu-specific capabilities, the vm ioctl |
| 1192 | for vm-wide capabilities. |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1193 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1194 | 4.38 KVM_GET_MP_STATE |
Avi Kivity | b843f06 | 2010-04-25 15:51:46 +0300 | [diff] [blame] | 1195 | |
| 1196 | Capability: KVM_CAP_MP_STATE |
Alex Bennée | ecccf0c | 2015-03-13 17:02:52 +0000 | [diff] [blame] | 1197 | Architectures: x86, s390, arm, arm64 |
Avi Kivity | b843f06 | 2010-04-25 15:51:46 +0300 | [diff] [blame] | 1198 | Type: vcpu ioctl |
| 1199 | Parameters: struct kvm_mp_state (out) |
| 1200 | Returns: 0 on success; -1 on error |
| 1201 | |
| 1202 | struct kvm_mp_state { |
| 1203 | __u32 mp_state; |
| 1204 | }; |
| 1205 | |
| 1206 | Returns the vcpu's current "multiprocessing state" (though also valid on |
| 1207 | uniprocessor guests). |
| 1208 | |
| 1209 | Possible values are: |
| 1210 | |
Alex Bennée | ecccf0c | 2015-03-13 17:02:52 +0000 | [diff] [blame] | 1211 | - KVM_MP_STATE_RUNNABLE: the vcpu is currently running [x86,arm/arm64] |
Avi Kivity | b843f06 | 2010-04-25 15:51:46 +0300 | [diff] [blame] | 1212 | - KVM_MP_STATE_UNINITIALIZED: the vcpu is an application processor (AP) |
Tiejun Chen | c32a427 | 2014-11-20 11:07:18 +0100 | [diff] [blame] | 1213 | which has not yet received an INIT signal [x86] |
Avi Kivity | b843f06 | 2010-04-25 15:51:46 +0300 | [diff] [blame] | 1214 | - KVM_MP_STATE_INIT_RECEIVED: the vcpu has received an INIT signal, and is |
Tiejun Chen | c32a427 | 2014-11-20 11:07:18 +0100 | [diff] [blame] | 1215 | now ready for a SIPI [x86] |
Avi Kivity | b843f06 | 2010-04-25 15:51:46 +0300 | [diff] [blame] | 1216 | - KVM_MP_STATE_HALTED: the vcpu has executed a HLT instruction and |
Tiejun Chen | c32a427 | 2014-11-20 11:07:18 +0100 | [diff] [blame] | 1217 | is waiting for an interrupt [x86] |
Avi Kivity | b843f06 | 2010-04-25 15:51:46 +0300 | [diff] [blame] | 1218 | - KVM_MP_STATE_SIPI_RECEIVED: the vcpu has just received a SIPI (vector |
Tiejun Chen | c32a427 | 2014-11-20 11:07:18 +0100 | [diff] [blame] | 1219 | accessible via KVM_GET_VCPU_EVENTS) [x86] |
Alex Bennée | ecccf0c | 2015-03-13 17:02:52 +0000 | [diff] [blame] | 1220 | - KVM_MP_STATE_STOPPED: the vcpu is stopped [s390,arm/arm64] |
David Hildenbrand | 6352e4d | 2014-04-10 17:35:00 +0200 | [diff] [blame] | 1221 | - KVM_MP_STATE_CHECK_STOP: the vcpu is in a special error state [s390] |
| 1222 | - KVM_MP_STATE_OPERATING: the vcpu is operating (running or halted) |
| 1223 | [s390] |
| 1224 | - KVM_MP_STATE_LOAD: the vcpu is in a special load/startup state |
| 1225 | [s390] |
Avi Kivity | b843f06 | 2010-04-25 15:51:46 +0300 | [diff] [blame] | 1226 | |
Tiejun Chen | c32a427 | 2014-11-20 11:07:18 +0100 | [diff] [blame] | 1227 | On x86, this ioctl is only useful after KVM_CREATE_IRQCHIP. Without an |
David Hildenbrand | 0b4820d | 2014-05-12 16:05:13 +0200 | [diff] [blame] | 1228 | in-kernel irqchip, the multiprocessing state must be maintained by userspace on |
| 1229 | these architectures. |
Avi Kivity | b843f06 | 2010-04-25 15:51:46 +0300 | [diff] [blame] | 1230 | |
Alex Bennée | ecccf0c | 2015-03-13 17:02:52 +0000 | [diff] [blame] | 1231 | For arm/arm64: |
| 1232 | |
| 1233 | The only states that are valid are KVM_MP_STATE_STOPPED and |
| 1234 | KVM_MP_STATE_RUNNABLE which reflect if the vcpu is paused or not. |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1235 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1236 | 4.39 KVM_SET_MP_STATE |
Avi Kivity | b843f06 | 2010-04-25 15:51:46 +0300 | [diff] [blame] | 1237 | |
| 1238 | Capability: KVM_CAP_MP_STATE |
Alex Bennée | ecccf0c | 2015-03-13 17:02:52 +0000 | [diff] [blame] | 1239 | Architectures: x86, s390, arm, arm64 |
Avi Kivity | b843f06 | 2010-04-25 15:51:46 +0300 | [diff] [blame] | 1240 | Type: vcpu ioctl |
| 1241 | Parameters: struct kvm_mp_state (in) |
| 1242 | Returns: 0 on success; -1 on error |
| 1243 | |
| 1244 | Sets the vcpu's current "multiprocessing state"; see KVM_GET_MP_STATE for |
| 1245 | arguments. |
| 1246 | |
Tiejun Chen | c32a427 | 2014-11-20 11:07:18 +0100 | [diff] [blame] | 1247 | On x86, this ioctl is only useful after KVM_CREATE_IRQCHIP. Without an |
David Hildenbrand | 0b4820d | 2014-05-12 16:05:13 +0200 | [diff] [blame] | 1248 | in-kernel irqchip, the multiprocessing state must be maintained by userspace on |
| 1249 | these architectures. |
Avi Kivity | b843f06 | 2010-04-25 15:51:46 +0300 | [diff] [blame] | 1250 | |
Alex Bennée | ecccf0c | 2015-03-13 17:02:52 +0000 | [diff] [blame] | 1251 | For arm/arm64: |
| 1252 | |
| 1253 | The only states that are valid are KVM_MP_STATE_STOPPED and |
| 1254 | KVM_MP_STATE_RUNNABLE which reflect if the vcpu should be paused or not. |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1255 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1256 | 4.40 KVM_SET_IDENTITY_MAP_ADDR |
Avi Kivity | 47dbb84 | 2010-04-29 12:08:56 +0300 | [diff] [blame] | 1257 | |
| 1258 | Capability: KVM_CAP_SET_IDENTITY_MAP_ADDR |
| 1259 | Architectures: x86 |
| 1260 | Type: vm ioctl |
| 1261 | Parameters: unsigned long identity (in) |
| 1262 | Returns: 0 on success, -1 on error |
| 1263 | |
| 1264 | This ioctl defines the physical address of a one-page region in the guest |
| 1265 | physical address space. The region must be within the first 4GB of the |
| 1266 | guest physical address space and must not conflict with any memory slot |
| 1267 | or any mmio address. The guest may malfunction if it accesses this memory |
| 1268 | region. |
| 1269 | |
David Hildenbrand | 726b99c | 2017-08-24 20:51:35 +0200 | [diff] [blame] | 1270 | Setting the address to 0 will result in resetting the address to its default |
| 1271 | (0xfffbc000). |
| 1272 | |
Avi Kivity | 47dbb84 | 2010-04-29 12:08:56 +0300 | [diff] [blame] | 1273 | This ioctl is required on Intel-based hosts. This is needed on Intel hardware |
| 1274 | because of a quirk in the virtualization implementation (see the internals |
| 1275 | documentation when it pops into existence). |
| 1276 | |
David Hildenbrand | 1af1ac9 | 2017-08-24 20:51:36 +0200 | [diff] [blame] | 1277 | Fails if any VCPU has already been created. |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1278 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1279 | 4.41 KVM_SET_BOOT_CPU_ID |
Avi Kivity | 57bc24c | 2010-04-29 12:12:57 +0300 | [diff] [blame] | 1280 | |
| 1281 | Capability: KVM_CAP_SET_BOOT_CPU_ID |
Tiejun Chen | c32a427 | 2014-11-20 11:07:18 +0100 | [diff] [blame] | 1282 | Architectures: x86 |
Avi Kivity | 57bc24c | 2010-04-29 12:12:57 +0300 | [diff] [blame] | 1283 | Type: vm ioctl |
| 1284 | Parameters: unsigned long vcpu_id |
| 1285 | Returns: 0 on success, -1 on error |
| 1286 | |
| 1287 | Define which vcpu is the Bootstrap Processor (BSP). Values are the same |
| 1288 | as the vcpu id in KVM_CREATE_VCPU. If this ioctl is not called, the default |
| 1289 | is vcpu 0. |
| 1290 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1291 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1292 | 4.42 KVM_GET_XSAVE |
Sheng Yang | 2d5b5a6 | 2010-06-13 17:29:39 +0800 | [diff] [blame] | 1293 | |
| 1294 | Capability: KVM_CAP_XSAVE |
| 1295 | Architectures: x86 |
| 1296 | Type: vcpu ioctl |
| 1297 | Parameters: struct kvm_xsave (out) |
| 1298 | Returns: 0 on success, -1 on error |
| 1299 | |
| 1300 | struct kvm_xsave { |
| 1301 | __u32 region[1024]; |
| 1302 | }; |
| 1303 | |
| 1304 | This ioctl would copy current vcpu's xsave struct to the userspace. |
| 1305 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1306 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1307 | 4.43 KVM_SET_XSAVE |
Sheng Yang | 2d5b5a6 | 2010-06-13 17:29:39 +0800 | [diff] [blame] | 1308 | |
| 1309 | Capability: KVM_CAP_XSAVE |
| 1310 | Architectures: x86 |
| 1311 | Type: vcpu ioctl |
| 1312 | Parameters: struct kvm_xsave (in) |
| 1313 | Returns: 0 on success, -1 on error |
| 1314 | |
| 1315 | struct kvm_xsave { |
| 1316 | __u32 region[1024]; |
| 1317 | }; |
| 1318 | |
| 1319 | This ioctl would copy userspace's xsave struct to the kernel. |
| 1320 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1321 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1322 | 4.44 KVM_GET_XCRS |
Sheng Yang | 2d5b5a6 | 2010-06-13 17:29:39 +0800 | [diff] [blame] | 1323 | |
| 1324 | Capability: KVM_CAP_XCRS |
| 1325 | Architectures: x86 |
| 1326 | Type: vcpu ioctl |
| 1327 | Parameters: struct kvm_xcrs (out) |
| 1328 | Returns: 0 on success, -1 on error |
| 1329 | |
| 1330 | struct kvm_xcr { |
| 1331 | __u32 xcr; |
| 1332 | __u32 reserved; |
| 1333 | __u64 value; |
| 1334 | }; |
| 1335 | |
| 1336 | struct kvm_xcrs { |
| 1337 | __u32 nr_xcrs; |
| 1338 | __u32 flags; |
| 1339 | struct kvm_xcr xcrs[KVM_MAX_XCRS]; |
| 1340 | __u64 padding[16]; |
| 1341 | }; |
| 1342 | |
| 1343 | This ioctl would copy current vcpu's xcrs to the userspace. |
| 1344 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1345 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1346 | 4.45 KVM_SET_XCRS |
Sheng Yang | 2d5b5a6 | 2010-06-13 17:29:39 +0800 | [diff] [blame] | 1347 | |
| 1348 | Capability: KVM_CAP_XCRS |
| 1349 | Architectures: x86 |
| 1350 | Type: vcpu ioctl |
| 1351 | Parameters: struct kvm_xcrs (in) |
| 1352 | Returns: 0 on success, -1 on error |
| 1353 | |
| 1354 | struct kvm_xcr { |
| 1355 | __u32 xcr; |
| 1356 | __u32 reserved; |
| 1357 | __u64 value; |
| 1358 | }; |
| 1359 | |
| 1360 | struct kvm_xcrs { |
| 1361 | __u32 nr_xcrs; |
| 1362 | __u32 flags; |
| 1363 | struct kvm_xcr xcrs[KVM_MAX_XCRS]; |
| 1364 | __u64 padding[16]; |
| 1365 | }; |
| 1366 | |
| 1367 | This ioctl would set vcpu's xcr to the value userspace specified. |
| 1368 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1369 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1370 | 4.46 KVM_GET_SUPPORTED_CPUID |
Avi Kivity | d153513 | 2010-07-14 09:45:21 +0300 | [diff] [blame] | 1371 | |
| 1372 | Capability: KVM_CAP_EXT_CPUID |
| 1373 | Architectures: x86 |
| 1374 | Type: system ioctl |
| 1375 | Parameters: struct kvm_cpuid2 (in/out) |
| 1376 | Returns: 0 on success, -1 on error |
| 1377 | |
| 1378 | struct kvm_cpuid2 { |
| 1379 | __u32 nent; |
| 1380 | __u32 padding; |
| 1381 | struct kvm_cpuid_entry2 entries[0]; |
| 1382 | }; |
| 1383 | |
Borislav Petkov | 9c15bb1 | 2013-09-22 16:44:50 +0200 | [diff] [blame] | 1384 | #define KVM_CPUID_FLAG_SIGNIFCANT_INDEX BIT(0) |
| 1385 | #define KVM_CPUID_FLAG_STATEFUL_FUNC BIT(1) |
| 1386 | #define KVM_CPUID_FLAG_STATE_READ_NEXT BIT(2) |
Avi Kivity | d153513 | 2010-07-14 09:45:21 +0300 | [diff] [blame] | 1387 | |
| 1388 | struct kvm_cpuid_entry2 { |
| 1389 | __u32 function; |
| 1390 | __u32 index; |
| 1391 | __u32 flags; |
| 1392 | __u32 eax; |
| 1393 | __u32 ebx; |
| 1394 | __u32 ecx; |
| 1395 | __u32 edx; |
| 1396 | __u32 padding[3]; |
| 1397 | }; |
| 1398 | |
Jim Mattson | df9cb9c | 2018-05-24 11:59:54 -0700 | [diff] [blame] | 1399 | This ioctl returns x86 cpuid features which are supported by both the |
| 1400 | hardware and kvm in its default configuration. Userspace can use the |
| 1401 | information returned by this ioctl to construct cpuid information (for |
| 1402 | KVM_SET_CPUID2) that is consistent with hardware, kernel, and |
| 1403 | userspace capabilities, and with user requirements (for example, the |
| 1404 | user may wish to constrain cpuid to emulate older hardware, or for |
| 1405 | feature consistency across a cluster). |
| 1406 | |
| 1407 | Note that certain capabilities, such as KVM_CAP_X86_DISABLE_EXITS, may |
| 1408 | expose cpuid features (e.g. MONITOR) which are not supported by kvm in |
| 1409 | its default configuration. If userspace enables such capabilities, it |
| 1410 | is responsible for modifying the results of this ioctl appropriately. |
Avi Kivity | d153513 | 2010-07-14 09:45:21 +0300 | [diff] [blame] | 1411 | |
| 1412 | Userspace invokes KVM_GET_SUPPORTED_CPUID by passing a kvm_cpuid2 structure |
| 1413 | with the 'nent' field indicating the number of entries in the variable-size |
| 1414 | array 'entries'. If the number of entries is too low to describe the cpu |
| 1415 | capabilities, an error (E2BIG) is returned. If the number is too high, |
| 1416 | the 'nent' field is adjusted and an error (ENOMEM) is returned. If the |
| 1417 | number is just right, the 'nent' field is adjusted to the number of valid |
| 1418 | entries in the 'entries' array, which is then filled. |
| 1419 | |
| 1420 | The entries returned are the host cpuid as returned by the cpuid instruction, |
Avi Kivity | c39cbd2 | 2010-09-12 16:39:11 +0200 | [diff] [blame] | 1421 | with unknown or unsupported features masked out. Some features (for example, |
| 1422 | x2apic), may not be present in the host cpu, but are exposed by kvm if it can |
| 1423 | emulate them efficiently. The fields in each entry are defined as follows: |
Avi Kivity | d153513 | 2010-07-14 09:45:21 +0300 | [diff] [blame] | 1424 | |
| 1425 | function: the eax value used to obtain the entry |
| 1426 | index: the ecx value used to obtain the entry (for entries that are |
| 1427 | affected by ecx) |
| 1428 | flags: an OR of zero or more of the following: |
| 1429 | KVM_CPUID_FLAG_SIGNIFCANT_INDEX: |
| 1430 | if the index field is valid |
| 1431 | KVM_CPUID_FLAG_STATEFUL_FUNC: |
| 1432 | if cpuid for this function returns different values for successive |
| 1433 | invocations; there will be several entries with the same function, |
| 1434 | all with this flag set |
| 1435 | KVM_CPUID_FLAG_STATE_READ_NEXT: |
| 1436 | for KVM_CPUID_FLAG_STATEFUL_FUNC entries, set if this entry is |
| 1437 | the first entry to be read by a cpu |
| 1438 | eax, ebx, ecx, edx: the values returned by the cpuid instruction for |
| 1439 | this function/index combination |
| 1440 | |
Jan Kiszka | 4d25a066 | 2011-12-21 12:28:29 +0100 | [diff] [blame] | 1441 | The TSC deadline timer feature (CPUID leaf 1, ecx[24]) is always returned |
| 1442 | as false, since the feature depends on KVM_CREATE_IRQCHIP for local APIC |
| 1443 | support. Instead it is reported via |
| 1444 | |
| 1445 | ioctl(KVM_CHECK_EXTENSION, KVM_CAP_TSC_DEADLINE_TIMER) |
| 1446 | |
| 1447 | if that returns true and you use KVM_CREATE_IRQCHIP, or if you emulate the |
| 1448 | feature in userspace, then you can enable the feature for KVM_SET_CPUID2. |
| 1449 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1450 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1451 | 4.47 KVM_PPC_GET_PVINFO |
Alexander Graf | 15711e9 | 2010-07-29 14:48:08 +0200 | [diff] [blame] | 1452 | |
| 1453 | Capability: KVM_CAP_PPC_GET_PVINFO |
| 1454 | Architectures: ppc |
| 1455 | Type: vm ioctl |
| 1456 | Parameters: struct kvm_ppc_pvinfo (out) |
| 1457 | Returns: 0 on success, !0 on error |
| 1458 | |
| 1459 | struct kvm_ppc_pvinfo { |
| 1460 | __u32 flags; |
| 1461 | __u32 hcall[4]; |
| 1462 | __u8 pad[108]; |
| 1463 | }; |
| 1464 | |
| 1465 | This ioctl fetches PV specific information that need to be passed to the guest |
| 1466 | using the device tree or other means from vm context. |
| 1467 | |
Liu Yu-B13201 | 9202e07 | 2012-07-03 05:48:52 +0000 | [diff] [blame] | 1468 | The hcall array defines 4 instructions that make up a hypercall. |
Alexander Graf | 15711e9 | 2010-07-29 14:48:08 +0200 | [diff] [blame] | 1469 | |
| 1470 | If any additional field gets added to this structure later on, a bit for that |
| 1471 | additional piece of information will be set in the flags bitmap. |
| 1472 | |
Liu Yu-B13201 | 9202e07 | 2012-07-03 05:48:52 +0000 | [diff] [blame] | 1473 | The flags bitmap is defined as: |
| 1474 | |
| 1475 | /* the host supports the ePAPR idle hcall |
| 1476 | #define KVM_PPC_PVINFO_FLAGS_EV_IDLE (1<<0) |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1477 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1478 | 4.52 KVM_SET_GSI_ROUTING |
Jan Kiszka | 49f4817 | 2010-11-16 22:30:07 +0100 | [diff] [blame] | 1479 | |
| 1480 | Capability: KVM_CAP_IRQ_ROUTING |
Eric Auger | 180ae7b | 2016-07-22 16:20:41 +0000 | [diff] [blame] | 1481 | Architectures: x86 s390 arm arm64 |
Jan Kiszka | 49f4817 | 2010-11-16 22:30:07 +0100 | [diff] [blame] | 1482 | Type: vm ioctl |
| 1483 | Parameters: struct kvm_irq_routing (in) |
| 1484 | Returns: 0 on success, -1 on error |
| 1485 | |
| 1486 | Sets the GSI routing table entries, overwriting any previously set entries. |
| 1487 | |
Eric Auger | 180ae7b | 2016-07-22 16:20:41 +0000 | [diff] [blame] | 1488 | On arm/arm64, GSI routing has the following limitation: |
| 1489 | - GSI routing does not apply to KVM_IRQ_LINE but only to KVM_IRQFD. |
| 1490 | |
Jan Kiszka | 49f4817 | 2010-11-16 22:30:07 +0100 | [diff] [blame] | 1491 | struct kvm_irq_routing { |
| 1492 | __u32 nr; |
| 1493 | __u32 flags; |
| 1494 | struct kvm_irq_routing_entry entries[0]; |
| 1495 | }; |
| 1496 | |
| 1497 | No flags are specified so far, the corresponding field must be set to zero. |
| 1498 | |
| 1499 | struct kvm_irq_routing_entry { |
| 1500 | __u32 gsi; |
| 1501 | __u32 type; |
| 1502 | __u32 flags; |
| 1503 | __u32 pad; |
| 1504 | union { |
| 1505 | struct kvm_irq_routing_irqchip irqchip; |
| 1506 | struct kvm_irq_routing_msi msi; |
Cornelia Huck | 8422359 | 2013-07-15 13:36:01 +0200 | [diff] [blame] | 1507 | struct kvm_irq_routing_s390_adapter adapter; |
Andrey Smetanin | 5c919412 | 2015-11-10 15:36:34 +0300 | [diff] [blame] | 1508 | struct kvm_irq_routing_hv_sint hv_sint; |
Jan Kiszka | 49f4817 | 2010-11-16 22:30:07 +0100 | [diff] [blame] | 1509 | __u32 pad[8]; |
| 1510 | } u; |
| 1511 | }; |
| 1512 | |
| 1513 | /* gsi routing entry types */ |
| 1514 | #define KVM_IRQ_ROUTING_IRQCHIP 1 |
| 1515 | #define KVM_IRQ_ROUTING_MSI 2 |
Cornelia Huck | 8422359 | 2013-07-15 13:36:01 +0200 | [diff] [blame] | 1516 | #define KVM_IRQ_ROUTING_S390_ADAPTER 3 |
Andrey Smetanin | 5c919412 | 2015-11-10 15:36:34 +0300 | [diff] [blame] | 1517 | #define KVM_IRQ_ROUTING_HV_SINT 4 |
Jan Kiszka | 49f4817 | 2010-11-16 22:30:07 +0100 | [diff] [blame] | 1518 | |
Eric Auger | 76a10b8 | 2016-07-22 16:20:37 +0000 | [diff] [blame] | 1519 | flags: |
Paolo Bonzini | 6f49b2f | 2016-08-04 13:59:56 +0200 | [diff] [blame] | 1520 | - KVM_MSI_VALID_DEVID: used along with KVM_IRQ_ROUTING_MSI routing entry |
| 1521 | type, specifies that the devid field contains a valid value. The per-VM |
| 1522 | KVM_CAP_MSI_DEVID capability advertises the requirement to provide |
| 1523 | the device ID. If this capability is not available, userspace should |
| 1524 | never set the KVM_MSI_VALID_DEVID flag as the ioctl might fail. |
Eric Auger | 76a10b8 | 2016-07-22 16:20:37 +0000 | [diff] [blame] | 1525 | - zero otherwise |
Jan Kiszka | 49f4817 | 2010-11-16 22:30:07 +0100 | [diff] [blame] | 1526 | |
| 1527 | struct kvm_irq_routing_irqchip { |
| 1528 | __u32 irqchip; |
| 1529 | __u32 pin; |
| 1530 | }; |
| 1531 | |
| 1532 | struct kvm_irq_routing_msi { |
| 1533 | __u32 address_lo; |
| 1534 | __u32 address_hi; |
| 1535 | __u32 data; |
Eric Auger | 76a10b8 | 2016-07-22 16:20:37 +0000 | [diff] [blame] | 1536 | union { |
| 1537 | __u32 pad; |
| 1538 | __u32 devid; |
| 1539 | }; |
Jan Kiszka | 49f4817 | 2010-11-16 22:30:07 +0100 | [diff] [blame] | 1540 | }; |
| 1541 | |
Paolo Bonzini | 6f49b2f | 2016-08-04 13:59:56 +0200 | [diff] [blame] | 1542 | If KVM_MSI_VALID_DEVID is set, devid contains a unique device identifier |
| 1543 | for the device that wrote the MSI message. For PCI, this is usually a |
| 1544 | BFD identifier in the lower 16 bits. |
Eric Auger | 76a10b8 | 2016-07-22 16:20:37 +0000 | [diff] [blame] | 1545 | |
Radim Krčmář | 37131313 | 2016-07-12 22:09:27 +0200 | [diff] [blame] | 1546 | On x86, address_hi is ignored unless the KVM_X2APIC_API_USE_32BIT_IDS |
| 1547 | feature of KVM_CAP_X2APIC_API capability is enabled. If it is enabled, |
| 1548 | address_hi bits 31-8 provide bits 31-8 of the destination id. Bits 7-0 of |
| 1549 | address_hi must be zero. |
| 1550 | |
Cornelia Huck | 8422359 | 2013-07-15 13:36:01 +0200 | [diff] [blame] | 1551 | struct kvm_irq_routing_s390_adapter { |
| 1552 | __u64 ind_addr; |
| 1553 | __u64 summary_addr; |
| 1554 | __u64 ind_offset; |
| 1555 | __u32 summary_offset; |
| 1556 | __u32 adapter_id; |
| 1557 | }; |
| 1558 | |
Andrey Smetanin | 5c919412 | 2015-11-10 15:36:34 +0300 | [diff] [blame] | 1559 | struct kvm_irq_routing_hv_sint { |
| 1560 | __u32 vcpu; |
| 1561 | __u32 sint; |
| 1562 | }; |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1563 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1564 | |
| 1565 | 4.55 KVM_SET_TSC_KHZ |
Joerg Roedel | 92a1f12 | 2011-03-25 09:44:51 +0100 | [diff] [blame] | 1566 | |
| 1567 | Capability: KVM_CAP_TSC_CONTROL |
| 1568 | Architectures: x86 |
| 1569 | Type: vcpu ioctl |
| 1570 | Parameters: virtual tsc_khz |
| 1571 | Returns: 0 on success, -1 on error |
| 1572 | |
| 1573 | Specifies the tsc frequency for the virtual machine. The unit of the |
| 1574 | frequency is KHz. |
| 1575 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1576 | |
| 1577 | 4.56 KVM_GET_TSC_KHZ |
Joerg Roedel | 92a1f12 | 2011-03-25 09:44:51 +0100 | [diff] [blame] | 1578 | |
| 1579 | Capability: KVM_CAP_GET_TSC_KHZ |
| 1580 | Architectures: x86 |
| 1581 | Type: vcpu ioctl |
| 1582 | Parameters: none |
| 1583 | Returns: virtual tsc-khz on success, negative value on error |
| 1584 | |
| 1585 | Returns the tsc frequency of the guest. The unit of the return value is |
| 1586 | KHz. If the host has unstable tsc this ioctl returns -EIO instead as an |
| 1587 | error. |
| 1588 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1589 | |
| 1590 | 4.57 KVM_GET_LAPIC |
Avi Kivity | e767793 | 2011-05-11 08:30:51 -0400 | [diff] [blame] | 1591 | |
| 1592 | Capability: KVM_CAP_IRQCHIP |
| 1593 | Architectures: x86 |
| 1594 | Type: vcpu ioctl |
| 1595 | Parameters: struct kvm_lapic_state (out) |
| 1596 | Returns: 0 on success, -1 on error |
| 1597 | |
| 1598 | #define KVM_APIC_REG_SIZE 0x400 |
| 1599 | struct kvm_lapic_state { |
| 1600 | char regs[KVM_APIC_REG_SIZE]; |
| 1601 | }; |
| 1602 | |
| 1603 | Reads the Local APIC registers and copies them into the input argument. The |
| 1604 | data format and layout are the same as documented in the architecture manual. |
| 1605 | |
Radim Krčmář | 37131313 | 2016-07-12 22:09:27 +0200 | [diff] [blame] | 1606 | If KVM_X2APIC_API_USE_32BIT_IDS feature of KVM_CAP_X2APIC_API is |
| 1607 | enabled, then the format of APIC_ID register depends on the APIC mode |
| 1608 | (reported by MSR_IA32_APICBASE) of its VCPU. x2APIC stores APIC ID in |
| 1609 | the APIC_ID register (bytes 32-35). xAPIC only allows an 8-bit APIC ID |
| 1610 | which is stored in bits 31-24 of the APIC register, or equivalently in |
| 1611 | byte 35 of struct kvm_lapic_state's regs field. KVM_GET_LAPIC must then |
| 1612 | be called after MSR_IA32_APICBASE has been set with KVM_SET_MSR. |
| 1613 | |
| 1614 | If KVM_X2APIC_API_USE_32BIT_IDS feature is disabled, struct kvm_lapic_state |
| 1615 | always uses xAPIC format. |
| 1616 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1617 | |
| 1618 | 4.58 KVM_SET_LAPIC |
Avi Kivity | e767793 | 2011-05-11 08:30:51 -0400 | [diff] [blame] | 1619 | |
| 1620 | Capability: KVM_CAP_IRQCHIP |
| 1621 | Architectures: x86 |
| 1622 | Type: vcpu ioctl |
| 1623 | Parameters: struct kvm_lapic_state (in) |
| 1624 | Returns: 0 on success, -1 on error |
| 1625 | |
| 1626 | #define KVM_APIC_REG_SIZE 0x400 |
| 1627 | struct kvm_lapic_state { |
| 1628 | char regs[KVM_APIC_REG_SIZE]; |
| 1629 | }; |
| 1630 | |
Masanari Iida | df5cbb2 | 2014-03-21 10:04:30 +0900 | [diff] [blame] | 1631 | Copies the input argument into the Local APIC registers. The data format |
Avi Kivity | e767793 | 2011-05-11 08:30:51 -0400 | [diff] [blame] | 1632 | and layout are the same as documented in the architecture manual. |
| 1633 | |
Radim Krčmář | 37131313 | 2016-07-12 22:09:27 +0200 | [diff] [blame] | 1634 | The format of the APIC ID register (bytes 32-35 of struct kvm_lapic_state's |
| 1635 | regs field) depends on the state of the KVM_CAP_X2APIC_API capability. |
| 1636 | See the note in KVM_GET_LAPIC. |
| 1637 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1638 | |
| 1639 | 4.59 KVM_IOEVENTFD |
Sasha Levin | 55399a0 | 2011-05-28 14:12:30 +0300 | [diff] [blame] | 1640 | |
| 1641 | Capability: KVM_CAP_IOEVENTFD |
| 1642 | Architectures: all |
| 1643 | Type: vm ioctl |
| 1644 | Parameters: struct kvm_ioeventfd (in) |
| 1645 | Returns: 0 on success, !0 on error |
| 1646 | |
| 1647 | This ioctl attaches or detaches an ioeventfd to a legal pio/mmio address |
| 1648 | within the guest. A guest write in the registered address will signal the |
| 1649 | provided event instead of triggering an exit. |
| 1650 | |
| 1651 | struct kvm_ioeventfd { |
| 1652 | __u64 datamatch; |
| 1653 | __u64 addr; /* legal pio/mmio address */ |
Jason Wang | e9ea506 | 2015-09-15 14:41:59 +0800 | [diff] [blame] | 1654 | __u32 len; /* 0, 1, 2, 4, or 8 bytes */ |
Sasha Levin | 55399a0 | 2011-05-28 14:12:30 +0300 | [diff] [blame] | 1655 | __s32 fd; |
| 1656 | __u32 flags; |
| 1657 | __u8 pad[36]; |
| 1658 | }; |
| 1659 | |
Cornelia Huck | 2b83451 | 2013-02-28 12:33:20 +0100 | [diff] [blame] | 1660 | For the special case of virtio-ccw devices on s390, the ioevent is matched |
| 1661 | to a subchannel/virtqueue tuple instead. |
| 1662 | |
Sasha Levin | 55399a0 | 2011-05-28 14:12:30 +0300 | [diff] [blame] | 1663 | The following flags are defined: |
| 1664 | |
| 1665 | #define KVM_IOEVENTFD_FLAG_DATAMATCH (1 << kvm_ioeventfd_flag_nr_datamatch) |
| 1666 | #define KVM_IOEVENTFD_FLAG_PIO (1 << kvm_ioeventfd_flag_nr_pio) |
| 1667 | #define KVM_IOEVENTFD_FLAG_DEASSIGN (1 << kvm_ioeventfd_flag_nr_deassign) |
Cornelia Huck | 2b83451 | 2013-02-28 12:33:20 +0100 | [diff] [blame] | 1668 | #define KVM_IOEVENTFD_FLAG_VIRTIO_CCW_NOTIFY \ |
| 1669 | (1 << kvm_ioeventfd_flag_nr_virtio_ccw_notify) |
Sasha Levin | 55399a0 | 2011-05-28 14:12:30 +0300 | [diff] [blame] | 1670 | |
| 1671 | If datamatch flag is set, the event will be signaled only if the written value |
| 1672 | to the registered address is equal to datamatch in struct kvm_ioeventfd. |
| 1673 | |
Cornelia Huck | 2b83451 | 2013-02-28 12:33:20 +0100 | [diff] [blame] | 1674 | For virtio-ccw devices, addr contains the subchannel id and datamatch the |
| 1675 | virtqueue index. |
| 1676 | |
Jason Wang | e9ea506 | 2015-09-15 14:41:59 +0800 | [diff] [blame] | 1677 | With KVM_CAP_IOEVENTFD_ANY_LENGTH, a zero length ioeventfd is allowed, and |
| 1678 | the kernel will ignore the length of guest write and may get a faster vmexit. |
| 1679 | The speedup may only apply to specific architectures, but the ioeventfd will |
| 1680 | work anyway. |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1681 | |
| 1682 | 4.60 KVM_DIRTY_TLB |
Scott Wood | dc83b8b | 2011-08-18 15:25:21 -0500 | [diff] [blame] | 1683 | |
| 1684 | Capability: KVM_CAP_SW_TLB |
| 1685 | Architectures: ppc |
| 1686 | Type: vcpu ioctl |
| 1687 | Parameters: struct kvm_dirty_tlb (in) |
| 1688 | Returns: 0 on success, -1 on error |
| 1689 | |
| 1690 | struct kvm_dirty_tlb { |
| 1691 | __u64 bitmap; |
| 1692 | __u32 num_dirty; |
| 1693 | }; |
| 1694 | |
| 1695 | This must be called whenever userspace has changed an entry in the shared |
| 1696 | TLB, prior to calling KVM_RUN on the associated vcpu. |
| 1697 | |
| 1698 | The "bitmap" field is the userspace address of an array. This array |
| 1699 | consists of a number of bits, equal to the total number of TLB entries as |
| 1700 | determined by the last successful call to KVM_CONFIG_TLB, rounded up to the |
| 1701 | nearest multiple of 64. |
| 1702 | |
| 1703 | Each bit corresponds to one TLB entry, ordered the same as in the shared TLB |
| 1704 | array. |
| 1705 | |
| 1706 | The array is little-endian: the bit 0 is the least significant bit of the |
| 1707 | first byte, bit 8 is the least significant bit of the second byte, etc. |
| 1708 | This avoids any complications with differing word sizes. |
| 1709 | |
| 1710 | The "num_dirty" field is a performance hint for KVM to determine whether it |
| 1711 | should skip processing the bitmap and just invalidate everything. It must |
| 1712 | be set to the number of set bits in the bitmap. |
| 1713 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1714 | |
David Gibson | 54738c0 | 2011-06-29 00:22:41 +0000 | [diff] [blame] | 1715 | 4.62 KVM_CREATE_SPAPR_TCE |
| 1716 | |
| 1717 | Capability: KVM_CAP_SPAPR_TCE |
| 1718 | Architectures: powerpc |
| 1719 | Type: vm ioctl |
| 1720 | Parameters: struct kvm_create_spapr_tce (in) |
| 1721 | Returns: file descriptor for manipulating the created TCE table |
| 1722 | |
| 1723 | This creates a virtual TCE (translation control entry) table, which |
| 1724 | is an IOMMU for PAPR-style virtual I/O. It is used to translate |
| 1725 | logical addresses used in virtual I/O into guest physical addresses, |
| 1726 | and provides a scatter/gather capability for PAPR virtual I/O. |
| 1727 | |
| 1728 | /* for KVM_CAP_SPAPR_TCE */ |
| 1729 | struct kvm_create_spapr_tce { |
| 1730 | __u64 liobn; |
| 1731 | __u32 window_size; |
| 1732 | }; |
| 1733 | |
| 1734 | The liobn field gives the logical IO bus number for which to create a |
| 1735 | TCE table. The window_size field specifies the size of the DMA window |
| 1736 | which this TCE table will translate - the table will contain one 64 |
| 1737 | bit TCE entry for every 4kiB of the DMA window. |
| 1738 | |
| 1739 | When the guest issues an H_PUT_TCE hcall on a liobn for which a TCE |
| 1740 | table has been created using this ioctl(), the kernel will handle it |
| 1741 | in real mode, updating the TCE table. H_PUT_TCE calls for other |
| 1742 | liobns will cause a vm exit and must be handled by userspace. |
| 1743 | |
| 1744 | The return value is a file descriptor which can be passed to mmap(2) |
| 1745 | to map the created TCE table into userspace. This lets userspace read |
| 1746 | the entries written by kernel-handled H_PUT_TCE calls, and also lets |
| 1747 | userspace update the TCE table directly which is useful in some |
| 1748 | circumstances. |
| 1749 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1750 | |
Paul Mackerras | aa04b4c | 2011-06-29 00:25:44 +0000 | [diff] [blame] | 1751 | 4.63 KVM_ALLOCATE_RMA |
| 1752 | |
| 1753 | Capability: KVM_CAP_PPC_RMA |
| 1754 | Architectures: powerpc |
| 1755 | Type: vm ioctl |
| 1756 | Parameters: struct kvm_allocate_rma (out) |
| 1757 | Returns: file descriptor for mapping the allocated RMA |
| 1758 | |
| 1759 | This allocates a Real Mode Area (RMA) from the pool allocated at boot |
| 1760 | time by the kernel. An RMA is a physically-contiguous, aligned region |
| 1761 | of memory used on older POWER processors to provide the memory which |
| 1762 | will be accessed by real-mode (MMU off) accesses in a KVM guest. |
| 1763 | POWER processors support a set of sizes for the RMA that usually |
| 1764 | includes 64MB, 128MB, 256MB and some larger powers of two. |
| 1765 | |
| 1766 | /* for KVM_ALLOCATE_RMA */ |
| 1767 | struct kvm_allocate_rma { |
| 1768 | __u64 rma_size; |
| 1769 | }; |
| 1770 | |
| 1771 | The return value is a file descriptor which can be passed to mmap(2) |
| 1772 | to map the allocated RMA into userspace. The mapped area can then be |
| 1773 | passed to the KVM_SET_USER_MEMORY_REGION ioctl to establish it as the |
| 1774 | RMA for a virtual machine. The size of the RMA in bytes (which is |
| 1775 | fixed at host kernel boot time) is returned in the rma_size field of |
| 1776 | the argument structure. |
| 1777 | |
| 1778 | The KVM_CAP_PPC_RMA capability is 1 or 2 if the KVM_ALLOCATE_RMA ioctl |
| 1779 | is supported; 2 if the processor requires all virtual machines to have |
| 1780 | an RMA, or 1 if the processor can use an RMA but doesn't require it, |
| 1781 | because it supports the Virtual RMA (VRMA) facility. |
| 1782 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1783 | |
Avi Kivity | 3f745f1 | 2011-12-07 12:42:47 +0200 | [diff] [blame] | 1784 | 4.64 KVM_NMI |
| 1785 | |
| 1786 | Capability: KVM_CAP_USER_NMI |
| 1787 | Architectures: x86 |
| 1788 | Type: vcpu ioctl |
| 1789 | Parameters: none |
| 1790 | Returns: 0 on success, -1 on error |
| 1791 | |
| 1792 | Queues an NMI on the thread's vcpu. Note this is well defined only |
| 1793 | when KVM_CREATE_IRQCHIP has not been called, since this is an interface |
| 1794 | between the virtual cpu core and virtual local APIC. After KVM_CREATE_IRQCHIP |
| 1795 | has been called, this interface is completely emulated within the kernel. |
| 1796 | |
| 1797 | To use this to emulate the LINT1 input with KVM_CREATE_IRQCHIP, use the |
| 1798 | following algorithm: |
| 1799 | |
Masanari Iida | 5d4f6f3 | 2015-10-04 00:46:21 +0900 | [diff] [blame] | 1800 | - pause the vcpu |
Avi Kivity | 3f745f1 | 2011-12-07 12:42:47 +0200 | [diff] [blame] | 1801 | - read the local APIC's state (KVM_GET_LAPIC) |
| 1802 | - check whether changing LINT1 will queue an NMI (see the LVT entry for LINT1) |
| 1803 | - if so, issue KVM_NMI |
| 1804 | - resume the vcpu |
| 1805 | |
| 1806 | Some guests configure the LINT1 NMI input to cause a panic, aiding in |
| 1807 | debugging. |
| 1808 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1809 | |
Alexander Graf | e24ed81 | 2011-09-14 10:02:41 +0200 | [diff] [blame] | 1810 | 4.65 KVM_S390_UCAS_MAP |
Carsten Otte | 27e0393 | 2012-01-04 10:25:21 +0100 | [diff] [blame] | 1811 | |
| 1812 | Capability: KVM_CAP_S390_UCONTROL |
| 1813 | Architectures: s390 |
| 1814 | Type: vcpu ioctl |
| 1815 | Parameters: struct kvm_s390_ucas_mapping (in) |
| 1816 | Returns: 0 in case of success |
| 1817 | |
| 1818 | The parameter is defined like this: |
| 1819 | struct kvm_s390_ucas_mapping { |
| 1820 | __u64 user_addr; |
| 1821 | __u64 vcpu_addr; |
| 1822 | __u64 length; |
| 1823 | }; |
| 1824 | |
| 1825 | This ioctl maps the memory at "user_addr" with the length "length" to |
| 1826 | the vcpu's address space starting at "vcpu_addr". All parameters need to |
Anatol Pomozov | f884ab1 | 2013-05-08 16:56:16 -0700 | [diff] [blame] | 1827 | be aligned by 1 megabyte. |
Carsten Otte | 27e0393 | 2012-01-04 10:25:21 +0100 | [diff] [blame] | 1828 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1829 | |
Alexander Graf | e24ed81 | 2011-09-14 10:02:41 +0200 | [diff] [blame] | 1830 | 4.66 KVM_S390_UCAS_UNMAP |
Carsten Otte | 27e0393 | 2012-01-04 10:25:21 +0100 | [diff] [blame] | 1831 | |
| 1832 | Capability: KVM_CAP_S390_UCONTROL |
| 1833 | Architectures: s390 |
| 1834 | Type: vcpu ioctl |
| 1835 | Parameters: struct kvm_s390_ucas_mapping (in) |
| 1836 | Returns: 0 in case of success |
| 1837 | |
| 1838 | The parameter is defined like this: |
| 1839 | struct kvm_s390_ucas_mapping { |
| 1840 | __u64 user_addr; |
| 1841 | __u64 vcpu_addr; |
| 1842 | __u64 length; |
| 1843 | }; |
| 1844 | |
| 1845 | This ioctl unmaps the memory in the vcpu's address space starting at |
| 1846 | "vcpu_addr" with the length "length". The field "user_addr" is ignored. |
Anatol Pomozov | f884ab1 | 2013-05-08 16:56:16 -0700 | [diff] [blame] | 1847 | All parameters need to be aligned by 1 megabyte. |
Carsten Otte | 27e0393 | 2012-01-04 10:25:21 +0100 | [diff] [blame] | 1848 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1849 | |
Alexander Graf | e24ed81 | 2011-09-14 10:02:41 +0200 | [diff] [blame] | 1850 | 4.67 KVM_S390_VCPU_FAULT |
Carsten Otte | ccc7910 | 2012-01-04 10:25:26 +0100 | [diff] [blame] | 1851 | |
| 1852 | Capability: KVM_CAP_S390_UCONTROL |
| 1853 | Architectures: s390 |
| 1854 | Type: vcpu ioctl |
| 1855 | Parameters: vcpu absolute address (in) |
| 1856 | Returns: 0 in case of success |
| 1857 | |
| 1858 | This call creates a page table entry on the virtual cpu's address space |
| 1859 | (for user controlled virtual machines) or the virtual machine's address |
| 1860 | space (for regular virtual machines). This only works for minor faults, |
| 1861 | thus it's recommended to access subject memory page via the user page |
| 1862 | table upfront. This is useful to handle validity intercepts for user |
| 1863 | controlled virtual machines to fault in the virtual cpu's lowcore pages |
| 1864 | prior to calling the KVM_RUN ioctl. |
| 1865 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1866 | |
Alexander Graf | e24ed81 | 2011-09-14 10:02:41 +0200 | [diff] [blame] | 1867 | 4.68 KVM_SET_ONE_REG |
| 1868 | |
| 1869 | Capability: KVM_CAP_ONE_REG |
| 1870 | Architectures: all |
| 1871 | Type: vcpu ioctl |
| 1872 | Parameters: struct kvm_one_reg (in) |
| 1873 | Returns: 0 on success, negative value on failure |
| 1874 | |
| 1875 | struct kvm_one_reg { |
| 1876 | __u64 id; |
| 1877 | __u64 addr; |
| 1878 | }; |
| 1879 | |
| 1880 | Using this ioctl, a single vcpu register can be set to a specific value |
| 1881 | defined by user space with the passed in struct kvm_one_reg, where id |
| 1882 | refers to the register identifier as described below and addr is a pointer |
| 1883 | to a variable with the respective size. There can be architecture agnostic |
| 1884 | and architecture specific registers. Each have their own range of operation |
| 1885 | and their own constants and width. To keep track of the implemented |
| 1886 | registers, find a list below: |
| 1887 | |
James Hogan | bf5590f | 2014-07-04 15:11:34 +0100 | [diff] [blame] | 1888 | Arch | Register | Width (bits) |
| 1889 | | | |
| 1890 | PPC | KVM_REG_PPC_HIOR | 64 |
| 1891 | PPC | KVM_REG_PPC_IAC1 | 64 |
| 1892 | PPC | KVM_REG_PPC_IAC2 | 64 |
| 1893 | PPC | KVM_REG_PPC_IAC3 | 64 |
| 1894 | PPC | KVM_REG_PPC_IAC4 | 64 |
| 1895 | PPC | KVM_REG_PPC_DAC1 | 64 |
| 1896 | PPC | KVM_REG_PPC_DAC2 | 64 |
| 1897 | PPC | KVM_REG_PPC_DABR | 64 |
| 1898 | PPC | KVM_REG_PPC_DSCR | 64 |
| 1899 | PPC | KVM_REG_PPC_PURR | 64 |
| 1900 | PPC | KVM_REG_PPC_SPURR | 64 |
| 1901 | PPC | KVM_REG_PPC_DAR | 64 |
| 1902 | PPC | KVM_REG_PPC_DSISR | 32 |
| 1903 | PPC | KVM_REG_PPC_AMR | 64 |
| 1904 | PPC | KVM_REG_PPC_UAMOR | 64 |
| 1905 | PPC | KVM_REG_PPC_MMCR0 | 64 |
| 1906 | PPC | KVM_REG_PPC_MMCR1 | 64 |
| 1907 | PPC | KVM_REG_PPC_MMCRA | 64 |
| 1908 | PPC | KVM_REG_PPC_MMCR2 | 64 |
| 1909 | PPC | KVM_REG_PPC_MMCRS | 64 |
| 1910 | PPC | KVM_REG_PPC_SIAR | 64 |
| 1911 | PPC | KVM_REG_PPC_SDAR | 64 |
| 1912 | PPC | KVM_REG_PPC_SIER | 64 |
| 1913 | PPC | KVM_REG_PPC_PMC1 | 32 |
| 1914 | PPC | KVM_REG_PPC_PMC2 | 32 |
| 1915 | PPC | KVM_REG_PPC_PMC3 | 32 |
| 1916 | PPC | KVM_REG_PPC_PMC4 | 32 |
| 1917 | PPC | KVM_REG_PPC_PMC5 | 32 |
| 1918 | PPC | KVM_REG_PPC_PMC6 | 32 |
| 1919 | PPC | KVM_REG_PPC_PMC7 | 32 |
| 1920 | PPC | KVM_REG_PPC_PMC8 | 32 |
| 1921 | PPC | KVM_REG_PPC_FPR0 | 64 |
Paul Mackerras | a8bd19e | 2012-09-25 20:32:30 +0000 | [diff] [blame] | 1922 | ... |
James Hogan | bf5590f | 2014-07-04 15:11:34 +0100 | [diff] [blame] | 1923 | PPC | KVM_REG_PPC_FPR31 | 64 |
| 1924 | PPC | KVM_REG_PPC_VR0 | 128 |
Paul Mackerras | a8bd19e | 2012-09-25 20:32:30 +0000 | [diff] [blame] | 1925 | ... |
James Hogan | bf5590f | 2014-07-04 15:11:34 +0100 | [diff] [blame] | 1926 | PPC | KVM_REG_PPC_VR31 | 128 |
| 1927 | PPC | KVM_REG_PPC_VSR0 | 128 |
Paul Mackerras | a8bd19e | 2012-09-25 20:32:30 +0000 | [diff] [blame] | 1928 | ... |
James Hogan | bf5590f | 2014-07-04 15:11:34 +0100 | [diff] [blame] | 1929 | PPC | KVM_REG_PPC_VSR31 | 128 |
| 1930 | PPC | KVM_REG_PPC_FPSCR | 64 |
| 1931 | PPC | KVM_REG_PPC_VSCR | 32 |
| 1932 | PPC | KVM_REG_PPC_VPA_ADDR | 64 |
| 1933 | PPC | KVM_REG_PPC_VPA_SLB | 128 |
| 1934 | PPC | KVM_REG_PPC_VPA_DTL | 128 |
| 1935 | PPC | KVM_REG_PPC_EPCR | 32 |
| 1936 | PPC | KVM_REG_PPC_EPR | 32 |
| 1937 | PPC | KVM_REG_PPC_TCR | 32 |
| 1938 | PPC | KVM_REG_PPC_TSR | 32 |
| 1939 | PPC | KVM_REG_PPC_OR_TSR | 32 |
| 1940 | PPC | KVM_REG_PPC_CLEAR_TSR | 32 |
| 1941 | PPC | KVM_REG_PPC_MAS0 | 32 |
| 1942 | PPC | KVM_REG_PPC_MAS1 | 32 |
| 1943 | PPC | KVM_REG_PPC_MAS2 | 64 |
| 1944 | PPC | KVM_REG_PPC_MAS7_3 | 64 |
| 1945 | PPC | KVM_REG_PPC_MAS4 | 32 |
| 1946 | PPC | KVM_REG_PPC_MAS6 | 32 |
| 1947 | PPC | KVM_REG_PPC_MMUCFG | 32 |
| 1948 | PPC | KVM_REG_PPC_TLB0CFG | 32 |
| 1949 | PPC | KVM_REG_PPC_TLB1CFG | 32 |
| 1950 | PPC | KVM_REG_PPC_TLB2CFG | 32 |
| 1951 | PPC | KVM_REG_PPC_TLB3CFG | 32 |
| 1952 | PPC | KVM_REG_PPC_TLB0PS | 32 |
| 1953 | PPC | KVM_REG_PPC_TLB1PS | 32 |
| 1954 | PPC | KVM_REG_PPC_TLB2PS | 32 |
| 1955 | PPC | KVM_REG_PPC_TLB3PS | 32 |
| 1956 | PPC | KVM_REG_PPC_EPTCFG | 32 |
| 1957 | PPC | KVM_REG_PPC_ICP_STATE | 64 |
| 1958 | PPC | KVM_REG_PPC_TB_OFFSET | 64 |
| 1959 | PPC | KVM_REG_PPC_SPMC1 | 32 |
| 1960 | PPC | KVM_REG_PPC_SPMC2 | 32 |
| 1961 | PPC | KVM_REG_PPC_IAMR | 64 |
| 1962 | PPC | KVM_REG_PPC_TFHAR | 64 |
| 1963 | PPC | KVM_REG_PPC_TFIAR | 64 |
| 1964 | PPC | KVM_REG_PPC_TEXASR | 64 |
| 1965 | PPC | KVM_REG_PPC_FSCR | 64 |
| 1966 | PPC | KVM_REG_PPC_PSPB | 32 |
| 1967 | PPC | KVM_REG_PPC_EBBHR | 64 |
| 1968 | PPC | KVM_REG_PPC_EBBRR | 64 |
| 1969 | PPC | KVM_REG_PPC_BESCR | 64 |
| 1970 | PPC | KVM_REG_PPC_TAR | 64 |
| 1971 | PPC | KVM_REG_PPC_DPDES | 64 |
| 1972 | PPC | KVM_REG_PPC_DAWR | 64 |
| 1973 | PPC | KVM_REG_PPC_DAWRX | 64 |
| 1974 | PPC | KVM_REG_PPC_CIABR | 64 |
| 1975 | PPC | KVM_REG_PPC_IC | 64 |
| 1976 | PPC | KVM_REG_PPC_VTB | 64 |
| 1977 | PPC | KVM_REG_PPC_CSIGR | 64 |
| 1978 | PPC | KVM_REG_PPC_TACR | 64 |
| 1979 | PPC | KVM_REG_PPC_TCSCR | 64 |
| 1980 | PPC | KVM_REG_PPC_PID | 64 |
| 1981 | PPC | KVM_REG_PPC_ACOP | 64 |
| 1982 | PPC | KVM_REG_PPC_VRSAVE | 32 |
Paolo Bonzini | cc568ea | 2014-08-05 09:55:22 +0200 | [diff] [blame] | 1983 | PPC | KVM_REG_PPC_LPCR | 32 |
| 1984 | PPC | KVM_REG_PPC_LPCR_64 | 64 |
James Hogan | bf5590f | 2014-07-04 15:11:34 +0100 | [diff] [blame] | 1985 | PPC | KVM_REG_PPC_PPR | 64 |
| 1986 | PPC | KVM_REG_PPC_ARCH_COMPAT | 32 |
| 1987 | PPC | KVM_REG_PPC_DABRX | 32 |
| 1988 | PPC | KVM_REG_PPC_WORT | 64 |
Bharat Bhushan | bc8a4e5 | 2014-08-13 14:40:06 +0530 | [diff] [blame] | 1989 | PPC | KVM_REG_PPC_SPRG9 | 64 |
| 1990 | PPC | KVM_REG_PPC_DBSR | 32 |
Paul Mackerras | e9cf1e0 | 2016-11-18 13:11:42 +1100 | [diff] [blame] | 1991 | PPC | KVM_REG_PPC_TIDR | 64 |
| 1992 | PPC | KVM_REG_PPC_PSSCR | 64 |
Paul Mackerras | 5855564 | 2018-01-12 20:55:20 +1100 | [diff] [blame] | 1993 | PPC | KVM_REG_PPC_DEC_EXPIRY | 64 |
Paul Mackerras | 3032341 | 2018-10-08 16:31:13 +1100 | [diff] [blame] | 1994 | PPC | KVM_REG_PPC_PTCR | 64 |
James Hogan | bf5590f | 2014-07-04 15:11:34 +0100 | [diff] [blame] | 1995 | PPC | KVM_REG_PPC_TM_GPR0 | 64 |
Michael Neuling | 3b78347 | 2013-09-03 11:13:12 +1000 | [diff] [blame] | 1996 | ... |
James Hogan | bf5590f | 2014-07-04 15:11:34 +0100 | [diff] [blame] | 1997 | PPC | KVM_REG_PPC_TM_GPR31 | 64 |
| 1998 | PPC | KVM_REG_PPC_TM_VSR0 | 128 |
Michael Neuling | 3b78347 | 2013-09-03 11:13:12 +1000 | [diff] [blame] | 1999 | ... |
James Hogan | bf5590f | 2014-07-04 15:11:34 +0100 | [diff] [blame] | 2000 | PPC | KVM_REG_PPC_TM_VSR63 | 128 |
| 2001 | PPC | KVM_REG_PPC_TM_CR | 64 |
| 2002 | PPC | KVM_REG_PPC_TM_LR | 64 |
| 2003 | PPC | KVM_REG_PPC_TM_CTR | 64 |
| 2004 | PPC | KVM_REG_PPC_TM_FPSCR | 64 |
| 2005 | PPC | KVM_REG_PPC_TM_AMR | 64 |
| 2006 | PPC | KVM_REG_PPC_TM_PPR | 64 |
| 2007 | PPC | KVM_REG_PPC_TM_VRSAVE | 64 |
| 2008 | PPC | KVM_REG_PPC_TM_VSCR | 32 |
| 2009 | PPC | KVM_REG_PPC_TM_DSCR | 64 |
| 2010 | PPC | KVM_REG_PPC_TM_TAR | 64 |
Paul Mackerras | 0d808df | 2016-11-07 15:09:58 +1100 | [diff] [blame] | 2011 | PPC | KVM_REG_PPC_TM_XER | 64 |
James Hogan | c2d2c21 | 2014-07-04 15:11:35 +0100 | [diff] [blame] | 2012 | | | |
| 2013 | MIPS | KVM_REG_MIPS_R0 | 64 |
| 2014 | ... |
| 2015 | MIPS | KVM_REG_MIPS_R31 | 64 |
| 2016 | MIPS | KVM_REG_MIPS_HI | 64 |
| 2017 | MIPS | KVM_REG_MIPS_LO | 64 |
| 2018 | MIPS | KVM_REG_MIPS_PC | 64 |
| 2019 | MIPS | KVM_REG_MIPS_CP0_INDEX | 32 |
James Hogan | 013044c | 2016-12-07 17:16:37 +0000 | [diff] [blame] | 2020 | MIPS | KVM_REG_MIPS_CP0_ENTRYLO0 | 64 |
| 2021 | MIPS | KVM_REG_MIPS_CP0_ENTRYLO1 | 64 |
James Hogan | c2d2c21 | 2014-07-04 15:11:35 +0100 | [diff] [blame] | 2022 | MIPS | KVM_REG_MIPS_CP0_CONTEXT | 64 |
James Hogan | dffe042 | 2017-03-14 10:15:34 +0000 | [diff] [blame] | 2023 | MIPS | KVM_REG_MIPS_CP0_CONTEXTCONFIG| 32 |
James Hogan | c2d2c21 | 2014-07-04 15:11:35 +0100 | [diff] [blame] | 2024 | MIPS | KVM_REG_MIPS_CP0_USERLOCAL | 64 |
James Hogan | dffe042 | 2017-03-14 10:15:34 +0000 | [diff] [blame] | 2025 | MIPS | KVM_REG_MIPS_CP0_XCONTEXTCONFIG| 64 |
James Hogan | c2d2c21 | 2014-07-04 15:11:35 +0100 | [diff] [blame] | 2026 | MIPS | KVM_REG_MIPS_CP0_PAGEMASK | 32 |
James Hogan | c992a4f | 2017-03-14 10:15:31 +0000 | [diff] [blame] | 2027 | MIPS | KVM_REG_MIPS_CP0_PAGEGRAIN | 32 |
James Hogan | 4b7de02 | 2017-03-14 10:15:35 +0000 | [diff] [blame] | 2028 | MIPS | KVM_REG_MIPS_CP0_SEGCTL0 | 64 |
| 2029 | MIPS | KVM_REG_MIPS_CP0_SEGCTL1 | 64 |
| 2030 | MIPS | KVM_REG_MIPS_CP0_SEGCTL2 | 64 |
James Hogan | 5a2f352 | 2017-03-14 10:15:36 +0000 | [diff] [blame] | 2031 | MIPS | KVM_REG_MIPS_CP0_PWBASE | 64 |
| 2032 | MIPS | KVM_REG_MIPS_CP0_PWFIELD | 64 |
| 2033 | MIPS | KVM_REG_MIPS_CP0_PWSIZE | 64 |
James Hogan | c2d2c21 | 2014-07-04 15:11:35 +0100 | [diff] [blame] | 2034 | MIPS | KVM_REG_MIPS_CP0_WIRED | 32 |
James Hogan | 5a2f352 | 2017-03-14 10:15:36 +0000 | [diff] [blame] | 2035 | MIPS | KVM_REG_MIPS_CP0_PWCTL | 32 |
James Hogan | c2d2c21 | 2014-07-04 15:11:35 +0100 | [diff] [blame] | 2036 | MIPS | KVM_REG_MIPS_CP0_HWRENA | 32 |
| 2037 | MIPS | KVM_REG_MIPS_CP0_BADVADDR | 64 |
James Hogan | edc8926 | 2017-03-14 10:15:33 +0000 | [diff] [blame] | 2038 | MIPS | KVM_REG_MIPS_CP0_BADINSTR | 32 |
| 2039 | MIPS | KVM_REG_MIPS_CP0_BADINSTRP | 32 |
James Hogan | c2d2c21 | 2014-07-04 15:11:35 +0100 | [diff] [blame] | 2040 | MIPS | KVM_REG_MIPS_CP0_COUNT | 32 |
| 2041 | MIPS | KVM_REG_MIPS_CP0_ENTRYHI | 64 |
| 2042 | MIPS | KVM_REG_MIPS_CP0_COMPARE | 32 |
| 2043 | MIPS | KVM_REG_MIPS_CP0_STATUS | 32 |
James Hogan | ad58d4d | 2015-02-02 22:55:17 +0000 | [diff] [blame] | 2044 | MIPS | KVM_REG_MIPS_CP0_INTCTL | 32 |
James Hogan | c2d2c21 | 2014-07-04 15:11:35 +0100 | [diff] [blame] | 2045 | MIPS | KVM_REG_MIPS_CP0_CAUSE | 32 |
| 2046 | MIPS | KVM_REG_MIPS_CP0_EPC | 64 |
James Hogan | 1068eaa | 2014-06-26 13:56:52 +0100 | [diff] [blame] | 2047 | MIPS | KVM_REG_MIPS_CP0_PRID | 32 |
James Hogan | 7801bbe | 2016-11-14 23:59:27 +0000 | [diff] [blame] | 2048 | MIPS | KVM_REG_MIPS_CP0_EBASE | 64 |
James Hogan | c2d2c21 | 2014-07-04 15:11:35 +0100 | [diff] [blame] | 2049 | MIPS | KVM_REG_MIPS_CP0_CONFIG | 32 |
| 2050 | MIPS | KVM_REG_MIPS_CP0_CONFIG1 | 32 |
| 2051 | MIPS | KVM_REG_MIPS_CP0_CONFIG2 | 32 |
| 2052 | MIPS | KVM_REG_MIPS_CP0_CONFIG3 | 32 |
James Hogan | c771607 | 2014-06-26 15:11:29 +0100 | [diff] [blame] | 2053 | MIPS | KVM_REG_MIPS_CP0_CONFIG4 | 32 |
| 2054 | MIPS | KVM_REG_MIPS_CP0_CONFIG5 | 32 |
James Hogan | c2d2c21 | 2014-07-04 15:11:35 +0100 | [diff] [blame] | 2055 | MIPS | KVM_REG_MIPS_CP0_CONFIG7 | 32 |
James Hogan | c992a4f | 2017-03-14 10:15:31 +0000 | [diff] [blame] | 2056 | MIPS | KVM_REG_MIPS_CP0_XCONTEXT | 64 |
James Hogan | c2d2c21 | 2014-07-04 15:11:35 +0100 | [diff] [blame] | 2057 | MIPS | KVM_REG_MIPS_CP0_ERROREPC | 64 |
James Hogan | 0510870 | 2016-06-15 19:29:56 +0100 | [diff] [blame] | 2058 | MIPS | KVM_REG_MIPS_CP0_KSCRATCH1 | 64 |
| 2059 | MIPS | KVM_REG_MIPS_CP0_KSCRATCH2 | 64 |
| 2060 | MIPS | KVM_REG_MIPS_CP0_KSCRATCH3 | 64 |
| 2061 | MIPS | KVM_REG_MIPS_CP0_KSCRATCH4 | 64 |
| 2062 | MIPS | KVM_REG_MIPS_CP0_KSCRATCH5 | 64 |
| 2063 | MIPS | KVM_REG_MIPS_CP0_KSCRATCH6 | 64 |
James Hogan | d42a008 | 2017-03-14 10:15:38 +0000 | [diff] [blame] | 2064 | MIPS | KVM_REG_MIPS_CP0_MAAR(0..63) | 64 |
James Hogan | c2d2c21 | 2014-07-04 15:11:35 +0100 | [diff] [blame] | 2065 | MIPS | KVM_REG_MIPS_COUNT_CTL | 64 |
| 2066 | MIPS | KVM_REG_MIPS_COUNT_RESUME | 64 |
| 2067 | MIPS | KVM_REG_MIPS_COUNT_HZ | 64 |
James Hogan | 379245c | 2014-12-02 15:48:24 +0000 | [diff] [blame] | 2068 | MIPS | KVM_REG_MIPS_FPR_32(0..31) | 32 |
| 2069 | MIPS | KVM_REG_MIPS_FPR_64(0..31) | 64 |
James Hogan | ab86bd6 | 2014-12-02 15:48:24 +0000 | [diff] [blame] | 2070 | MIPS | KVM_REG_MIPS_VEC_128(0..31) | 128 |
James Hogan | 379245c | 2014-12-02 15:48:24 +0000 | [diff] [blame] | 2071 | MIPS | KVM_REG_MIPS_FCR_IR | 32 |
| 2072 | MIPS | KVM_REG_MIPS_FCR_CSR | 32 |
James Hogan | ab86bd6 | 2014-12-02 15:48:24 +0000 | [diff] [blame] | 2073 | MIPS | KVM_REG_MIPS_MSA_IR | 32 |
| 2074 | MIPS | KVM_REG_MIPS_MSA_CSR | 32 |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 2075 | |
Christoffer Dall | 749cf76c | 2013-01-20 18:28:06 -0500 | [diff] [blame] | 2076 | ARM registers are mapped using the lower 32 bits. The upper 16 of that |
| 2077 | is the register group type, or coprocessor number: |
| 2078 | |
| 2079 | ARM core registers have the following id bit patterns: |
Christoffer Dall | aa404dd | 2013-04-22 18:57:46 -0700 | [diff] [blame] | 2080 | 0x4020 0000 0010 <index into the kvm_regs struct:16> |
Christoffer Dall | 749cf76c | 2013-01-20 18:28:06 -0500 | [diff] [blame] | 2081 | |
Christoffer Dall | 1138245 | 2013-01-20 18:28:10 -0500 | [diff] [blame] | 2082 | ARM 32-bit CP15 registers have the following id bit patterns: |
Christoffer Dall | aa404dd | 2013-04-22 18:57:46 -0700 | [diff] [blame] | 2083 | 0x4020 0000 000F <zero:1> <crn:4> <crm:4> <opc1:4> <opc2:3> |
Christoffer Dall | 1138245 | 2013-01-20 18:28:10 -0500 | [diff] [blame] | 2084 | |
| 2085 | ARM 64-bit CP15 registers have the following id bit patterns: |
Christoffer Dall | aa404dd | 2013-04-22 18:57:46 -0700 | [diff] [blame] | 2086 | 0x4030 0000 000F <zero:1> <zero:4> <crm:4> <opc1:4> <zero:3> |
Christoffer Dall | 749cf76c | 2013-01-20 18:28:06 -0500 | [diff] [blame] | 2087 | |
Christoffer Dall | c27581e | 2013-01-20 18:28:10 -0500 | [diff] [blame] | 2088 | ARM CCSIDR registers are demultiplexed by CSSELR value: |
Christoffer Dall | aa404dd | 2013-04-22 18:57:46 -0700 | [diff] [blame] | 2089 | 0x4020 0000 0011 00 <csselr:8> |
Christoffer Dall | 749cf76c | 2013-01-20 18:28:06 -0500 | [diff] [blame] | 2090 | |
Rusty Russell | 4fe21e4 | 2013-01-20 18:28:11 -0500 | [diff] [blame] | 2091 | ARM 32-bit VFP control registers have the following id bit patterns: |
Christoffer Dall | aa404dd | 2013-04-22 18:57:46 -0700 | [diff] [blame] | 2092 | 0x4020 0000 0012 1 <regno:12> |
Rusty Russell | 4fe21e4 | 2013-01-20 18:28:11 -0500 | [diff] [blame] | 2093 | |
| 2094 | ARM 64-bit FP registers have the following id bit patterns: |
Christoffer Dall | aa404dd | 2013-04-22 18:57:46 -0700 | [diff] [blame] | 2095 | 0x4030 0000 0012 0 <regno:12> |
Rusty Russell | 4fe21e4 | 2013-01-20 18:28:11 -0500 | [diff] [blame] | 2096 | |
Marc Zyngier | 85bd0ba | 2018-01-21 16:42:56 +0000 | [diff] [blame] | 2097 | ARM firmware pseudo-registers have the following bit pattern: |
| 2098 | 0x4030 0000 0014 <regno:16> |
| 2099 | |
Marc Zyngier | 379e04c7 | 2013-04-02 17:46:31 +0100 | [diff] [blame] | 2100 | |
| 2101 | arm64 registers are mapped using the lower 32 bits. The upper 16 of |
| 2102 | that is the register group type, or coprocessor number: |
| 2103 | |
| 2104 | arm64 core/FP-SIMD registers have the following id bit patterns. Note |
| 2105 | that the size of the access is variable, as the kvm_regs structure |
| 2106 | contains elements ranging from 32 to 128 bits. The index is a 32bit |
| 2107 | value in the kvm_regs structure seen as a 32bit array. |
| 2108 | 0x60x0 0000 0010 <index into the kvm_regs struct:16> |
| 2109 | |
| 2110 | arm64 CCSIDR registers are demultiplexed by CSSELR value: |
| 2111 | 0x6020 0000 0011 00 <csselr:8> |
| 2112 | |
| 2113 | arm64 system registers have the following id bit patterns: |
| 2114 | 0x6030 0000 0013 <op0:2> <op1:3> <crn:4> <crm:4> <op2:3> |
| 2115 | |
Marc Zyngier | 85bd0ba | 2018-01-21 16:42:56 +0000 | [diff] [blame] | 2116 | arm64 firmware pseudo-registers have the following bit pattern: |
| 2117 | 0x6030 0000 0014 <regno:16> |
| 2118 | |
James Hogan | c2d2c21 | 2014-07-04 15:11:35 +0100 | [diff] [blame] | 2119 | |
| 2120 | MIPS registers are mapped using the lower 32 bits. The upper 16 of that is |
| 2121 | the register group type: |
| 2122 | |
| 2123 | MIPS core registers (see above) have the following id bit patterns: |
| 2124 | 0x7030 0000 0000 <reg:16> |
| 2125 | |
| 2126 | MIPS CP0 registers (see KVM_REG_MIPS_CP0_* above) have the following id bit |
| 2127 | patterns depending on whether they're 32-bit or 64-bit registers: |
| 2128 | 0x7020 0000 0001 00 <reg:5> <sel:3> (32-bit) |
| 2129 | 0x7030 0000 0001 00 <reg:5> <sel:3> (64-bit) |
| 2130 | |
James Hogan | 013044c | 2016-12-07 17:16:37 +0000 | [diff] [blame] | 2131 | Note: KVM_REG_MIPS_CP0_ENTRYLO0 and KVM_REG_MIPS_CP0_ENTRYLO1 are the MIPS64 |
| 2132 | versions of the EntryLo registers regardless of the word size of the host |
| 2133 | hardware, host kernel, guest, and whether XPA is present in the guest, i.e. |
| 2134 | with the RI and XI bits (if they exist) in bits 63 and 62 respectively, and |
| 2135 | the PFNX field starting at bit 30. |
| 2136 | |
James Hogan | d42a008 | 2017-03-14 10:15:38 +0000 | [diff] [blame] | 2137 | MIPS MAARs (see KVM_REG_MIPS_CP0_MAAR(*) above) have the following id bit |
| 2138 | patterns: |
| 2139 | 0x7030 0000 0001 01 <reg:8> |
| 2140 | |
James Hogan | c2d2c21 | 2014-07-04 15:11:35 +0100 | [diff] [blame] | 2141 | MIPS KVM control registers (see above) have the following id bit patterns: |
| 2142 | 0x7030 0000 0002 <reg:16> |
| 2143 | |
James Hogan | 379245c | 2014-12-02 15:48:24 +0000 | [diff] [blame] | 2144 | MIPS FPU registers (see KVM_REG_MIPS_FPR_{32,64}() above) have the following |
| 2145 | id bit patterns depending on the size of the register being accessed. They are |
| 2146 | always accessed according to the current guest FPU mode (Status.FR and |
| 2147 | Config5.FRE), i.e. as the guest would see them, and they become unpredictable |
James Hogan | ab86bd6 | 2014-12-02 15:48:24 +0000 | [diff] [blame] | 2148 | if the guest FPU mode is changed. MIPS SIMD Architecture (MSA) vector |
| 2149 | registers (see KVM_REG_MIPS_VEC_128() above) have similar patterns as they |
| 2150 | overlap the FPU registers: |
James Hogan | 379245c | 2014-12-02 15:48:24 +0000 | [diff] [blame] | 2151 | 0x7020 0000 0003 00 <0:3> <reg:5> (32-bit FPU registers) |
| 2152 | 0x7030 0000 0003 00 <0:3> <reg:5> (64-bit FPU registers) |
James Hogan | ab86bd6 | 2014-12-02 15:48:24 +0000 | [diff] [blame] | 2153 | 0x7040 0000 0003 00 <0:3> <reg:5> (128-bit MSA vector registers) |
James Hogan | 379245c | 2014-12-02 15:48:24 +0000 | [diff] [blame] | 2154 | |
| 2155 | MIPS FPU control registers (see KVM_REG_MIPS_FCR_{IR,CSR} above) have the |
| 2156 | following id bit patterns: |
| 2157 | 0x7020 0000 0003 01 <0:3> <reg:5> |
| 2158 | |
James Hogan | ab86bd6 | 2014-12-02 15:48:24 +0000 | [diff] [blame] | 2159 | MIPS MSA control registers (see KVM_REG_MIPS_MSA_{IR,CSR} above) have the |
| 2160 | following id bit patterns: |
| 2161 | 0x7020 0000 0003 02 <0:3> <reg:5> |
| 2162 | |
James Hogan | c2d2c21 | 2014-07-04 15:11:35 +0100 | [diff] [blame] | 2163 | |
Alexander Graf | e24ed81 | 2011-09-14 10:02:41 +0200 | [diff] [blame] | 2164 | 4.69 KVM_GET_ONE_REG |
| 2165 | |
| 2166 | Capability: KVM_CAP_ONE_REG |
| 2167 | Architectures: all |
| 2168 | Type: vcpu ioctl |
| 2169 | Parameters: struct kvm_one_reg (in and out) |
| 2170 | Returns: 0 on success, negative value on failure |
| 2171 | |
| 2172 | This ioctl allows to receive the value of a single register implemented |
| 2173 | in a vcpu. The register to read is indicated by the "id" field of the |
| 2174 | kvm_one_reg struct passed in. On success, the register value can be found |
| 2175 | at the memory location pointed to by "addr". |
| 2176 | |
| 2177 | The list of registers accessible using this interface is identical to the |
Bharat Bhushan | 2e23270 | 2012-08-15 17:37:13 +0000 | [diff] [blame] | 2178 | list in 4.68. |
Alexander Graf | e24ed81 | 2011-09-14 10:02:41 +0200 | [diff] [blame] | 2179 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 2180 | |
Eric B Munson | 1c0b28c | 2012-03-10 14:37:27 -0500 | [diff] [blame] | 2181 | 4.70 KVM_KVMCLOCK_CTRL |
| 2182 | |
| 2183 | Capability: KVM_CAP_KVMCLOCK_CTRL |
| 2184 | Architectures: Any that implement pvclocks (currently x86 only) |
| 2185 | Type: vcpu ioctl |
| 2186 | Parameters: None |
| 2187 | Returns: 0 on success, -1 on error |
| 2188 | |
| 2189 | This signals to the host kernel that the specified guest is being paused by |
| 2190 | userspace. The host will set a flag in the pvclock structure that is checked |
| 2191 | from the soft lockup watchdog. The flag is part of the pvclock structure that |
| 2192 | is shared between guest and host, specifically the second bit of the flags |
| 2193 | field of the pvclock_vcpu_time_info structure. It will be set exclusively by |
| 2194 | the host and read/cleared exclusively by the guest. The guest operation of |
| 2195 | checking and clearing the flag must an atomic operation so |
| 2196 | load-link/store-conditional, or equivalent must be used. There are two cases |
| 2197 | where the guest will clear the flag: when the soft lockup watchdog timer resets |
| 2198 | itself or when a soft lockup is detected. This ioctl can be called any time |
| 2199 | after pausing the vcpu, but before it is resumed. |
| 2200 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 2201 | |
Jan Kiszka | 07975ad | 2012-03-29 21:14:12 +0200 | [diff] [blame] | 2202 | 4.71 KVM_SIGNAL_MSI |
| 2203 | |
| 2204 | Capability: KVM_CAP_SIGNAL_MSI |
Vladimir Murzin | 2988509 | 2016-11-02 11:55:34 +0000 | [diff] [blame] | 2205 | Architectures: x86 arm arm64 |
Jan Kiszka | 07975ad | 2012-03-29 21:14:12 +0200 | [diff] [blame] | 2206 | Type: vm ioctl |
| 2207 | Parameters: struct kvm_msi (in) |
| 2208 | Returns: >0 on delivery, 0 if guest blocked the MSI, and -1 on error |
| 2209 | |
| 2210 | Directly inject a MSI message. Only valid with in-kernel irqchip that handles |
| 2211 | MSI messages. |
| 2212 | |
| 2213 | struct kvm_msi { |
| 2214 | __u32 address_lo; |
| 2215 | __u32 address_hi; |
| 2216 | __u32 data; |
| 2217 | __u32 flags; |
Andre Przywara | 2b8ddd9 | 2016-07-15 12:43:24 +0100 | [diff] [blame] | 2218 | __u32 devid; |
| 2219 | __u8 pad[12]; |
Jan Kiszka | 07975ad | 2012-03-29 21:14:12 +0200 | [diff] [blame] | 2220 | }; |
| 2221 | |
Paolo Bonzini | 6f49b2f | 2016-08-04 13:59:56 +0200 | [diff] [blame] | 2222 | flags: KVM_MSI_VALID_DEVID: devid contains a valid value. The per-VM |
| 2223 | KVM_CAP_MSI_DEVID capability advertises the requirement to provide |
| 2224 | the device ID. If this capability is not available, userspace |
| 2225 | should never set the KVM_MSI_VALID_DEVID flag as the ioctl might fail. |
Andre Przywara | 2b8ddd9 | 2016-07-15 12:43:24 +0100 | [diff] [blame] | 2226 | |
Paolo Bonzini | 6f49b2f | 2016-08-04 13:59:56 +0200 | [diff] [blame] | 2227 | If KVM_MSI_VALID_DEVID is set, devid contains a unique device identifier |
| 2228 | for the device that wrote the MSI message. For PCI, this is usually a |
| 2229 | BFD identifier in the lower 16 bits. |
Jan Kiszka | 07975ad | 2012-03-29 21:14:12 +0200 | [diff] [blame] | 2230 | |
Paolo Bonzini | 055b6ae | 2016-08-04 14:01:05 +0200 | [diff] [blame] | 2231 | On x86, address_hi is ignored unless the KVM_X2APIC_API_USE_32BIT_IDS |
| 2232 | feature of KVM_CAP_X2APIC_API capability is enabled. If it is enabled, |
| 2233 | address_hi bits 31-8 provide bits 31-8 of the destination id. Bits 7-0 of |
| 2234 | address_hi must be zero. |
Radim Krčmář | 37131313 | 2016-07-12 22:09:27 +0200 | [diff] [blame] | 2235 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 2236 | |
Jan Kiszka | 0589ff6 | 2012-04-24 16:40:16 +0200 | [diff] [blame] | 2237 | 4.71 KVM_CREATE_PIT2 |
| 2238 | |
| 2239 | Capability: KVM_CAP_PIT2 |
| 2240 | Architectures: x86 |
| 2241 | Type: vm ioctl |
| 2242 | Parameters: struct kvm_pit_config (in) |
| 2243 | Returns: 0 on success, -1 on error |
| 2244 | |
| 2245 | Creates an in-kernel device model for the i8254 PIT. This call is only valid |
| 2246 | after enabling in-kernel irqchip support via KVM_CREATE_IRQCHIP. The following |
| 2247 | parameters have to be passed: |
| 2248 | |
| 2249 | struct kvm_pit_config { |
| 2250 | __u32 flags; |
| 2251 | __u32 pad[15]; |
| 2252 | }; |
| 2253 | |
| 2254 | Valid flags are: |
| 2255 | |
| 2256 | #define KVM_PIT_SPEAKER_DUMMY 1 /* emulate speaker port stub */ |
| 2257 | |
Jan Kiszka | b6ddf05 | 2012-04-24 16:40:17 +0200 | [diff] [blame] | 2258 | PIT timer interrupts may use a per-VM kernel thread for injection. If it |
| 2259 | exists, this thread will have a name of the following pattern: |
| 2260 | |
| 2261 | kvm-pit/<owner-process-pid> |
| 2262 | |
| 2263 | When running a guest with elevated priorities, the scheduling parameters of |
| 2264 | this thread may have to be adjusted accordingly. |
| 2265 | |
Jan Kiszka | 0589ff6 | 2012-04-24 16:40:16 +0200 | [diff] [blame] | 2266 | This IOCTL replaces the obsolete KVM_CREATE_PIT. |
| 2267 | |
| 2268 | |
| 2269 | 4.72 KVM_GET_PIT2 |
| 2270 | |
| 2271 | Capability: KVM_CAP_PIT_STATE2 |
| 2272 | Architectures: x86 |
| 2273 | Type: vm ioctl |
| 2274 | Parameters: struct kvm_pit_state2 (out) |
| 2275 | Returns: 0 on success, -1 on error |
| 2276 | |
| 2277 | Retrieves the state of the in-kernel PIT model. Only valid after |
| 2278 | KVM_CREATE_PIT2. The state is returned in the following structure: |
| 2279 | |
| 2280 | struct kvm_pit_state2 { |
| 2281 | struct kvm_pit_channel_state channels[3]; |
| 2282 | __u32 flags; |
| 2283 | __u32 reserved[9]; |
| 2284 | }; |
| 2285 | |
| 2286 | Valid flags are: |
| 2287 | |
| 2288 | /* disable PIT in HPET legacy mode */ |
| 2289 | #define KVM_PIT_FLAGS_HPET_LEGACY 0x00000001 |
| 2290 | |
| 2291 | This IOCTL replaces the obsolete KVM_GET_PIT. |
| 2292 | |
| 2293 | |
| 2294 | 4.73 KVM_SET_PIT2 |
| 2295 | |
| 2296 | Capability: KVM_CAP_PIT_STATE2 |
| 2297 | Architectures: x86 |
| 2298 | Type: vm ioctl |
| 2299 | Parameters: struct kvm_pit_state2 (in) |
| 2300 | Returns: 0 on success, -1 on error |
| 2301 | |
| 2302 | Sets the state of the in-kernel PIT model. Only valid after KVM_CREATE_PIT2. |
| 2303 | See KVM_GET_PIT2 for details on struct kvm_pit_state2. |
| 2304 | |
| 2305 | This IOCTL replaces the obsolete KVM_SET_PIT. |
| 2306 | |
| 2307 | |
Benjamin Herrenschmidt | 5b74716 | 2012-04-26 19:43:42 +0000 | [diff] [blame] | 2308 | 4.74 KVM_PPC_GET_SMMU_INFO |
| 2309 | |
| 2310 | Capability: KVM_CAP_PPC_GET_SMMU_INFO |
| 2311 | Architectures: powerpc |
| 2312 | Type: vm ioctl |
| 2313 | Parameters: None |
| 2314 | Returns: 0 on success, -1 on error |
| 2315 | |
| 2316 | This populates and returns a structure describing the features of |
| 2317 | the "Server" class MMU emulation supported by KVM. |
Stefan Huber | cc22c35 | 2013-06-05 12:24:37 +0200 | [diff] [blame] | 2318 | This can in turn be used by userspace to generate the appropriate |
Benjamin Herrenschmidt | 5b74716 | 2012-04-26 19:43:42 +0000 | [diff] [blame] | 2319 | device-tree properties for the guest operating system. |
| 2320 | |
Carlos Garcia | c98be0c | 2014-04-04 22:31:00 -0400 | [diff] [blame] | 2321 | The structure contains some global information, followed by an |
Benjamin Herrenschmidt | 5b74716 | 2012-04-26 19:43:42 +0000 | [diff] [blame] | 2322 | array of supported segment page sizes: |
| 2323 | |
| 2324 | struct kvm_ppc_smmu_info { |
| 2325 | __u64 flags; |
| 2326 | __u32 slb_size; |
| 2327 | __u32 pad; |
| 2328 | struct kvm_ppc_one_seg_page_size sps[KVM_PPC_PAGE_SIZES_MAX_SZ]; |
| 2329 | }; |
| 2330 | |
| 2331 | The supported flags are: |
| 2332 | |
| 2333 | - KVM_PPC_PAGE_SIZES_REAL: |
| 2334 | When that flag is set, guest page sizes must "fit" the backing |
| 2335 | store page sizes. When not set, any page size in the list can |
| 2336 | be used regardless of how they are backed by userspace. |
| 2337 | |
| 2338 | - KVM_PPC_1T_SEGMENTS |
| 2339 | The emulated MMU supports 1T segments in addition to the |
| 2340 | standard 256M ones. |
| 2341 | |
Paul Mackerras | 901f8c3 | 2018-10-08 14:24:30 +1100 | [diff] [blame] | 2342 | - KVM_PPC_NO_HASH |
| 2343 | This flag indicates that HPT guests are not supported by KVM, |
| 2344 | thus all guests must use radix MMU mode. |
| 2345 | |
Benjamin Herrenschmidt | 5b74716 | 2012-04-26 19:43:42 +0000 | [diff] [blame] | 2346 | The "slb_size" field indicates how many SLB entries are supported |
| 2347 | |
| 2348 | The "sps" array contains 8 entries indicating the supported base |
| 2349 | page sizes for a segment in increasing order. Each entry is defined |
| 2350 | as follow: |
| 2351 | |
| 2352 | struct kvm_ppc_one_seg_page_size { |
| 2353 | __u32 page_shift; /* Base page shift of segment (or 0) */ |
| 2354 | __u32 slb_enc; /* SLB encoding for BookS */ |
| 2355 | struct kvm_ppc_one_page_size enc[KVM_PPC_PAGE_SIZES_MAX_SZ]; |
| 2356 | }; |
| 2357 | |
| 2358 | An entry with a "page_shift" of 0 is unused. Because the array is |
| 2359 | organized in increasing order, a lookup can stop when encoutering |
| 2360 | such an entry. |
| 2361 | |
| 2362 | The "slb_enc" field provides the encoding to use in the SLB for the |
| 2363 | page size. The bits are in positions such as the value can directly |
| 2364 | be OR'ed into the "vsid" argument of the slbmte instruction. |
| 2365 | |
| 2366 | The "enc" array is a list which for each of those segment base page |
| 2367 | size provides the list of supported actual page sizes (which can be |
| 2368 | only larger or equal to the base page size), along with the |
Anatol Pomozov | f884ab1 | 2013-05-08 16:56:16 -0700 | [diff] [blame] | 2369 | corresponding encoding in the hash PTE. Similarly, the array is |
Benjamin Herrenschmidt | 5b74716 | 2012-04-26 19:43:42 +0000 | [diff] [blame] | 2370 | 8 entries sorted by increasing sizes and an entry with a "0" shift |
| 2371 | is an empty entry and a terminator: |
| 2372 | |
| 2373 | struct kvm_ppc_one_page_size { |
| 2374 | __u32 page_shift; /* Page shift (or 0) */ |
| 2375 | __u32 pte_enc; /* Encoding in the HPTE (>>12) */ |
| 2376 | }; |
| 2377 | |
| 2378 | The "pte_enc" field provides a value that can OR'ed into the hash |
| 2379 | PTE's RPN field (ie, it needs to be shifted left by 12 to OR it |
| 2380 | into the hash PTE second double word). |
| 2381 | |
Alex Williamson | f36992e | 2012-06-29 09:56:16 -0600 | [diff] [blame] | 2382 | 4.75 KVM_IRQFD |
| 2383 | |
| 2384 | Capability: KVM_CAP_IRQFD |
Eric Auger | 174178f | 2015-03-04 11:14:36 +0100 | [diff] [blame] | 2385 | Architectures: x86 s390 arm arm64 |
Alex Williamson | f36992e | 2012-06-29 09:56:16 -0600 | [diff] [blame] | 2386 | Type: vm ioctl |
| 2387 | Parameters: struct kvm_irqfd (in) |
| 2388 | Returns: 0 on success, -1 on error |
| 2389 | |
| 2390 | Allows setting an eventfd to directly trigger a guest interrupt. |
| 2391 | kvm_irqfd.fd specifies the file descriptor to use as the eventfd and |
| 2392 | kvm_irqfd.gsi specifies the irqchip pin toggled by this event. When |
Masanari Iida | 1718003 | 2013-12-22 01:21:23 +0900 | [diff] [blame] | 2393 | an event is triggered on the eventfd, an interrupt is injected into |
Alex Williamson | f36992e | 2012-06-29 09:56:16 -0600 | [diff] [blame] | 2394 | the guest using the specified gsi pin. The irqfd is removed using |
| 2395 | the KVM_IRQFD_FLAG_DEASSIGN flag, specifying both kvm_irqfd.fd |
| 2396 | and kvm_irqfd.gsi. |
| 2397 | |
Alex Williamson | 7a84428 | 2012-09-21 11:58:03 -0600 | [diff] [blame] | 2398 | With KVM_CAP_IRQFD_RESAMPLE, KVM_IRQFD supports a de-assert and notify |
| 2399 | mechanism allowing emulation of level-triggered, irqfd-based |
| 2400 | interrupts. When KVM_IRQFD_FLAG_RESAMPLE is set the user must pass an |
| 2401 | additional eventfd in the kvm_irqfd.resamplefd field. When operating |
| 2402 | in resample mode, posting of an interrupt through kvm_irq.fd asserts |
| 2403 | the specified gsi in the irqchip. When the irqchip is resampled, such |
Masanari Iida | 1718003 | 2013-12-22 01:21:23 +0900 | [diff] [blame] | 2404 | as from an EOI, the gsi is de-asserted and the user is notified via |
Alex Williamson | 7a84428 | 2012-09-21 11:58:03 -0600 | [diff] [blame] | 2405 | kvm_irqfd.resamplefd. It is the user's responsibility to re-queue |
| 2406 | the interrupt if the device making use of it still requires service. |
| 2407 | Note that closing the resamplefd is not sufficient to disable the |
| 2408 | irqfd. The KVM_IRQFD_FLAG_RESAMPLE is only necessary on assignment |
| 2409 | and need not be specified with KVM_IRQFD_FLAG_DEASSIGN. |
| 2410 | |
Eric Auger | 180ae7b | 2016-07-22 16:20:41 +0000 | [diff] [blame] | 2411 | On arm/arm64, gsi routing being supported, the following can happen: |
| 2412 | - in case no routing entry is associated to this gsi, injection fails |
| 2413 | - in case the gsi is associated to an irqchip routing entry, |
| 2414 | irqchip.pin + 32 corresponds to the injected SPI ID. |
Eric Auger | 995a0ee | 2016-07-22 16:20:42 +0000 | [diff] [blame] | 2415 | - in case the gsi is associated to an MSI routing entry, the MSI |
| 2416 | message and device ID are translated into an LPI (support restricted |
| 2417 | to GICv3 ITS in-kernel emulation). |
Eric Auger | 174178f | 2015-03-04 11:14:36 +0100 | [diff] [blame] | 2418 | |
Linus Torvalds | 5fecc9d | 2012-07-24 12:01:20 -0700 | [diff] [blame] | 2419 | 4.76 KVM_PPC_ALLOCATE_HTAB |
Paul Mackerras | 32fad28 | 2012-05-04 02:32:53 +0000 | [diff] [blame] | 2420 | |
| 2421 | Capability: KVM_CAP_PPC_ALLOC_HTAB |
| 2422 | Architectures: powerpc |
| 2423 | Type: vm ioctl |
| 2424 | Parameters: Pointer to u32 containing hash table order (in/out) |
| 2425 | Returns: 0 on success, -1 on error |
| 2426 | |
| 2427 | This requests the host kernel to allocate an MMU hash table for a |
| 2428 | guest using the PAPR paravirtualization interface. This only does |
| 2429 | anything if the kernel is configured to use the Book 3S HV style of |
| 2430 | virtualization. Otherwise the capability doesn't exist and the ioctl |
| 2431 | returns an ENOTTY error. The rest of this description assumes Book 3S |
| 2432 | HV. |
| 2433 | |
| 2434 | There must be no vcpus running when this ioctl is called; if there |
| 2435 | are, it will do nothing and return an EBUSY error. |
| 2436 | |
| 2437 | The parameter is a pointer to a 32-bit unsigned integer variable |
| 2438 | containing the order (log base 2) of the desired size of the hash |
| 2439 | table, which must be between 18 and 46. On successful return from the |
David Gibson | f98a8bf | 2016-12-20 16:49:03 +1100 | [diff] [blame] | 2440 | ioctl, the value will not be changed by the kernel. |
Paul Mackerras | 32fad28 | 2012-05-04 02:32:53 +0000 | [diff] [blame] | 2441 | |
| 2442 | If no hash table has been allocated when any vcpu is asked to run |
| 2443 | (with the KVM_RUN ioctl), the host kernel will allocate a |
| 2444 | default-sized hash table (16 MB). |
| 2445 | |
| 2446 | If this ioctl is called when a hash table has already been allocated, |
David Gibson | f98a8bf | 2016-12-20 16:49:03 +1100 | [diff] [blame] | 2447 | with a different order from the existing hash table, the existing hash |
| 2448 | table will be freed and a new one allocated. If this is ioctl is |
| 2449 | called when a hash table has already been allocated of the same order |
| 2450 | as specified, the kernel will clear out the existing hash table (zero |
| 2451 | all HPTEs). In either case, if the guest is using the virtualized |
| 2452 | real-mode area (VRMA) facility, the kernel will re-create the VMRA |
| 2453 | HPTEs on the next KVM_RUN of any vcpu. |
Paul Mackerras | 32fad28 | 2012-05-04 02:32:53 +0000 | [diff] [blame] | 2454 | |
Cornelia Huck | 416ad65 | 2012-10-02 16:25:37 +0200 | [diff] [blame] | 2455 | 4.77 KVM_S390_INTERRUPT |
| 2456 | |
| 2457 | Capability: basic |
| 2458 | Architectures: s390 |
| 2459 | Type: vm ioctl, vcpu ioctl |
| 2460 | Parameters: struct kvm_s390_interrupt (in) |
| 2461 | Returns: 0 on success, -1 on error |
| 2462 | |
| 2463 | Allows to inject an interrupt to the guest. Interrupts can be floating |
| 2464 | (vm ioctl) or per cpu (vcpu ioctl), depending on the interrupt type. |
| 2465 | |
| 2466 | Interrupt parameters are passed via kvm_s390_interrupt: |
| 2467 | |
| 2468 | struct kvm_s390_interrupt { |
| 2469 | __u32 type; |
| 2470 | __u32 parm; |
| 2471 | __u64 parm64; |
| 2472 | }; |
| 2473 | |
| 2474 | type can be one of the following: |
| 2475 | |
David Hildenbrand | 2822545 | 2014-10-15 16:48:16 +0200 | [diff] [blame] | 2476 | KVM_S390_SIGP_STOP (vcpu) - sigp stop; optional flags in parm |
Cornelia Huck | 416ad65 | 2012-10-02 16:25:37 +0200 | [diff] [blame] | 2477 | KVM_S390_PROGRAM_INT (vcpu) - program check; code in parm |
| 2478 | KVM_S390_SIGP_SET_PREFIX (vcpu) - sigp set prefix; prefix address in parm |
| 2479 | KVM_S390_RESTART (vcpu) - restart |
Thomas Huth | e029ae5 | 2014-03-26 16:11:54 +0100 | [diff] [blame] | 2480 | KVM_S390_INT_CLOCK_COMP (vcpu) - clock comparator interrupt |
| 2481 | KVM_S390_INT_CPU_TIMER (vcpu) - CPU timer interrupt |
Cornelia Huck | 416ad65 | 2012-10-02 16:25:37 +0200 | [diff] [blame] | 2482 | KVM_S390_INT_VIRTIO (vm) - virtio external interrupt; external interrupt |
| 2483 | parameters in parm and parm64 |
| 2484 | KVM_S390_INT_SERVICE (vm) - sclp external interrupt; sclp parameter in parm |
| 2485 | KVM_S390_INT_EMERGENCY (vcpu) - sigp emergency; source cpu in parm |
| 2486 | KVM_S390_INT_EXTERNAL_CALL (vcpu) - sigp external call; source cpu in parm |
Cornelia Huck | d8346b7 | 2012-12-20 15:32:08 +0100 | [diff] [blame] | 2487 | KVM_S390_INT_IO(ai,cssid,ssid,schid) (vm) - compound value to indicate an |
| 2488 | I/O interrupt (ai - adapter interrupt; cssid,ssid,schid - subchannel); |
| 2489 | I/O interruption parameters in parm (subchannel) and parm64 (intparm, |
| 2490 | interruption subclass) |
Cornelia Huck | 48a3e95 | 2012-12-20 15:32:09 +0100 | [diff] [blame] | 2491 | KVM_S390_MCHK (vm, vcpu) - machine check interrupt; cr 14 bits in parm, |
| 2492 | machine check interrupt code in parm64 (note that |
| 2493 | machine checks needing further payload are not |
| 2494 | supported by this ioctl) |
Cornelia Huck | 416ad65 | 2012-10-02 16:25:37 +0200 | [diff] [blame] | 2495 | |
| 2496 | Note that the vcpu ioctl is asynchronous to vcpu execution. |
| 2497 | |
Paul Mackerras | a293292 | 2012-11-19 22:57:20 +0000 | [diff] [blame] | 2498 | 4.78 KVM_PPC_GET_HTAB_FD |
| 2499 | |
| 2500 | Capability: KVM_CAP_PPC_HTAB_FD |
| 2501 | Architectures: powerpc |
| 2502 | Type: vm ioctl |
| 2503 | Parameters: Pointer to struct kvm_get_htab_fd (in) |
| 2504 | Returns: file descriptor number (>= 0) on success, -1 on error |
| 2505 | |
| 2506 | This returns a file descriptor that can be used either to read out the |
| 2507 | entries in the guest's hashed page table (HPT), or to write entries to |
| 2508 | initialize the HPT. The returned fd can only be written to if the |
| 2509 | KVM_GET_HTAB_WRITE bit is set in the flags field of the argument, and |
| 2510 | can only be read if that bit is clear. The argument struct looks like |
| 2511 | this: |
| 2512 | |
| 2513 | /* For KVM_PPC_GET_HTAB_FD */ |
| 2514 | struct kvm_get_htab_fd { |
| 2515 | __u64 flags; |
| 2516 | __u64 start_index; |
| 2517 | __u64 reserved[2]; |
| 2518 | }; |
| 2519 | |
| 2520 | /* Values for kvm_get_htab_fd.flags */ |
| 2521 | #define KVM_GET_HTAB_BOLTED_ONLY ((__u64)0x1) |
| 2522 | #define KVM_GET_HTAB_WRITE ((__u64)0x2) |
| 2523 | |
| 2524 | The `start_index' field gives the index in the HPT of the entry at |
| 2525 | which to start reading. It is ignored when writing. |
| 2526 | |
| 2527 | Reads on the fd will initially supply information about all |
| 2528 | "interesting" HPT entries. Interesting entries are those with the |
| 2529 | bolted bit set, if the KVM_GET_HTAB_BOLTED_ONLY bit is set, otherwise |
| 2530 | all entries. When the end of the HPT is reached, the read() will |
| 2531 | return. If read() is called again on the fd, it will start again from |
| 2532 | the beginning of the HPT, but will only return HPT entries that have |
| 2533 | changed since they were last read. |
| 2534 | |
| 2535 | Data read or written is structured as a header (8 bytes) followed by a |
| 2536 | series of valid HPT entries (16 bytes) each. The header indicates how |
| 2537 | many valid HPT entries there are and how many invalid entries follow |
| 2538 | the valid entries. The invalid entries are not represented explicitly |
| 2539 | in the stream. The header format is: |
| 2540 | |
| 2541 | struct kvm_get_htab_header { |
| 2542 | __u32 index; |
| 2543 | __u16 n_valid; |
| 2544 | __u16 n_invalid; |
| 2545 | }; |
| 2546 | |
| 2547 | Writes to the fd create HPT entries starting at the index given in the |
| 2548 | header; first `n_valid' valid entries with contents from the data |
| 2549 | written, then `n_invalid' invalid entries, invalidating any previously |
| 2550 | valid entries found. |
| 2551 | |
Scott Wood | 852b6d5 | 2013-04-12 14:08:42 +0000 | [diff] [blame] | 2552 | 4.79 KVM_CREATE_DEVICE |
| 2553 | |
| 2554 | Capability: KVM_CAP_DEVICE_CTRL |
| 2555 | Type: vm ioctl |
| 2556 | Parameters: struct kvm_create_device (in/out) |
| 2557 | Returns: 0 on success, -1 on error |
| 2558 | Errors: |
| 2559 | ENODEV: The device type is unknown or unsupported |
| 2560 | EEXIST: Device already created, and this type of device may not |
| 2561 | be instantiated multiple times |
| 2562 | |
| 2563 | Other error conditions may be defined by individual device types or |
| 2564 | have their standard meanings. |
| 2565 | |
| 2566 | Creates an emulated device in the kernel. The file descriptor returned |
| 2567 | in fd can be used with KVM_SET/GET/HAS_DEVICE_ATTR. |
| 2568 | |
| 2569 | If the KVM_CREATE_DEVICE_TEST flag is set, only test whether the |
| 2570 | device type is supported (not necessarily whether it can be created |
| 2571 | in the current vm). |
| 2572 | |
| 2573 | Individual devices should not define flags. Attributes should be used |
| 2574 | for specifying any behavior that is not implied by the device type |
| 2575 | number. |
| 2576 | |
| 2577 | struct kvm_create_device { |
| 2578 | __u32 type; /* in: KVM_DEV_TYPE_xxx */ |
| 2579 | __u32 fd; /* out: device handle */ |
| 2580 | __u32 flags; /* in: KVM_CREATE_DEVICE_xxx */ |
| 2581 | }; |
| 2582 | |
| 2583 | 4.80 KVM_SET_DEVICE_ATTR/KVM_GET_DEVICE_ATTR |
| 2584 | |
Shannon Zhao | f577f6c | 2016-01-11 20:56:17 +0800 | [diff] [blame] | 2585 | Capability: KVM_CAP_DEVICE_CTRL, KVM_CAP_VM_ATTRIBUTES for vm device, |
| 2586 | KVM_CAP_VCPU_ATTRIBUTES for vcpu device |
| 2587 | Type: device ioctl, vm ioctl, vcpu ioctl |
Scott Wood | 852b6d5 | 2013-04-12 14:08:42 +0000 | [diff] [blame] | 2588 | Parameters: struct kvm_device_attr |
| 2589 | Returns: 0 on success, -1 on error |
| 2590 | Errors: |
| 2591 | ENXIO: The group or attribute is unknown/unsupported for this device |
David Hildenbrand | f9cbd9b | 2016-03-03 09:48:47 +0100 | [diff] [blame] | 2592 | or hardware support is missing. |
Scott Wood | 852b6d5 | 2013-04-12 14:08:42 +0000 | [diff] [blame] | 2593 | EPERM: The attribute cannot (currently) be accessed this way |
| 2594 | (e.g. read-only attribute, or attribute that only makes |
| 2595 | sense when the device is in a different state) |
| 2596 | |
| 2597 | Other error conditions may be defined by individual device types. |
| 2598 | |
| 2599 | Gets/sets a specified piece of device configuration and/or state. The |
| 2600 | semantics are device-specific. See individual device documentation in |
| 2601 | the "devices" directory. As with ONE_REG, the size of the data |
| 2602 | transferred is defined by the particular attribute. |
| 2603 | |
| 2604 | struct kvm_device_attr { |
| 2605 | __u32 flags; /* no flags currently defined */ |
| 2606 | __u32 group; /* device-defined */ |
| 2607 | __u64 attr; /* group-defined */ |
| 2608 | __u64 addr; /* userspace address of attr data */ |
| 2609 | }; |
| 2610 | |
| 2611 | 4.81 KVM_HAS_DEVICE_ATTR |
| 2612 | |
Shannon Zhao | f577f6c | 2016-01-11 20:56:17 +0800 | [diff] [blame] | 2613 | Capability: KVM_CAP_DEVICE_CTRL, KVM_CAP_VM_ATTRIBUTES for vm device, |
| 2614 | KVM_CAP_VCPU_ATTRIBUTES for vcpu device |
| 2615 | Type: device ioctl, vm ioctl, vcpu ioctl |
Scott Wood | 852b6d5 | 2013-04-12 14:08:42 +0000 | [diff] [blame] | 2616 | Parameters: struct kvm_device_attr |
| 2617 | Returns: 0 on success, -1 on error |
| 2618 | Errors: |
| 2619 | ENXIO: The group or attribute is unknown/unsupported for this device |
David Hildenbrand | f9cbd9b | 2016-03-03 09:48:47 +0100 | [diff] [blame] | 2620 | or hardware support is missing. |
Scott Wood | 852b6d5 | 2013-04-12 14:08:42 +0000 | [diff] [blame] | 2621 | |
| 2622 | Tests whether a device supports a particular attribute. A successful |
| 2623 | return indicates the attribute is implemented. It does not necessarily |
| 2624 | indicate that the attribute can be read or written in the device's |
| 2625 | current state. "addr" is ignored. |
Alex Williamson | f36992e | 2012-06-29 09:56:16 -0600 | [diff] [blame] | 2626 | |
Alexey Kardashevskiy | d8968f1 | 2013-06-19 11:42:07 +1000 | [diff] [blame] | 2627 | 4.82 KVM_ARM_VCPU_INIT |
Christoffer Dall | 749cf76c | 2013-01-20 18:28:06 -0500 | [diff] [blame] | 2628 | |
| 2629 | Capability: basic |
Marc Zyngier | 379e04c7 | 2013-04-02 17:46:31 +0100 | [diff] [blame] | 2630 | Architectures: arm, arm64 |
Christoffer Dall | 749cf76c | 2013-01-20 18:28:06 -0500 | [diff] [blame] | 2631 | Type: vcpu ioctl |
Anup Patel | beb11fc | 2013-12-12 21:42:24 +0530 | [diff] [blame] | 2632 | Parameters: struct kvm_vcpu_init (in) |
Christoffer Dall | 749cf76c | 2013-01-20 18:28:06 -0500 | [diff] [blame] | 2633 | Returns: 0 on success; -1 on error |
| 2634 | Errors: |
| 2635 | EINVAL: the target is unknown, or the combination of features is invalid. |
| 2636 | ENOENT: a features bit specified is unknown. |
| 2637 | |
| 2638 | This tells KVM what type of CPU to present to the guest, and what |
| 2639 | optional features it should have. This will cause a reset of the cpu |
| 2640 | registers to their initial values. If this is not called, KVM_RUN will |
| 2641 | return ENOEXEC for that vcpu. |
| 2642 | |
| 2643 | Note that because some registers reflect machine topology, all vcpus |
| 2644 | should be created before this ioctl is invoked. |
| 2645 | |
Christoffer Dall | f7fa034d | 2014-10-16 16:40:53 +0200 | [diff] [blame] | 2646 | Userspace can call this function multiple times for a given vcpu, including |
| 2647 | after the vcpu has been run. This will reset the vcpu to its initial |
| 2648 | state. All calls to this function after the initial call must use the same |
| 2649 | target and same set of feature flags, otherwise EINVAL will be returned. |
| 2650 | |
Marc Zyngier | aa024c2 | 2013-01-20 18:28:13 -0500 | [diff] [blame] | 2651 | Possible features: |
| 2652 | - KVM_ARM_VCPU_POWER_OFF: Starts the CPU in a power-off state. |
Christoffer Dall | 3ad8b3d | 2014-10-16 16:14:43 +0200 | [diff] [blame] | 2653 | Depends on KVM_CAP_ARM_PSCI. If not set, the CPU will be powered on |
| 2654 | and execute guest code when KVM_RUN is called. |
Marc Zyngier | 379e04c7 | 2013-04-02 17:46:31 +0100 | [diff] [blame] | 2655 | - KVM_ARM_VCPU_EL1_32BIT: Starts the CPU in a 32bit mode. |
| 2656 | Depends on KVM_CAP_ARM_EL1_32BIT (arm64 only). |
Marc Zyngier | 85bd0ba | 2018-01-21 16:42:56 +0000 | [diff] [blame] | 2657 | - KVM_ARM_VCPU_PSCI_0_2: Emulate PSCI v0.2 (or a future revision |
| 2658 | backward compatible with v0.2) for the CPU. |
Anup Patel | 50bb0c9 | 2014-04-29 11:24:17 +0530 | [diff] [blame] | 2659 | Depends on KVM_CAP_ARM_PSCI_0_2. |
Shannon Zhao | 808e738 | 2016-01-11 22:46:15 +0800 | [diff] [blame] | 2660 | - KVM_ARM_VCPU_PMU_V3: Emulate PMUv3 for the CPU. |
| 2661 | Depends on KVM_CAP_ARM_PMU_V3. |
Marc Zyngier | aa024c2 | 2013-01-20 18:28:13 -0500 | [diff] [blame] | 2662 | |
Christoffer Dall | 749cf76c | 2013-01-20 18:28:06 -0500 | [diff] [blame] | 2663 | |
Anup Patel | 740edfc | 2013-09-30 14:20:08 +0530 | [diff] [blame] | 2664 | 4.83 KVM_ARM_PREFERRED_TARGET |
| 2665 | |
| 2666 | Capability: basic |
| 2667 | Architectures: arm, arm64 |
| 2668 | Type: vm ioctl |
| 2669 | Parameters: struct struct kvm_vcpu_init (out) |
| 2670 | Returns: 0 on success; -1 on error |
| 2671 | Errors: |
Christoffer Dall | a7265fb | 2013-10-15 17:43:00 -0700 | [diff] [blame] | 2672 | ENODEV: no preferred target available for the host |
Anup Patel | 740edfc | 2013-09-30 14:20:08 +0530 | [diff] [blame] | 2673 | |
| 2674 | This queries KVM for preferred CPU target type which can be emulated |
| 2675 | by KVM on underlying host. |
| 2676 | |
| 2677 | The ioctl returns struct kvm_vcpu_init instance containing information |
| 2678 | about preferred CPU target type and recommended features for it. The |
| 2679 | kvm_vcpu_init->features bitmap returned will have feature bits set if |
| 2680 | the preferred target recommends setting these features, but this is |
| 2681 | not mandatory. |
| 2682 | |
| 2683 | The information returned by this ioctl can be used to prepare an instance |
| 2684 | of struct kvm_vcpu_init for KVM_ARM_VCPU_INIT ioctl which will result in |
| 2685 | in VCPU matching underlying host. |
| 2686 | |
| 2687 | |
| 2688 | 4.84 KVM_GET_REG_LIST |
Christoffer Dall | 749cf76c | 2013-01-20 18:28:06 -0500 | [diff] [blame] | 2689 | |
| 2690 | Capability: basic |
James Hogan | c2d2c21 | 2014-07-04 15:11:35 +0100 | [diff] [blame] | 2691 | Architectures: arm, arm64, mips |
Christoffer Dall | 749cf76c | 2013-01-20 18:28:06 -0500 | [diff] [blame] | 2692 | Type: vcpu ioctl |
| 2693 | Parameters: struct kvm_reg_list (in/out) |
| 2694 | Returns: 0 on success; -1 on error |
| 2695 | Errors: |
| 2696 | E2BIG: the reg index list is too big to fit in the array specified by |
| 2697 | the user (the number required will be written into n). |
| 2698 | |
| 2699 | struct kvm_reg_list { |
| 2700 | __u64 n; /* number of registers in reg[] */ |
| 2701 | __u64 reg[0]; |
| 2702 | }; |
| 2703 | |
| 2704 | This ioctl returns the guest registers that are supported for the |
| 2705 | KVM_GET_ONE_REG/KVM_SET_ONE_REG calls. |
| 2706 | |
Christoffer Dall | ce01e4e | 2013-09-23 14:55:56 -0700 | [diff] [blame] | 2707 | |
| 2708 | 4.85 KVM_ARM_SET_DEVICE_ADDR (deprecated) |
Christoffer Dall | 3401d546 | 2013-01-23 13:18:04 -0500 | [diff] [blame] | 2709 | |
| 2710 | Capability: KVM_CAP_ARM_SET_DEVICE_ADDR |
Marc Zyngier | 379e04c7 | 2013-04-02 17:46:31 +0100 | [diff] [blame] | 2711 | Architectures: arm, arm64 |
Christoffer Dall | 3401d546 | 2013-01-23 13:18:04 -0500 | [diff] [blame] | 2712 | Type: vm ioctl |
| 2713 | Parameters: struct kvm_arm_device_address (in) |
| 2714 | Returns: 0 on success, -1 on error |
| 2715 | Errors: |
| 2716 | ENODEV: The device id is unknown |
| 2717 | ENXIO: Device not supported on current system |
| 2718 | EEXIST: Address already set |
| 2719 | E2BIG: Address outside guest physical address space |
Christoffer Dall | 330690c | 2013-01-21 19:36:13 -0500 | [diff] [blame] | 2720 | EBUSY: Address overlaps with other device range |
Christoffer Dall | 3401d546 | 2013-01-23 13:18:04 -0500 | [diff] [blame] | 2721 | |
| 2722 | struct kvm_arm_device_addr { |
| 2723 | __u64 id; |
| 2724 | __u64 addr; |
| 2725 | }; |
| 2726 | |
| 2727 | Specify a device address in the guest's physical address space where guests |
| 2728 | can access emulated or directly exposed devices, which the host kernel needs |
| 2729 | to know about. The id field is an architecture specific identifier for a |
| 2730 | specific device. |
| 2731 | |
Marc Zyngier | 379e04c7 | 2013-04-02 17:46:31 +0100 | [diff] [blame] | 2732 | ARM/arm64 divides the id field into two parts, a device id and an |
| 2733 | address type id specific to the individual device. |
Christoffer Dall | 3401d546 | 2013-01-23 13:18:04 -0500 | [diff] [blame] | 2734 | |
| 2735 | bits: | 63 ... 32 | 31 ... 16 | 15 ... 0 | |
| 2736 | field: | 0x00000000 | device id | addr type id | |
| 2737 | |
Marc Zyngier | 379e04c7 | 2013-04-02 17:46:31 +0100 | [diff] [blame] | 2738 | ARM/arm64 currently only require this when using the in-kernel GIC |
| 2739 | support for the hardware VGIC features, using KVM_ARM_DEVICE_VGIC_V2 |
| 2740 | as the device id. When setting the base address for the guest's |
| 2741 | mapping of the VGIC virtual CPU and distributor interface, the ioctl |
| 2742 | must be called after calling KVM_CREATE_IRQCHIP, but before calling |
| 2743 | KVM_RUN on any of the VCPUs. Calling this ioctl twice for any of the |
| 2744 | base addresses will return -EEXIST. |
Christoffer Dall | 3401d546 | 2013-01-23 13:18:04 -0500 | [diff] [blame] | 2745 | |
Christoffer Dall | ce01e4e | 2013-09-23 14:55:56 -0700 | [diff] [blame] | 2746 | Note, this IOCTL is deprecated and the more flexible SET/GET_DEVICE_ATTR API |
| 2747 | should be used instead. |
| 2748 | |
| 2749 | |
Anup Patel | 740edfc | 2013-09-30 14:20:08 +0530 | [diff] [blame] | 2750 | 4.86 KVM_PPC_RTAS_DEFINE_TOKEN |
Michael Ellerman | 8e591cb | 2013-04-17 20:30:00 +0000 | [diff] [blame] | 2751 | |
| 2752 | Capability: KVM_CAP_PPC_RTAS |
| 2753 | Architectures: ppc |
| 2754 | Type: vm ioctl |
| 2755 | Parameters: struct kvm_rtas_token_args |
| 2756 | Returns: 0 on success, -1 on error |
| 2757 | |
| 2758 | Defines a token value for a RTAS (Run Time Abstraction Services) |
| 2759 | service in order to allow it to be handled in the kernel. The |
| 2760 | argument struct gives the name of the service, which must be the name |
| 2761 | of a service that has a kernel-side implementation. If the token |
| 2762 | value is non-zero, it will be associated with that service, and |
| 2763 | subsequent RTAS calls by the guest specifying that token will be |
| 2764 | handled by the kernel. If the token value is 0, then any token |
| 2765 | associated with the service will be forgotten, and subsequent RTAS |
| 2766 | calls by the guest for that service will be passed to userspace to be |
| 2767 | handled. |
| 2768 | |
Alex Bennée | 4bd9d34 | 2014-09-09 17:27:18 +0100 | [diff] [blame] | 2769 | 4.87 KVM_SET_GUEST_DEBUG |
| 2770 | |
| 2771 | Capability: KVM_CAP_SET_GUEST_DEBUG |
Alex Bennée | 0e6f07f | 2015-07-07 17:29:55 +0100 | [diff] [blame] | 2772 | Architectures: x86, s390, ppc, arm64 |
Alex Bennée | 4bd9d34 | 2014-09-09 17:27:18 +0100 | [diff] [blame] | 2773 | Type: vcpu ioctl |
| 2774 | Parameters: struct kvm_guest_debug (in) |
| 2775 | Returns: 0 on success; -1 on error |
| 2776 | |
| 2777 | struct kvm_guest_debug { |
| 2778 | __u32 control; |
| 2779 | __u32 pad; |
| 2780 | struct kvm_guest_debug_arch arch; |
| 2781 | }; |
| 2782 | |
| 2783 | Set up the processor specific debug registers and configure vcpu for |
| 2784 | handling guest debug events. There are two parts to the structure, the |
| 2785 | first a control bitfield indicates the type of debug events to handle |
| 2786 | when running. Common control bits are: |
| 2787 | |
| 2788 | - KVM_GUESTDBG_ENABLE: guest debugging is enabled |
| 2789 | - KVM_GUESTDBG_SINGLESTEP: the next run should single-step |
| 2790 | |
| 2791 | The top 16 bits of the control field are architecture specific control |
| 2792 | flags which can include the following: |
| 2793 | |
Alex Bennée | 4bd611c | 2015-07-07 17:29:57 +0100 | [diff] [blame] | 2794 | - KVM_GUESTDBG_USE_SW_BP: using software breakpoints [x86, arm64] |
Alex Bennée | 834bf88 | 2015-07-07 17:30:02 +0100 | [diff] [blame] | 2795 | - KVM_GUESTDBG_USE_HW_BP: using hardware breakpoints [x86, s390, arm64] |
Alex Bennée | 4bd9d34 | 2014-09-09 17:27:18 +0100 | [diff] [blame] | 2796 | - KVM_GUESTDBG_INJECT_DB: inject DB type exception [x86] |
| 2797 | - KVM_GUESTDBG_INJECT_BP: inject BP type exception [x86] |
| 2798 | - KVM_GUESTDBG_EXIT_PENDING: trigger an immediate guest exit [s390] |
| 2799 | |
| 2800 | For example KVM_GUESTDBG_USE_SW_BP indicates that software breakpoints |
| 2801 | are enabled in memory so we need to ensure breakpoint exceptions are |
| 2802 | correctly trapped and the KVM run loop exits at the breakpoint and not |
| 2803 | running off into the normal guest vector. For KVM_GUESTDBG_USE_HW_BP |
| 2804 | we need to ensure the guest vCPUs architecture specific registers are |
| 2805 | updated to the correct (supplied) values. |
| 2806 | |
| 2807 | The second part of the structure is architecture specific and |
| 2808 | typically contains a set of debug registers. |
| 2809 | |
Alex Bennée | 834bf88 | 2015-07-07 17:30:02 +0100 | [diff] [blame] | 2810 | For arm64 the number of debug registers is implementation defined and |
| 2811 | can be determined by querying the KVM_CAP_GUEST_DEBUG_HW_BPS and |
| 2812 | KVM_CAP_GUEST_DEBUG_HW_WPS capabilities which return a positive number |
| 2813 | indicating the number of supported registers. |
| 2814 | |
Alex Bennée | 4bd9d34 | 2014-09-09 17:27:18 +0100 | [diff] [blame] | 2815 | When debug events exit the main run loop with the reason |
| 2816 | KVM_EXIT_DEBUG with the kvm_debug_exit_arch part of the kvm_run |
| 2817 | structure containing architecture specific debug information. |
Christoffer Dall | 3401d546 | 2013-01-23 13:18:04 -0500 | [diff] [blame] | 2818 | |
Alex Bennée | 209cf19 | 2014-09-09 17:27:19 +0100 | [diff] [blame] | 2819 | 4.88 KVM_GET_EMULATED_CPUID |
| 2820 | |
| 2821 | Capability: KVM_CAP_EXT_EMUL_CPUID |
| 2822 | Architectures: x86 |
| 2823 | Type: system ioctl |
| 2824 | Parameters: struct kvm_cpuid2 (in/out) |
| 2825 | Returns: 0 on success, -1 on error |
| 2826 | |
| 2827 | struct kvm_cpuid2 { |
| 2828 | __u32 nent; |
| 2829 | __u32 flags; |
| 2830 | struct kvm_cpuid_entry2 entries[0]; |
| 2831 | }; |
| 2832 | |
| 2833 | The member 'flags' is used for passing flags from userspace. |
| 2834 | |
| 2835 | #define KVM_CPUID_FLAG_SIGNIFCANT_INDEX BIT(0) |
| 2836 | #define KVM_CPUID_FLAG_STATEFUL_FUNC BIT(1) |
| 2837 | #define KVM_CPUID_FLAG_STATE_READ_NEXT BIT(2) |
| 2838 | |
| 2839 | struct kvm_cpuid_entry2 { |
| 2840 | __u32 function; |
| 2841 | __u32 index; |
| 2842 | __u32 flags; |
| 2843 | __u32 eax; |
| 2844 | __u32 ebx; |
| 2845 | __u32 ecx; |
| 2846 | __u32 edx; |
| 2847 | __u32 padding[3]; |
| 2848 | }; |
| 2849 | |
| 2850 | This ioctl returns x86 cpuid features which are emulated by |
| 2851 | kvm.Userspace can use the information returned by this ioctl to query |
| 2852 | which features are emulated by kvm instead of being present natively. |
| 2853 | |
| 2854 | Userspace invokes KVM_GET_EMULATED_CPUID by passing a kvm_cpuid2 |
| 2855 | structure with the 'nent' field indicating the number of entries in |
| 2856 | the variable-size array 'entries'. If the number of entries is too low |
| 2857 | to describe the cpu capabilities, an error (E2BIG) is returned. If the |
| 2858 | number is too high, the 'nent' field is adjusted and an error (ENOMEM) |
| 2859 | is returned. If the number is just right, the 'nent' field is adjusted |
| 2860 | to the number of valid entries in the 'entries' array, which is then |
| 2861 | filled. |
| 2862 | |
| 2863 | The entries returned are the set CPUID bits of the respective features |
| 2864 | which kvm emulates, as returned by the CPUID instruction, with unknown |
| 2865 | or unsupported feature bits cleared. |
| 2866 | |
| 2867 | Features like x2apic, for example, may not be present in the host cpu |
| 2868 | but are exposed by kvm in KVM_GET_SUPPORTED_CPUID because they can be |
| 2869 | emulated efficiently and thus not included here. |
| 2870 | |
| 2871 | The fields in each entry are defined as follows: |
| 2872 | |
| 2873 | function: the eax value used to obtain the entry |
| 2874 | index: the ecx value used to obtain the entry (for entries that are |
| 2875 | affected by ecx) |
| 2876 | flags: an OR of zero or more of the following: |
| 2877 | KVM_CPUID_FLAG_SIGNIFCANT_INDEX: |
| 2878 | if the index field is valid |
| 2879 | KVM_CPUID_FLAG_STATEFUL_FUNC: |
| 2880 | if cpuid for this function returns different values for successive |
| 2881 | invocations; there will be several entries with the same function, |
| 2882 | all with this flag set |
| 2883 | KVM_CPUID_FLAG_STATE_READ_NEXT: |
| 2884 | for KVM_CPUID_FLAG_STATEFUL_FUNC entries, set if this entry is |
| 2885 | the first entry to be read by a cpu |
| 2886 | eax, ebx, ecx, edx: the values returned by the cpuid instruction for |
| 2887 | this function/index combination |
| 2888 | |
Thomas Huth | 41408c28 | 2015-02-06 15:01:21 +0100 | [diff] [blame] | 2889 | 4.89 KVM_S390_MEM_OP |
| 2890 | |
| 2891 | Capability: KVM_CAP_S390_MEM_OP |
| 2892 | Architectures: s390 |
| 2893 | Type: vcpu ioctl |
| 2894 | Parameters: struct kvm_s390_mem_op (in) |
| 2895 | Returns: = 0 on success, |
| 2896 | < 0 on generic error (e.g. -EFAULT or -ENOMEM), |
| 2897 | > 0 if an exception occurred while walking the page tables |
| 2898 | |
Masanari Iida | 5d4f6f3 | 2015-10-04 00:46:21 +0900 | [diff] [blame] | 2899 | Read or write data from/to the logical (virtual) memory of a VCPU. |
Thomas Huth | 41408c28 | 2015-02-06 15:01:21 +0100 | [diff] [blame] | 2900 | |
| 2901 | Parameters are specified via the following structure: |
| 2902 | |
| 2903 | struct kvm_s390_mem_op { |
| 2904 | __u64 gaddr; /* the guest address */ |
| 2905 | __u64 flags; /* flags */ |
| 2906 | __u32 size; /* amount of bytes */ |
| 2907 | __u32 op; /* type of operation */ |
| 2908 | __u64 buf; /* buffer in userspace */ |
| 2909 | __u8 ar; /* the access register number */ |
| 2910 | __u8 reserved[31]; /* should be set to 0 */ |
| 2911 | }; |
| 2912 | |
| 2913 | The type of operation is specified in the "op" field. It is either |
| 2914 | KVM_S390_MEMOP_LOGICAL_READ for reading from logical memory space or |
| 2915 | KVM_S390_MEMOP_LOGICAL_WRITE for writing to logical memory space. The |
| 2916 | KVM_S390_MEMOP_F_CHECK_ONLY flag can be set in the "flags" field to check |
| 2917 | whether the corresponding memory access would create an access exception |
| 2918 | (without touching the data in the memory at the destination). In case an |
| 2919 | access exception occurred while walking the MMU tables of the guest, the |
| 2920 | ioctl returns a positive error number to indicate the type of exception. |
| 2921 | This exception is also raised directly at the corresponding VCPU if the |
| 2922 | flag KVM_S390_MEMOP_F_INJECT_EXCEPTION is set in the "flags" field. |
| 2923 | |
| 2924 | The start address of the memory region has to be specified in the "gaddr" |
| 2925 | field, and the length of the region in the "size" field. "buf" is the buffer |
| 2926 | supplied by the userspace application where the read data should be written |
| 2927 | to for KVM_S390_MEMOP_LOGICAL_READ, or where the data that should be written |
| 2928 | is stored for a KVM_S390_MEMOP_LOGICAL_WRITE. "buf" is unused and can be NULL |
| 2929 | when KVM_S390_MEMOP_F_CHECK_ONLY is specified. "ar" designates the access |
| 2930 | register number to be used. |
| 2931 | |
| 2932 | The "reserved" field is meant for future extensions. It is not used by |
| 2933 | KVM with the currently defined set of flags. |
| 2934 | |
Jason J. Herne | 30ee2a9 | 2014-09-23 09:23:01 -0400 | [diff] [blame] | 2935 | 4.90 KVM_S390_GET_SKEYS |
| 2936 | |
| 2937 | Capability: KVM_CAP_S390_SKEYS |
| 2938 | Architectures: s390 |
| 2939 | Type: vm ioctl |
| 2940 | Parameters: struct kvm_s390_skeys |
| 2941 | Returns: 0 on success, KVM_S390_GET_KEYS_NONE if guest is not using storage |
| 2942 | keys, negative value on error |
| 2943 | |
| 2944 | This ioctl is used to get guest storage key values on the s390 |
| 2945 | architecture. The ioctl takes parameters via the kvm_s390_skeys struct. |
| 2946 | |
| 2947 | struct kvm_s390_skeys { |
| 2948 | __u64 start_gfn; |
| 2949 | __u64 count; |
| 2950 | __u64 skeydata_addr; |
| 2951 | __u32 flags; |
| 2952 | __u32 reserved[9]; |
| 2953 | }; |
| 2954 | |
| 2955 | The start_gfn field is the number of the first guest frame whose storage keys |
| 2956 | you want to get. |
| 2957 | |
| 2958 | The count field is the number of consecutive frames (starting from start_gfn) |
| 2959 | whose storage keys to get. The count field must be at least 1 and the maximum |
| 2960 | allowed value is defined as KVM_S390_SKEYS_ALLOC_MAX. Values outside this range |
| 2961 | will cause the ioctl to return -EINVAL. |
| 2962 | |
| 2963 | The skeydata_addr field is the address to a buffer large enough to hold count |
| 2964 | bytes. This buffer will be filled with storage key data by the ioctl. |
| 2965 | |
| 2966 | 4.91 KVM_S390_SET_SKEYS |
| 2967 | |
| 2968 | Capability: KVM_CAP_S390_SKEYS |
| 2969 | Architectures: s390 |
| 2970 | Type: vm ioctl |
| 2971 | Parameters: struct kvm_s390_skeys |
| 2972 | Returns: 0 on success, negative value on error |
| 2973 | |
| 2974 | This ioctl is used to set guest storage key values on the s390 |
| 2975 | architecture. The ioctl takes parameters via the kvm_s390_skeys struct. |
| 2976 | See section on KVM_S390_GET_SKEYS for struct definition. |
| 2977 | |
| 2978 | The start_gfn field is the number of the first guest frame whose storage keys |
| 2979 | you want to set. |
| 2980 | |
| 2981 | The count field is the number of consecutive frames (starting from start_gfn) |
| 2982 | whose storage keys to get. The count field must be at least 1 and the maximum |
| 2983 | allowed value is defined as KVM_S390_SKEYS_ALLOC_MAX. Values outside this range |
| 2984 | will cause the ioctl to return -EINVAL. |
| 2985 | |
| 2986 | The skeydata_addr field is the address to a buffer containing count bytes of |
| 2987 | storage keys. Each byte in the buffer will be set as the storage key for a |
| 2988 | single frame starting at start_gfn for count frames. |
| 2989 | |
| 2990 | Note: If any architecturally invalid key value is found in the given data then |
| 2991 | the ioctl will return -EINVAL. |
| 2992 | |
Jens Freimann | 47b43c5 | 2014-11-11 20:57:06 +0100 | [diff] [blame] | 2993 | 4.92 KVM_S390_IRQ |
| 2994 | |
| 2995 | Capability: KVM_CAP_S390_INJECT_IRQ |
| 2996 | Architectures: s390 |
| 2997 | Type: vcpu ioctl |
| 2998 | Parameters: struct kvm_s390_irq (in) |
| 2999 | Returns: 0 on success, -1 on error |
| 3000 | Errors: |
| 3001 | EINVAL: interrupt type is invalid |
| 3002 | type is KVM_S390_SIGP_STOP and flag parameter is invalid value |
| 3003 | type is KVM_S390_INT_EXTERNAL_CALL and code is bigger |
| 3004 | than the maximum of VCPUs |
| 3005 | EBUSY: type is KVM_S390_SIGP_SET_PREFIX and vcpu is not stopped |
| 3006 | type is KVM_S390_SIGP_STOP and a stop irq is already pending |
| 3007 | type is KVM_S390_INT_EXTERNAL_CALL and an external call interrupt |
| 3008 | is already pending |
| 3009 | |
| 3010 | Allows to inject an interrupt to the guest. |
| 3011 | |
| 3012 | Using struct kvm_s390_irq as a parameter allows |
| 3013 | to inject additional payload which is not |
| 3014 | possible via KVM_S390_INTERRUPT. |
| 3015 | |
| 3016 | Interrupt parameters are passed via kvm_s390_irq: |
| 3017 | |
| 3018 | struct kvm_s390_irq { |
| 3019 | __u64 type; |
| 3020 | union { |
| 3021 | struct kvm_s390_io_info io; |
| 3022 | struct kvm_s390_ext_info ext; |
| 3023 | struct kvm_s390_pgm_info pgm; |
| 3024 | struct kvm_s390_emerg_info emerg; |
| 3025 | struct kvm_s390_extcall_info extcall; |
| 3026 | struct kvm_s390_prefix_info prefix; |
| 3027 | struct kvm_s390_stop_info stop; |
| 3028 | struct kvm_s390_mchk_info mchk; |
| 3029 | char reserved[64]; |
| 3030 | } u; |
| 3031 | }; |
| 3032 | |
| 3033 | type can be one of the following: |
| 3034 | |
| 3035 | KVM_S390_SIGP_STOP - sigp stop; parameter in .stop |
| 3036 | KVM_S390_PROGRAM_INT - program check; parameters in .pgm |
| 3037 | KVM_S390_SIGP_SET_PREFIX - sigp set prefix; parameters in .prefix |
| 3038 | KVM_S390_RESTART - restart; no parameters |
| 3039 | KVM_S390_INT_CLOCK_COMP - clock comparator interrupt; no parameters |
| 3040 | KVM_S390_INT_CPU_TIMER - CPU timer interrupt; no parameters |
| 3041 | KVM_S390_INT_EMERGENCY - sigp emergency; parameters in .emerg |
| 3042 | KVM_S390_INT_EXTERNAL_CALL - sigp external call; parameters in .extcall |
| 3043 | KVM_S390_MCHK - machine check interrupt; parameters in .mchk |
| 3044 | |
| 3045 | |
| 3046 | Note that the vcpu ioctl is asynchronous to vcpu execution. |
| 3047 | |
Jens Freimann | 816c766 | 2014-11-24 17:13:46 +0100 | [diff] [blame] | 3048 | 4.94 KVM_S390_GET_IRQ_STATE |
| 3049 | |
| 3050 | Capability: KVM_CAP_S390_IRQ_STATE |
| 3051 | Architectures: s390 |
| 3052 | Type: vcpu ioctl |
| 3053 | Parameters: struct kvm_s390_irq_state (out) |
| 3054 | Returns: >= number of bytes copied into buffer, |
| 3055 | -EINVAL if buffer size is 0, |
| 3056 | -ENOBUFS if buffer size is too small to fit all pending interrupts, |
| 3057 | -EFAULT if the buffer address was invalid |
| 3058 | |
| 3059 | This ioctl allows userspace to retrieve the complete state of all currently |
| 3060 | pending interrupts in a single buffer. Use cases include migration |
| 3061 | and introspection. The parameter structure contains the address of a |
| 3062 | userspace buffer and its length: |
| 3063 | |
| 3064 | struct kvm_s390_irq_state { |
| 3065 | __u64 buf; |
Christian Borntraeger | bb64da9 | 2017-11-21 16:02:52 +0100 | [diff] [blame] | 3066 | __u32 flags; /* will stay unused for compatibility reasons */ |
Jens Freimann | 816c766 | 2014-11-24 17:13:46 +0100 | [diff] [blame] | 3067 | __u32 len; |
Christian Borntraeger | bb64da9 | 2017-11-21 16:02:52 +0100 | [diff] [blame] | 3068 | __u32 reserved[4]; /* will stay unused for compatibility reasons */ |
Jens Freimann | 816c766 | 2014-11-24 17:13:46 +0100 | [diff] [blame] | 3069 | }; |
| 3070 | |
| 3071 | Userspace passes in the above struct and for each pending interrupt a |
| 3072 | struct kvm_s390_irq is copied to the provided buffer. |
| 3073 | |
Christian Borntraeger | bb64da9 | 2017-11-21 16:02:52 +0100 | [diff] [blame] | 3074 | The structure contains a flags and a reserved field for future extensions. As |
| 3075 | the kernel never checked for flags == 0 and QEMU never pre-zeroed flags and |
| 3076 | reserved, these fields can not be used in the future without breaking |
| 3077 | compatibility. |
| 3078 | |
Jens Freimann | 816c766 | 2014-11-24 17:13:46 +0100 | [diff] [blame] | 3079 | If -ENOBUFS is returned the buffer provided was too small and userspace |
| 3080 | may retry with a bigger buffer. |
| 3081 | |
| 3082 | 4.95 KVM_S390_SET_IRQ_STATE |
| 3083 | |
| 3084 | Capability: KVM_CAP_S390_IRQ_STATE |
| 3085 | Architectures: s390 |
| 3086 | Type: vcpu ioctl |
| 3087 | Parameters: struct kvm_s390_irq_state (in) |
| 3088 | Returns: 0 on success, |
| 3089 | -EFAULT if the buffer address was invalid, |
| 3090 | -EINVAL for an invalid buffer length (see below), |
| 3091 | -EBUSY if there were already interrupts pending, |
| 3092 | errors occurring when actually injecting the |
| 3093 | interrupt. See KVM_S390_IRQ. |
| 3094 | |
| 3095 | This ioctl allows userspace to set the complete state of all cpu-local |
| 3096 | interrupts currently pending for the vcpu. It is intended for restoring |
| 3097 | interrupt state after a migration. The input parameter is a userspace buffer |
| 3098 | containing a struct kvm_s390_irq_state: |
| 3099 | |
| 3100 | struct kvm_s390_irq_state { |
| 3101 | __u64 buf; |
Christian Borntraeger | bb64da9 | 2017-11-21 16:02:52 +0100 | [diff] [blame] | 3102 | __u32 flags; /* will stay unused for compatibility reasons */ |
Jens Freimann | 816c766 | 2014-11-24 17:13:46 +0100 | [diff] [blame] | 3103 | __u32 len; |
Christian Borntraeger | bb64da9 | 2017-11-21 16:02:52 +0100 | [diff] [blame] | 3104 | __u32 reserved[4]; /* will stay unused for compatibility reasons */ |
Jens Freimann | 816c766 | 2014-11-24 17:13:46 +0100 | [diff] [blame] | 3105 | }; |
| 3106 | |
Christian Borntraeger | bb64da9 | 2017-11-21 16:02:52 +0100 | [diff] [blame] | 3107 | The restrictions for flags and reserved apply as well. |
| 3108 | (see KVM_S390_GET_IRQ_STATE) |
| 3109 | |
Jens Freimann | 816c766 | 2014-11-24 17:13:46 +0100 | [diff] [blame] | 3110 | The userspace memory referenced by buf contains a struct kvm_s390_irq |
| 3111 | for each interrupt to be injected into the guest. |
| 3112 | If one of the interrupts could not be injected for some reason the |
| 3113 | ioctl aborts. |
| 3114 | |
| 3115 | len must be a multiple of sizeof(struct kvm_s390_irq). It must be > 0 |
| 3116 | and it must not exceed (max_vcpus + 32) * sizeof(struct kvm_s390_irq), |
| 3117 | which is the maximum number of possibly pending cpu-local interrupts. |
Jens Freimann | 47b43c5 | 2014-11-11 20:57:06 +0100 | [diff] [blame] | 3118 | |
Alexey Kardashevskiy | ed8e5a2 | 2016-01-19 16:12:28 +1100 | [diff] [blame] | 3119 | 4.96 KVM_SMI |
Paolo Bonzini | f077825 | 2015-04-01 15:06:40 +0200 | [diff] [blame] | 3120 | |
| 3121 | Capability: KVM_CAP_X86_SMM |
| 3122 | Architectures: x86 |
| 3123 | Type: vcpu ioctl |
| 3124 | Parameters: none |
| 3125 | Returns: 0 on success, -1 on error |
| 3126 | |
| 3127 | Queues an SMI on the thread's vcpu. |
| 3128 | |
Alexey Kardashevskiy | d3695aa | 2016-02-15 12:55:09 +1100 | [diff] [blame] | 3129 | 4.97 KVM_CAP_PPC_MULTITCE |
| 3130 | |
| 3131 | Capability: KVM_CAP_PPC_MULTITCE |
| 3132 | Architectures: ppc |
| 3133 | Type: vm |
| 3134 | |
| 3135 | This capability means the kernel is capable of handling hypercalls |
| 3136 | H_PUT_TCE_INDIRECT and H_STUFF_TCE without passing those into the user |
| 3137 | space. This significantly accelerates DMA operations for PPC KVM guests. |
| 3138 | User space should expect that its handlers for these hypercalls |
| 3139 | are not going to be called if user space previously registered LIOBN |
| 3140 | in KVM (via KVM_CREATE_SPAPR_TCE or similar calls). |
| 3141 | |
| 3142 | In order to enable H_PUT_TCE_INDIRECT and H_STUFF_TCE use in the guest, |
| 3143 | user space might have to advertise it for the guest. For example, |
| 3144 | IBM pSeries (sPAPR) guest starts using them if "hcall-multi-tce" is |
| 3145 | present in the "ibm,hypertas-functions" device-tree property. |
| 3146 | |
| 3147 | The hypercalls mentioned above may or may not be processed successfully |
| 3148 | in the kernel based fast path. If they can not be handled by the kernel, |
| 3149 | they will get passed on to user space. So user space still has to have |
| 3150 | an implementation for these despite the in kernel acceleration. |
| 3151 | |
| 3152 | This capability is always enabled. |
| 3153 | |
Alexey Kardashevskiy | 58ded42 | 2016-03-01 17:54:40 +1100 | [diff] [blame] | 3154 | 4.98 KVM_CREATE_SPAPR_TCE_64 |
| 3155 | |
| 3156 | Capability: KVM_CAP_SPAPR_TCE_64 |
| 3157 | Architectures: powerpc |
| 3158 | Type: vm ioctl |
| 3159 | Parameters: struct kvm_create_spapr_tce_64 (in) |
| 3160 | Returns: file descriptor for manipulating the created TCE table |
| 3161 | |
| 3162 | This is an extension for KVM_CAP_SPAPR_TCE which only supports 32bit |
| 3163 | windows, described in 4.62 KVM_CREATE_SPAPR_TCE |
| 3164 | |
| 3165 | This capability uses extended struct in ioctl interface: |
| 3166 | |
| 3167 | /* for KVM_CAP_SPAPR_TCE_64 */ |
| 3168 | struct kvm_create_spapr_tce_64 { |
| 3169 | __u64 liobn; |
| 3170 | __u32 page_shift; |
| 3171 | __u32 flags; |
| 3172 | __u64 offset; /* in pages */ |
| 3173 | __u64 size; /* in pages */ |
| 3174 | }; |
| 3175 | |
| 3176 | The aim of extension is to support an additional bigger DMA window with |
| 3177 | a variable page size. |
| 3178 | KVM_CREATE_SPAPR_TCE_64 receives a 64bit window size, an IOMMU page shift and |
| 3179 | a bus offset of the corresponding DMA window, @size and @offset are numbers |
| 3180 | of IOMMU pages. |
| 3181 | |
| 3182 | @flags are not used at the moment. |
| 3183 | |
| 3184 | The rest of functionality is identical to KVM_CREATE_SPAPR_TCE. |
| 3185 | |
David Gibson | ccc4df4 | 2016-12-20 16:48:57 +1100 | [diff] [blame] | 3186 | 4.99 KVM_REINJECT_CONTROL |
Radim Krčmář | 107d44a2 | 2016-03-02 22:56:53 +0100 | [diff] [blame] | 3187 | |
| 3188 | Capability: KVM_CAP_REINJECT_CONTROL |
| 3189 | Architectures: x86 |
| 3190 | Type: vm ioctl |
| 3191 | Parameters: struct kvm_reinject_control (in) |
| 3192 | Returns: 0 on success, |
| 3193 | -EFAULT if struct kvm_reinject_control cannot be read, |
| 3194 | -ENXIO if KVM_CREATE_PIT or KVM_CREATE_PIT2 didn't succeed earlier. |
| 3195 | |
| 3196 | i8254 (PIT) has two modes, reinject and !reinject. The default is reinject, |
| 3197 | where KVM queues elapsed i8254 ticks and monitors completion of interrupt from |
| 3198 | vector(s) that i8254 injects. Reinject mode dequeues a tick and injects its |
| 3199 | interrupt whenever there isn't a pending interrupt from i8254. |
| 3200 | !reinject mode injects an interrupt as soon as a tick arrives. |
| 3201 | |
| 3202 | struct kvm_reinject_control { |
| 3203 | __u8 pit_reinject; |
| 3204 | __u8 reserved[31]; |
| 3205 | }; |
| 3206 | |
| 3207 | pit_reinject = 0 (!reinject mode) is recommended, unless running an old |
| 3208 | operating system that uses the PIT for timing (e.g. Linux 2.4.x). |
| 3209 | |
David Gibson | ccc4df4 | 2016-12-20 16:48:57 +1100 | [diff] [blame] | 3210 | 4.100 KVM_PPC_CONFIGURE_V3_MMU |
Paul Mackerras | c927013 | 2017-01-30 21:21:41 +1100 | [diff] [blame] | 3211 | |
| 3212 | Capability: KVM_CAP_PPC_RADIX_MMU or KVM_CAP_PPC_HASH_MMU_V3 |
| 3213 | Architectures: ppc |
| 3214 | Type: vm ioctl |
| 3215 | Parameters: struct kvm_ppc_mmuv3_cfg (in) |
| 3216 | Returns: 0 on success, |
| 3217 | -EFAULT if struct kvm_ppc_mmuv3_cfg cannot be read, |
| 3218 | -EINVAL if the configuration is invalid |
| 3219 | |
| 3220 | This ioctl controls whether the guest will use radix or HPT (hashed |
| 3221 | page table) translation, and sets the pointer to the process table for |
| 3222 | the guest. |
| 3223 | |
| 3224 | struct kvm_ppc_mmuv3_cfg { |
| 3225 | __u64 flags; |
| 3226 | __u64 process_table; |
| 3227 | }; |
| 3228 | |
| 3229 | There are two bits that can be set in flags; KVM_PPC_MMUV3_RADIX and |
| 3230 | KVM_PPC_MMUV3_GTSE. KVM_PPC_MMUV3_RADIX, if set, configures the guest |
| 3231 | to use radix tree translation, and if clear, to use HPT translation. |
| 3232 | KVM_PPC_MMUV3_GTSE, if set and if KVM permits it, configures the guest |
| 3233 | to be able to use the global TLB and SLB invalidation instructions; |
| 3234 | if clear, the guest may not use these instructions. |
| 3235 | |
| 3236 | The process_table field specifies the address and size of the guest |
| 3237 | process table, which is in the guest's space. This field is formatted |
| 3238 | as the second doubleword of the partition table entry, as defined in |
| 3239 | the Power ISA V3.00, Book III section 5.7.6.1. |
| 3240 | |
David Gibson | ccc4df4 | 2016-12-20 16:48:57 +1100 | [diff] [blame] | 3241 | 4.101 KVM_PPC_GET_RMMU_INFO |
Paul Mackerras | c927013 | 2017-01-30 21:21:41 +1100 | [diff] [blame] | 3242 | |
| 3243 | Capability: KVM_CAP_PPC_RADIX_MMU |
| 3244 | Architectures: ppc |
| 3245 | Type: vm ioctl |
| 3246 | Parameters: struct kvm_ppc_rmmu_info (out) |
| 3247 | Returns: 0 on success, |
| 3248 | -EFAULT if struct kvm_ppc_rmmu_info cannot be written, |
| 3249 | -EINVAL if no useful information can be returned |
| 3250 | |
| 3251 | This ioctl returns a structure containing two things: (a) a list |
| 3252 | containing supported radix tree geometries, and (b) a list that maps |
| 3253 | page sizes to put in the "AP" (actual page size) field for the tlbie |
| 3254 | (TLB invalidate entry) instruction. |
| 3255 | |
| 3256 | struct kvm_ppc_rmmu_info { |
| 3257 | struct kvm_ppc_radix_geom { |
| 3258 | __u8 page_shift; |
| 3259 | __u8 level_bits[4]; |
| 3260 | __u8 pad[3]; |
| 3261 | } geometries[8]; |
| 3262 | __u32 ap_encodings[8]; |
| 3263 | }; |
| 3264 | |
| 3265 | The geometries[] field gives up to 8 supported geometries for the |
| 3266 | radix page table, in terms of the log base 2 of the smallest page |
| 3267 | size, and the number of bits indexed at each level of the tree, from |
| 3268 | the PTE level up to the PGD level in that order. Any unused entries |
| 3269 | will have 0 in the page_shift field. |
| 3270 | |
| 3271 | The ap_encodings gives the supported page sizes and their AP field |
| 3272 | encodings, encoded with the AP value in the top 3 bits and the log |
| 3273 | base 2 of the page size in the bottom 6 bits. |
| 3274 | |
David Gibson | ef1ead0 | 2016-12-20 16:48:58 +1100 | [diff] [blame] | 3275 | 4.102 KVM_PPC_RESIZE_HPT_PREPARE |
| 3276 | |
| 3277 | Capability: KVM_CAP_SPAPR_RESIZE_HPT |
| 3278 | Architectures: powerpc |
| 3279 | Type: vm ioctl |
| 3280 | Parameters: struct kvm_ppc_resize_hpt (in) |
| 3281 | Returns: 0 on successful completion, |
| 3282 | >0 if a new HPT is being prepared, the value is an estimated |
| 3283 | number of milliseconds until preparation is complete |
| 3284 | -EFAULT if struct kvm_reinject_control cannot be read, |
| 3285 | -EINVAL if the supplied shift or flags are invalid |
| 3286 | -ENOMEM if unable to allocate the new HPT |
| 3287 | -ENOSPC if there was a hash collision when moving existing |
| 3288 | HPT entries to the new HPT |
| 3289 | -EIO on other error conditions |
| 3290 | |
| 3291 | Used to implement the PAPR extension for runtime resizing of a guest's |
| 3292 | Hashed Page Table (HPT). Specifically this starts, stops or monitors |
| 3293 | the preparation of a new potential HPT for the guest, essentially |
| 3294 | implementing the H_RESIZE_HPT_PREPARE hypercall. |
| 3295 | |
| 3296 | If called with shift > 0 when there is no pending HPT for the guest, |
| 3297 | this begins preparation of a new pending HPT of size 2^(shift) bytes. |
| 3298 | It then returns a positive integer with the estimated number of |
| 3299 | milliseconds until preparation is complete. |
| 3300 | |
| 3301 | If called when there is a pending HPT whose size does not match that |
| 3302 | requested in the parameters, discards the existing pending HPT and |
| 3303 | creates a new one as above. |
| 3304 | |
| 3305 | If called when there is a pending HPT of the size requested, will: |
| 3306 | * If preparation of the pending HPT is already complete, return 0 |
| 3307 | * If preparation of the pending HPT has failed, return an error |
| 3308 | code, then discard the pending HPT. |
| 3309 | * If preparation of the pending HPT is still in progress, return an |
| 3310 | estimated number of milliseconds until preparation is complete. |
| 3311 | |
| 3312 | If called with shift == 0, discards any currently pending HPT and |
| 3313 | returns 0 (i.e. cancels any in-progress preparation). |
| 3314 | |
| 3315 | flags is reserved for future expansion, currently setting any bits in |
| 3316 | flags will result in an -EINVAL. |
| 3317 | |
| 3318 | Normally this will be called repeatedly with the same parameters until |
| 3319 | it returns <= 0. The first call will initiate preparation, subsequent |
| 3320 | ones will monitor preparation until it completes or fails. |
| 3321 | |
| 3322 | struct kvm_ppc_resize_hpt { |
| 3323 | __u64 flags; |
| 3324 | __u32 shift; |
| 3325 | __u32 pad; |
| 3326 | }; |
| 3327 | |
| 3328 | 4.103 KVM_PPC_RESIZE_HPT_COMMIT |
| 3329 | |
| 3330 | Capability: KVM_CAP_SPAPR_RESIZE_HPT |
| 3331 | Architectures: powerpc |
| 3332 | Type: vm ioctl |
| 3333 | Parameters: struct kvm_ppc_resize_hpt (in) |
| 3334 | Returns: 0 on successful completion, |
| 3335 | -EFAULT if struct kvm_reinject_control cannot be read, |
| 3336 | -EINVAL if the supplied shift or flags are invalid |
| 3337 | -ENXIO is there is no pending HPT, or the pending HPT doesn't |
| 3338 | have the requested size |
| 3339 | -EBUSY if the pending HPT is not fully prepared |
| 3340 | -ENOSPC if there was a hash collision when moving existing |
| 3341 | HPT entries to the new HPT |
| 3342 | -EIO on other error conditions |
| 3343 | |
| 3344 | Used to implement the PAPR extension for runtime resizing of a guest's |
| 3345 | Hashed Page Table (HPT). Specifically this requests that the guest be |
| 3346 | transferred to working with the new HPT, essentially implementing the |
| 3347 | H_RESIZE_HPT_COMMIT hypercall. |
| 3348 | |
| 3349 | This should only be called after KVM_PPC_RESIZE_HPT_PREPARE has |
| 3350 | returned 0 with the same parameters. In other cases |
| 3351 | KVM_PPC_RESIZE_HPT_COMMIT will return an error (usually -ENXIO or |
| 3352 | -EBUSY, though others may be possible if the preparation was started, |
| 3353 | but failed). |
| 3354 | |
| 3355 | This will have undefined effects on the guest if it has not already |
| 3356 | placed itself in a quiescent state where no vcpu will make MMU enabled |
| 3357 | memory accesses. |
| 3358 | |
| 3359 | On succsful completion, the pending HPT will become the guest's active |
| 3360 | HPT and the previous HPT will be discarded. |
| 3361 | |
| 3362 | On failure, the guest will still be operating on its previous HPT. |
| 3363 | |
| 3364 | struct kvm_ppc_resize_hpt { |
| 3365 | __u64 flags; |
| 3366 | __u32 shift; |
| 3367 | __u32 pad; |
| 3368 | }; |
| 3369 | |
Luiz Capitulino | 3aa5385 | 2017-03-13 09:08:20 -0400 | [diff] [blame] | 3370 | 4.104 KVM_X86_GET_MCE_CAP_SUPPORTED |
| 3371 | |
| 3372 | Capability: KVM_CAP_MCE |
| 3373 | Architectures: x86 |
| 3374 | Type: system ioctl |
| 3375 | Parameters: u64 mce_cap (out) |
| 3376 | Returns: 0 on success, -1 on error |
| 3377 | |
| 3378 | Returns supported MCE capabilities. The u64 mce_cap parameter |
| 3379 | has the same format as the MSR_IA32_MCG_CAP register. Supported |
| 3380 | capabilities will have the corresponding bits set. |
| 3381 | |
| 3382 | 4.105 KVM_X86_SETUP_MCE |
| 3383 | |
| 3384 | Capability: KVM_CAP_MCE |
| 3385 | Architectures: x86 |
| 3386 | Type: vcpu ioctl |
| 3387 | Parameters: u64 mcg_cap (in) |
| 3388 | Returns: 0 on success, |
| 3389 | -EFAULT if u64 mcg_cap cannot be read, |
| 3390 | -EINVAL if the requested number of banks is invalid, |
| 3391 | -EINVAL if requested MCE capability is not supported. |
| 3392 | |
| 3393 | Initializes MCE support for use. The u64 mcg_cap parameter |
| 3394 | has the same format as the MSR_IA32_MCG_CAP register and |
| 3395 | specifies which capabilities should be enabled. The maximum |
| 3396 | supported number of error-reporting banks can be retrieved when |
| 3397 | checking for KVM_CAP_MCE. The supported capabilities can be |
| 3398 | retrieved with KVM_X86_GET_MCE_CAP_SUPPORTED. |
| 3399 | |
| 3400 | 4.106 KVM_X86_SET_MCE |
| 3401 | |
| 3402 | Capability: KVM_CAP_MCE |
| 3403 | Architectures: x86 |
| 3404 | Type: vcpu ioctl |
| 3405 | Parameters: struct kvm_x86_mce (in) |
| 3406 | Returns: 0 on success, |
| 3407 | -EFAULT if struct kvm_x86_mce cannot be read, |
| 3408 | -EINVAL if the bank number is invalid, |
| 3409 | -EINVAL if VAL bit is not set in status field. |
| 3410 | |
| 3411 | Inject a machine check error (MCE) into the guest. The input |
| 3412 | parameter is: |
| 3413 | |
| 3414 | struct kvm_x86_mce { |
| 3415 | __u64 status; |
| 3416 | __u64 addr; |
| 3417 | __u64 misc; |
| 3418 | __u64 mcg_status; |
| 3419 | __u8 bank; |
| 3420 | __u8 pad1[7]; |
| 3421 | __u64 pad2[3]; |
| 3422 | }; |
| 3423 | |
| 3424 | If the MCE being reported is an uncorrected error, KVM will |
| 3425 | inject it as an MCE exception into the guest. If the guest |
| 3426 | MCG_STATUS register reports that an MCE is in progress, KVM |
| 3427 | causes an KVM_EXIT_SHUTDOWN vmexit. |
| 3428 | |
| 3429 | Otherwise, if the MCE is a corrected error, KVM will just |
| 3430 | store it in the corresponding bank (provided this bank is |
| 3431 | not holding a previously reported uncorrected error). |
| 3432 | |
Claudio Imbrenda | 4036e38 | 2016-08-04 17:58:47 +0200 | [diff] [blame] | 3433 | 4.107 KVM_S390_GET_CMMA_BITS |
| 3434 | |
| 3435 | Capability: KVM_CAP_S390_CMMA_MIGRATION |
| 3436 | Architectures: s390 |
| 3437 | Type: vm ioctl |
| 3438 | Parameters: struct kvm_s390_cmma_log (in, out) |
| 3439 | Returns: 0 on success, a negative value on error |
| 3440 | |
| 3441 | This ioctl is used to get the values of the CMMA bits on the s390 |
| 3442 | architecture. It is meant to be used in two scenarios: |
| 3443 | - During live migration to save the CMMA values. Live migration needs |
| 3444 | to be enabled via the KVM_REQ_START_MIGRATION VM property. |
| 3445 | - To non-destructively peek at the CMMA values, with the flag |
| 3446 | KVM_S390_CMMA_PEEK set. |
| 3447 | |
| 3448 | The ioctl takes parameters via the kvm_s390_cmma_log struct. The desired |
| 3449 | values are written to a buffer whose location is indicated via the "values" |
| 3450 | member in the kvm_s390_cmma_log struct. The values in the input struct are |
| 3451 | also updated as needed. |
| 3452 | Each CMMA value takes up one byte. |
| 3453 | |
| 3454 | struct kvm_s390_cmma_log { |
| 3455 | __u64 start_gfn; |
| 3456 | __u32 count; |
| 3457 | __u32 flags; |
| 3458 | union { |
| 3459 | __u64 remaining; |
| 3460 | __u64 mask; |
| 3461 | }; |
| 3462 | __u64 values; |
| 3463 | }; |
| 3464 | |
| 3465 | start_gfn is the number of the first guest frame whose CMMA values are |
| 3466 | to be retrieved, |
| 3467 | |
| 3468 | count is the length of the buffer in bytes, |
| 3469 | |
| 3470 | values points to the buffer where the result will be written to. |
| 3471 | |
| 3472 | If count is greater than KVM_S390_SKEYS_MAX, then it is considered to be |
| 3473 | KVM_S390_SKEYS_MAX. KVM_S390_SKEYS_MAX is re-used for consistency with |
| 3474 | other ioctls. |
| 3475 | |
| 3476 | The result is written in the buffer pointed to by the field values, and |
| 3477 | the values of the input parameter are updated as follows. |
| 3478 | |
| 3479 | Depending on the flags, different actions are performed. The only |
| 3480 | supported flag so far is KVM_S390_CMMA_PEEK. |
| 3481 | |
| 3482 | The default behaviour if KVM_S390_CMMA_PEEK is not set is: |
| 3483 | start_gfn will indicate the first page frame whose CMMA bits were dirty. |
| 3484 | It is not necessarily the same as the one passed as input, as clean pages |
| 3485 | are skipped. |
| 3486 | |
| 3487 | count will indicate the number of bytes actually written in the buffer. |
| 3488 | It can (and very often will) be smaller than the input value, since the |
| 3489 | buffer is only filled until 16 bytes of clean values are found (which |
| 3490 | are then not copied in the buffer). Since a CMMA migration block needs |
| 3491 | the base address and the length, for a total of 16 bytes, we will send |
| 3492 | back some clean data if there is some dirty data afterwards, as long as |
| 3493 | the size of the clean data does not exceed the size of the header. This |
| 3494 | allows to minimize the amount of data to be saved or transferred over |
| 3495 | the network at the expense of more roundtrips to userspace. The next |
| 3496 | invocation of the ioctl will skip over all the clean values, saving |
| 3497 | potentially more than just the 16 bytes we found. |
| 3498 | |
| 3499 | If KVM_S390_CMMA_PEEK is set: |
| 3500 | the existing storage attributes are read even when not in migration |
| 3501 | mode, and no other action is performed; |
| 3502 | |
| 3503 | the output start_gfn will be equal to the input start_gfn, |
| 3504 | |
| 3505 | the output count will be equal to the input count, except if the end of |
| 3506 | memory has been reached. |
| 3507 | |
| 3508 | In both cases: |
| 3509 | the field "remaining" will indicate the total number of dirty CMMA values |
| 3510 | still remaining, or 0 if KVM_S390_CMMA_PEEK is set and migration mode is |
| 3511 | not enabled. |
| 3512 | |
| 3513 | mask is unused. |
| 3514 | |
| 3515 | values points to the userspace buffer where the result will be stored. |
| 3516 | |
| 3517 | This ioctl can fail with -ENOMEM if not enough memory can be allocated to |
| 3518 | complete the task, with -ENXIO if CMMA is not enabled, with -EINVAL if |
| 3519 | KVM_S390_CMMA_PEEK is not set but migration mode was not enabled, with |
| 3520 | -EFAULT if the userspace address is invalid or if no page table is |
| 3521 | present for the addresses (e.g. when using hugepages). |
| 3522 | |
| 3523 | 4.108 KVM_S390_SET_CMMA_BITS |
| 3524 | |
| 3525 | Capability: KVM_CAP_S390_CMMA_MIGRATION |
| 3526 | Architectures: s390 |
| 3527 | Type: vm ioctl |
| 3528 | Parameters: struct kvm_s390_cmma_log (in) |
| 3529 | Returns: 0 on success, a negative value on error |
| 3530 | |
| 3531 | This ioctl is used to set the values of the CMMA bits on the s390 |
| 3532 | architecture. It is meant to be used during live migration to restore |
| 3533 | the CMMA values, but there are no restrictions on its use. |
| 3534 | The ioctl takes parameters via the kvm_s390_cmma_values struct. |
| 3535 | Each CMMA value takes up one byte. |
| 3536 | |
| 3537 | struct kvm_s390_cmma_log { |
| 3538 | __u64 start_gfn; |
| 3539 | __u32 count; |
| 3540 | __u32 flags; |
| 3541 | union { |
| 3542 | __u64 remaining; |
| 3543 | __u64 mask; |
| 3544 | }; |
| 3545 | __u64 values; |
| 3546 | }; |
| 3547 | |
| 3548 | start_gfn indicates the starting guest frame number, |
| 3549 | |
| 3550 | count indicates how many values are to be considered in the buffer, |
| 3551 | |
| 3552 | flags is not used and must be 0. |
| 3553 | |
| 3554 | mask indicates which PGSTE bits are to be considered. |
| 3555 | |
| 3556 | remaining is not used. |
| 3557 | |
| 3558 | values points to the buffer in userspace where to store the values. |
| 3559 | |
| 3560 | This ioctl can fail with -ENOMEM if not enough memory can be allocated to |
| 3561 | complete the task, with -ENXIO if CMMA is not enabled, with -EINVAL if |
| 3562 | the count field is too large (e.g. more than KVM_S390_CMMA_SIZE_MAX) or |
| 3563 | if the flags field was not 0, with -EFAULT if the userspace address is |
| 3564 | invalid, if invalid pages are written to (e.g. after the end of memory) |
| 3565 | or if no page table is present for the addresses (e.g. when using |
| 3566 | hugepages). |
| 3567 | |
Radim Krčmář | 7bf14c2 | 2018-02-01 15:04:17 +0100 | [diff] [blame] | 3568 | 4.109 KVM_PPC_GET_CPU_CHAR |
Paul Mackerras | 3214d01 | 2018-01-15 16:06:47 +1100 | [diff] [blame] | 3569 | |
| 3570 | Capability: KVM_CAP_PPC_GET_CPU_CHAR |
| 3571 | Architectures: powerpc |
| 3572 | Type: vm ioctl |
| 3573 | Parameters: struct kvm_ppc_cpu_char (out) |
| 3574 | Returns: 0 on successful completion |
| 3575 | -EFAULT if struct kvm_ppc_cpu_char cannot be written |
| 3576 | |
| 3577 | This ioctl gives userspace information about certain characteristics |
| 3578 | of the CPU relating to speculative execution of instructions and |
| 3579 | possible information leakage resulting from speculative execution (see |
| 3580 | CVE-2017-5715, CVE-2017-5753 and CVE-2017-5754). The information is |
| 3581 | returned in struct kvm_ppc_cpu_char, which looks like this: |
| 3582 | |
| 3583 | struct kvm_ppc_cpu_char { |
| 3584 | __u64 character; /* characteristics of the CPU */ |
| 3585 | __u64 behaviour; /* recommended software behaviour */ |
| 3586 | __u64 character_mask; /* valid bits in character */ |
| 3587 | __u64 behaviour_mask; /* valid bits in behaviour */ |
| 3588 | }; |
| 3589 | |
| 3590 | For extensibility, the character_mask and behaviour_mask fields |
| 3591 | indicate which bits of character and behaviour have been filled in by |
| 3592 | the kernel. If the set of defined bits is extended in future then |
| 3593 | userspace will be able to tell whether it is running on a kernel that |
| 3594 | knows about the new bits. |
| 3595 | |
| 3596 | The character field describes attributes of the CPU which can help |
| 3597 | with preventing inadvertent information disclosure - specifically, |
| 3598 | whether there is an instruction to flash-invalidate the L1 data cache |
| 3599 | (ori 30,30,0 or mtspr SPRN_TRIG2,rN), whether the L1 data cache is set |
| 3600 | to a mode where entries can only be used by the thread that created |
| 3601 | them, whether the bcctr[l] instruction prevents speculation, and |
| 3602 | whether a speculation barrier instruction (ori 31,31,0) is provided. |
| 3603 | |
| 3604 | The behaviour field describes actions that software should take to |
| 3605 | prevent inadvertent information disclosure, and thus describes which |
| 3606 | vulnerabilities the hardware is subject to; specifically whether the |
| 3607 | L1 data cache should be flushed when returning to user mode from the |
| 3608 | kernel, and whether a speculation barrier should be placed between an |
| 3609 | array bounds check and the array access. |
| 3610 | |
| 3611 | These fields use the same bit definitions as the new |
| 3612 | H_GET_CPU_CHARACTERISTICS hypercall. |
| 3613 | |
Radim Krčmář | 7bf14c2 | 2018-02-01 15:04:17 +0100 | [diff] [blame] | 3614 | 4.110 KVM_MEMORY_ENCRYPT_OP |
Brijesh Singh | 5acc5c0 | 2017-12-04 10:57:26 -0600 | [diff] [blame] | 3615 | |
| 3616 | Capability: basic |
| 3617 | Architectures: x86 |
| 3618 | Type: system |
| 3619 | Parameters: an opaque platform specific structure (in/out) |
| 3620 | Returns: 0 on success; -1 on error |
| 3621 | |
| 3622 | If the platform supports creating encrypted VMs then this ioctl can be used |
| 3623 | for issuing platform-specific memory encryption commands to manage those |
| 3624 | encrypted VMs. |
| 3625 | |
| 3626 | Currently, this ioctl is used for issuing Secure Encrypted Virtualization |
| 3627 | (SEV) commands on AMD Processors. The SEV commands are defined in |
Andrew Jones | 21e94ac | 2018-03-26 14:38:02 +0200 | [diff] [blame] | 3628 | Documentation/virtual/kvm/amd-memory-encryption.rst. |
Brijesh Singh | 5acc5c0 | 2017-12-04 10:57:26 -0600 | [diff] [blame] | 3629 | |
Radim Krčmář | 7bf14c2 | 2018-02-01 15:04:17 +0100 | [diff] [blame] | 3630 | 4.111 KVM_MEMORY_ENCRYPT_REG_REGION |
Brijesh Singh | 69eaede | 2017-12-04 10:57:26 -0600 | [diff] [blame] | 3631 | |
| 3632 | Capability: basic |
| 3633 | Architectures: x86 |
| 3634 | Type: system |
| 3635 | Parameters: struct kvm_enc_region (in) |
| 3636 | Returns: 0 on success; -1 on error |
| 3637 | |
| 3638 | This ioctl can be used to register a guest memory region which may |
| 3639 | contain encrypted data (e.g. guest RAM, SMRAM etc). |
| 3640 | |
| 3641 | It is used in the SEV-enabled guest. When encryption is enabled, a guest |
| 3642 | memory region may contain encrypted data. The SEV memory encryption |
| 3643 | engine uses a tweak such that two identical plaintext pages, each at |
| 3644 | different locations will have differing ciphertexts. So swapping or |
| 3645 | moving ciphertext of those pages will not result in plaintext being |
| 3646 | swapped. So relocating (or migrating) physical backing pages for the SEV |
| 3647 | guest will require some additional steps. |
| 3648 | |
| 3649 | Note: The current SEV key management spec does not provide commands to |
| 3650 | swap or migrate (move) ciphertext pages. Hence, for now we pin the guest |
| 3651 | memory region registered with the ioctl. |
| 3652 | |
Radim Krčmář | 7bf14c2 | 2018-02-01 15:04:17 +0100 | [diff] [blame] | 3653 | 4.112 KVM_MEMORY_ENCRYPT_UNREG_REGION |
Brijesh Singh | 69eaede | 2017-12-04 10:57:26 -0600 | [diff] [blame] | 3654 | |
| 3655 | Capability: basic |
| 3656 | Architectures: x86 |
| 3657 | Type: system |
| 3658 | Parameters: struct kvm_enc_region (in) |
| 3659 | Returns: 0 on success; -1 on error |
| 3660 | |
| 3661 | This ioctl can be used to unregister the guest memory region registered |
| 3662 | with KVM_MEMORY_ENCRYPT_REG_REGION ioctl above. |
| 3663 | |
Roman Kagan | faeb783 | 2018-02-01 16:48:32 +0300 | [diff] [blame] | 3664 | 4.113 KVM_HYPERV_EVENTFD |
| 3665 | |
| 3666 | Capability: KVM_CAP_HYPERV_EVENTFD |
| 3667 | Architectures: x86 |
| 3668 | Type: vm ioctl |
| 3669 | Parameters: struct kvm_hyperv_eventfd (in) |
| 3670 | |
| 3671 | This ioctl (un)registers an eventfd to receive notifications from the guest on |
| 3672 | the specified Hyper-V connection id through the SIGNAL_EVENT hypercall, without |
| 3673 | causing a user exit. SIGNAL_EVENT hypercall with non-zero event flag number |
| 3674 | (bits 24-31) still triggers a KVM_EXIT_HYPERV_HCALL user exit. |
| 3675 | |
| 3676 | struct kvm_hyperv_eventfd { |
| 3677 | __u32 conn_id; |
| 3678 | __s32 fd; |
| 3679 | __u32 flags; |
| 3680 | __u32 padding[3]; |
| 3681 | }; |
| 3682 | |
| 3683 | The conn_id field should fit within 24 bits: |
| 3684 | |
| 3685 | #define KVM_HYPERV_CONN_ID_MASK 0x00ffffff |
| 3686 | |
| 3687 | The acceptable values for the flags field are: |
| 3688 | |
| 3689 | #define KVM_HYPERV_EVENTFD_DEASSIGN (1 << 0) |
| 3690 | |
| 3691 | Returns: 0 on success, |
| 3692 | -EINVAL if conn_id or flags is outside the allowed range |
| 3693 | -ENOENT on deassign if the conn_id isn't registered |
| 3694 | -EEXIST on assign if the conn_id is already registered |
| 3695 | |
Jim Mattson | 8fcc4b5 | 2018-07-10 11:27:20 +0200 | [diff] [blame] | 3696 | 4.114 KVM_GET_NESTED_STATE |
| 3697 | |
| 3698 | Capability: KVM_CAP_NESTED_STATE |
| 3699 | Architectures: x86 |
| 3700 | Type: vcpu ioctl |
| 3701 | Parameters: struct kvm_nested_state (in/out) |
| 3702 | Returns: 0 on success, -1 on error |
| 3703 | Errors: |
| 3704 | E2BIG: the total state size (including the fixed-size part of struct |
| 3705 | kvm_nested_state) exceeds the value of 'size' specified by |
| 3706 | the user; the size required will be written into size. |
| 3707 | |
| 3708 | struct kvm_nested_state { |
| 3709 | __u16 flags; |
| 3710 | __u16 format; |
| 3711 | __u32 size; |
| 3712 | union { |
| 3713 | struct kvm_vmx_nested_state vmx; |
| 3714 | struct kvm_svm_nested_state svm; |
| 3715 | __u8 pad[120]; |
| 3716 | }; |
| 3717 | __u8 data[0]; |
| 3718 | }; |
| 3719 | |
| 3720 | #define KVM_STATE_NESTED_GUEST_MODE 0x00000001 |
| 3721 | #define KVM_STATE_NESTED_RUN_PENDING 0x00000002 |
| 3722 | |
| 3723 | #define KVM_STATE_NESTED_SMM_GUEST_MODE 0x00000001 |
| 3724 | #define KVM_STATE_NESTED_SMM_VMXON 0x00000002 |
| 3725 | |
| 3726 | struct kvm_vmx_nested_state { |
| 3727 | __u64 vmxon_pa; |
| 3728 | __u64 vmcs_pa; |
| 3729 | |
| 3730 | struct { |
| 3731 | __u16 flags; |
| 3732 | } smm; |
| 3733 | }; |
| 3734 | |
| 3735 | This ioctl copies the vcpu's nested virtualization state from the kernel to |
| 3736 | userspace. |
| 3737 | |
| 3738 | The maximum size of the state, including the fixed-size part of struct |
| 3739 | kvm_nested_state, can be retrieved by passing KVM_CAP_NESTED_STATE to |
| 3740 | the KVM_CHECK_EXTENSION ioctl(). |
| 3741 | |
| 3742 | 4.115 KVM_SET_NESTED_STATE |
| 3743 | |
| 3744 | Capability: KVM_CAP_NESTED_STATE |
| 3745 | Architectures: x86 |
| 3746 | Type: vcpu ioctl |
| 3747 | Parameters: struct kvm_nested_state (in) |
| 3748 | Returns: 0 on success, -1 on error |
| 3749 | |
| 3750 | This copies the vcpu's kvm_nested_state struct from userspace to the kernel. For |
| 3751 | the definition of struct kvm_nested_state, see KVM_GET_NESTED_STATE. |
Radim Krčmář | 7bf14c2 | 2018-02-01 15:04:17 +0100 | [diff] [blame] | 3752 | |
Peng Hao | 9943450 | 2018-10-14 07:09:56 +0800 | [diff] [blame] | 3753 | 4.116 KVM_(UN)REGISTER_COALESCED_MMIO |
| 3754 | |
Peng Hao | 0804c84 | 2018-10-14 07:09:55 +0800 | [diff] [blame] | 3755 | Capability: KVM_CAP_COALESCED_MMIO (for coalesced mmio) |
| 3756 | KVM_CAP_COALESCED_PIO (for coalesced pio) |
Peng Hao | 9943450 | 2018-10-14 07:09:56 +0800 | [diff] [blame] | 3757 | Architectures: all |
| 3758 | Type: vm ioctl |
| 3759 | Parameters: struct kvm_coalesced_mmio_zone |
| 3760 | Returns: 0 on success, < 0 on error |
| 3761 | |
Peng Hao | 0804c84 | 2018-10-14 07:09:55 +0800 | [diff] [blame] | 3762 | Coalesced I/O is a performance optimization that defers hardware |
Peng Hao | 9943450 | 2018-10-14 07:09:56 +0800 | [diff] [blame] | 3763 | register write emulation so that userspace exits are avoided. It is |
| 3764 | typically used to reduce the overhead of emulating frequently accessed |
| 3765 | hardware registers. |
| 3766 | |
Peng Hao | 0804c84 | 2018-10-14 07:09:55 +0800 | [diff] [blame] | 3767 | When a hardware register is configured for coalesced I/O, write accesses |
Peng Hao | 9943450 | 2018-10-14 07:09:56 +0800 | [diff] [blame] | 3768 | do not exit to userspace and their value is recorded in a ring buffer |
| 3769 | that is shared between kernel and userspace. |
| 3770 | |
Peng Hao | 0804c84 | 2018-10-14 07:09:55 +0800 | [diff] [blame] | 3771 | Coalesced I/O is used if one or more write accesses to a hardware |
Peng Hao | 9943450 | 2018-10-14 07:09:56 +0800 | [diff] [blame] | 3772 | register can be deferred until a read or a write to another hardware |
| 3773 | register on the same device. This last access will cause a vmexit and |
| 3774 | userspace will process accesses from the ring buffer before emulating |
Peng Hao | 0804c84 | 2018-10-14 07:09:55 +0800 | [diff] [blame] | 3775 | it. That will avoid exiting to userspace on repeated writes. |
| 3776 | |
| 3777 | Coalesced pio is based on coalesced mmio. There is little difference |
| 3778 | between coalesced mmio and pio except that coalesced pio records accesses |
| 3779 | to I/O ports. |
Peng Hao | 9943450 | 2018-10-14 07:09:56 +0800 | [diff] [blame] | 3780 | |
Paolo Bonzini | 2a31b9d | 2018-10-23 02:36:47 +0200 | [diff] [blame] | 3781 | 4.117 KVM_CLEAR_DIRTY_LOG (vm ioctl) |
| 3782 | |
| 3783 | Capability: KVM_CAP_MANUAL_DIRTY_LOG_PROTECT |
| 3784 | Architectures: x86 |
| 3785 | Type: vm ioctl |
| 3786 | Parameters: struct kvm_dirty_log (in) |
| 3787 | Returns: 0 on success, -1 on error |
| 3788 | |
| 3789 | /* for KVM_CLEAR_DIRTY_LOG */ |
| 3790 | struct kvm_clear_dirty_log { |
| 3791 | __u32 slot; |
| 3792 | __u32 num_pages; |
| 3793 | __u64 first_page; |
| 3794 | union { |
| 3795 | void __user *dirty_bitmap; /* one bit per page */ |
| 3796 | __u64 padding; |
| 3797 | }; |
| 3798 | }; |
| 3799 | |
| 3800 | The ioctl clears the dirty status of pages in a memory slot, according to |
| 3801 | the bitmap that is passed in struct kvm_clear_dirty_log's dirty_bitmap |
| 3802 | field. Bit 0 of the bitmap corresponds to page "first_page" in the |
| 3803 | memory slot, and num_pages is the size in bits of the input bitmap. |
| 3804 | Both first_page and num_pages must be a multiple of 64. For each bit |
| 3805 | that is set in the input bitmap, the corresponding page is marked "clean" |
| 3806 | in KVM's dirty bitmap, and dirty tracking is re-enabled for that page |
| 3807 | (for example via write-protection, or by clearing the dirty bit in |
| 3808 | a page table entry). |
| 3809 | |
| 3810 | If KVM_CAP_MULTI_ADDRESS_SPACE is available, bits 16-31 specifies |
| 3811 | the address space for which you want to return the dirty bitmap. |
| 3812 | They must be less than the value that KVM_CHECK_EXTENSION returns for |
| 3813 | the KVM_CAP_MULTI_ADDRESS_SPACE capability. |
| 3814 | |
| 3815 | This ioctl is mostly useful when KVM_CAP_MANUAL_DIRTY_LOG_PROTECT |
| 3816 | is enabled; for more information, see the description of the capability. |
| 3817 | However, it can always be used as long as KVM_CHECK_EXTENSION confirms |
| 3818 | that KVM_CAP_MANUAL_DIRTY_LOG_PROTECT is present. |
| 3819 | |
Vitaly Kuznetsov | 2bc3997 | 2018-12-10 18:21:56 +0100 | [diff] [blame] | 3820 | 4.118 KVM_GET_SUPPORTED_HV_CPUID |
| 3821 | |
| 3822 | Capability: KVM_CAP_HYPERV_CPUID |
| 3823 | Architectures: x86 |
| 3824 | Type: vcpu ioctl |
| 3825 | Parameters: struct kvm_cpuid2 (in/out) |
| 3826 | Returns: 0 on success, -1 on error |
| 3827 | |
| 3828 | struct kvm_cpuid2 { |
| 3829 | __u32 nent; |
| 3830 | __u32 padding; |
| 3831 | struct kvm_cpuid_entry2 entries[0]; |
| 3832 | }; |
| 3833 | |
| 3834 | struct kvm_cpuid_entry2 { |
| 3835 | __u32 function; |
| 3836 | __u32 index; |
| 3837 | __u32 flags; |
| 3838 | __u32 eax; |
| 3839 | __u32 ebx; |
| 3840 | __u32 ecx; |
| 3841 | __u32 edx; |
| 3842 | __u32 padding[3]; |
| 3843 | }; |
| 3844 | |
| 3845 | This ioctl returns x86 cpuid features leaves related to Hyper-V emulation in |
| 3846 | KVM. Userspace can use the information returned by this ioctl to construct |
| 3847 | cpuid information presented to guests consuming Hyper-V enlightenments (e.g. |
| 3848 | Windows or Hyper-V guests). |
| 3849 | |
| 3850 | CPUID feature leaves returned by this ioctl are defined by Hyper-V Top Level |
| 3851 | Functional Specification (TLFS). These leaves can't be obtained with |
| 3852 | KVM_GET_SUPPORTED_CPUID ioctl because some of them intersect with KVM feature |
| 3853 | leaves (0x40000000, 0x40000001). |
| 3854 | |
| 3855 | Currently, the following list of CPUID leaves are returned: |
| 3856 | HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS |
| 3857 | HYPERV_CPUID_INTERFACE |
| 3858 | HYPERV_CPUID_VERSION |
| 3859 | HYPERV_CPUID_FEATURES |
| 3860 | HYPERV_CPUID_ENLIGHTMENT_INFO |
| 3861 | HYPERV_CPUID_IMPLEMENT_LIMITS |
| 3862 | HYPERV_CPUID_NESTED_FEATURES |
| 3863 | |
| 3864 | HYPERV_CPUID_NESTED_FEATURES leaf is only exposed when Enlightened VMCS was |
| 3865 | enabled on the corresponding vCPU (KVM_CAP_HYPERV_ENLIGHTENED_VMCS). |
| 3866 | |
| 3867 | Userspace invokes KVM_GET_SUPPORTED_CPUID by passing a kvm_cpuid2 structure |
| 3868 | with the 'nent' field indicating the number of entries in the variable-size |
| 3869 | array 'entries'. If the number of entries is too low to describe all Hyper-V |
| 3870 | feature leaves, an error (E2BIG) is returned. If the number is more or equal |
| 3871 | to the number of Hyper-V feature leaves, the 'nent' field is adjusted to the |
| 3872 | number of valid entries in the 'entries' array, which is then filled. |
| 3873 | |
| 3874 | 'index' and 'flags' fields in 'struct kvm_cpuid_entry2' are currently reserved, |
| 3875 | userspace should not expect to get any particular value there. |
Paolo Bonzini | 2a31b9d | 2018-10-23 02:36:47 +0200 | [diff] [blame] | 3876 | |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 3877 | 5. The kvm_run structure |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 3878 | ------------------------ |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 3879 | |
| 3880 | Application code obtains a pointer to the kvm_run structure by |
| 3881 | mmap()ing a vcpu fd. From that point, application code can control |
| 3882 | execution by changing fields in kvm_run prior to calling the KVM_RUN |
| 3883 | ioctl, and obtain information about the reason KVM_RUN returned by |
| 3884 | looking up structure members. |
| 3885 | |
| 3886 | struct kvm_run { |
| 3887 | /* in */ |
| 3888 | __u8 request_interrupt_window; |
| 3889 | |
| 3890 | Request that KVM_RUN return when it becomes possible to inject external |
| 3891 | interrupts into the guest. Useful in conjunction with KVM_INTERRUPT. |
| 3892 | |
Paolo Bonzini | 460df4c | 2017-02-08 11:50:15 +0100 | [diff] [blame] | 3893 | __u8 immediate_exit; |
| 3894 | |
| 3895 | This field is polled once when KVM_RUN starts; if non-zero, KVM_RUN |
| 3896 | exits immediately, returning -EINTR. In the common scenario where a |
| 3897 | signal is used to "kick" a VCPU out of KVM_RUN, this field can be used |
| 3898 | to avoid usage of KVM_SET_SIGNAL_MASK, which has worse scalability. |
| 3899 | Rather than blocking the signal outside KVM_RUN, userspace can set up |
| 3900 | a signal handler that sets run->immediate_exit to a non-zero value. |
| 3901 | |
| 3902 | This field is ignored if KVM_CAP_IMMEDIATE_EXIT is not available. |
| 3903 | |
| 3904 | __u8 padding1[6]; |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 3905 | |
| 3906 | /* out */ |
| 3907 | __u32 exit_reason; |
| 3908 | |
| 3909 | When KVM_RUN has returned successfully (return value 0), this informs |
| 3910 | application code why KVM_RUN has returned. Allowable values for this |
| 3911 | field are detailed below. |
| 3912 | |
| 3913 | __u8 ready_for_interrupt_injection; |
| 3914 | |
| 3915 | If request_interrupt_window has been specified, this field indicates |
| 3916 | an interrupt can be injected now with KVM_INTERRUPT. |
| 3917 | |
| 3918 | __u8 if_flag; |
| 3919 | |
| 3920 | The value of the current interrupt flag. Only valid if in-kernel |
| 3921 | local APIC is not used. |
| 3922 | |
Paolo Bonzini | f077825 | 2015-04-01 15:06:40 +0200 | [diff] [blame] | 3923 | __u16 flags; |
| 3924 | |
| 3925 | More architecture-specific flags detailing state of the VCPU that may |
| 3926 | affect the device's behavior. The only currently defined flag is |
| 3927 | KVM_RUN_X86_SMM, which is valid on x86 machines and is set if the |
| 3928 | VCPU is in system management mode. |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 3929 | |
| 3930 | /* in (pre_kvm_run), out (post_kvm_run) */ |
| 3931 | __u64 cr8; |
| 3932 | |
| 3933 | The value of the cr8 register. Only valid if in-kernel local APIC is |
| 3934 | not used. Both input and output. |
| 3935 | |
| 3936 | __u64 apic_base; |
| 3937 | |
| 3938 | The value of the APIC BASE msr. Only valid if in-kernel local |
| 3939 | APIC is not used. Both input and output. |
| 3940 | |
| 3941 | union { |
| 3942 | /* KVM_EXIT_UNKNOWN */ |
| 3943 | struct { |
| 3944 | __u64 hardware_exit_reason; |
| 3945 | } hw; |
| 3946 | |
| 3947 | If exit_reason is KVM_EXIT_UNKNOWN, the vcpu has exited due to unknown |
| 3948 | reasons. Further architecture-specific information is available in |
| 3949 | hardware_exit_reason. |
| 3950 | |
| 3951 | /* KVM_EXIT_FAIL_ENTRY */ |
| 3952 | struct { |
| 3953 | __u64 hardware_entry_failure_reason; |
| 3954 | } fail_entry; |
| 3955 | |
| 3956 | If exit_reason is KVM_EXIT_FAIL_ENTRY, the vcpu could not be run due |
| 3957 | to unknown reasons. Further architecture-specific information is |
| 3958 | available in hardware_entry_failure_reason. |
| 3959 | |
| 3960 | /* KVM_EXIT_EXCEPTION */ |
| 3961 | struct { |
| 3962 | __u32 exception; |
| 3963 | __u32 error_code; |
| 3964 | } ex; |
| 3965 | |
| 3966 | Unused. |
| 3967 | |
| 3968 | /* KVM_EXIT_IO */ |
| 3969 | struct { |
| 3970 | #define KVM_EXIT_IO_IN 0 |
| 3971 | #define KVM_EXIT_IO_OUT 1 |
| 3972 | __u8 direction; |
| 3973 | __u8 size; /* bytes */ |
| 3974 | __u16 port; |
| 3975 | __u32 count; |
| 3976 | __u64 data_offset; /* relative to kvm_run start */ |
| 3977 | } io; |
| 3978 | |
Wu Fengguang | 2044892d | 2009-12-24 09:04:16 +0800 | [diff] [blame] | 3979 | If exit_reason is KVM_EXIT_IO, then the vcpu has |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 3980 | executed a port I/O instruction which could not be satisfied by kvm. |
| 3981 | data_offset describes where the data is located (KVM_EXIT_IO_OUT) or |
| 3982 | where kvm expects application code to place the data for the next |
Wu Fengguang | 2044892d | 2009-12-24 09:04:16 +0800 | [diff] [blame] | 3983 | KVM_RUN invocation (KVM_EXIT_IO_IN). Data format is a packed array. |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 3984 | |
Alex Bennée | 8ab30c1 | 2015-07-07 17:29:53 +0100 | [diff] [blame] | 3985 | /* KVM_EXIT_DEBUG */ |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 3986 | struct { |
| 3987 | struct kvm_debug_exit_arch arch; |
| 3988 | } debug; |
| 3989 | |
Alex Bennée | 8ab30c1 | 2015-07-07 17:29:53 +0100 | [diff] [blame] | 3990 | If the exit_reason is KVM_EXIT_DEBUG, then a vcpu is processing a debug event |
| 3991 | for which architecture specific information is returned. |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 3992 | |
| 3993 | /* KVM_EXIT_MMIO */ |
| 3994 | struct { |
| 3995 | __u64 phys_addr; |
| 3996 | __u8 data[8]; |
| 3997 | __u32 len; |
| 3998 | __u8 is_write; |
| 3999 | } mmio; |
| 4000 | |
Wu Fengguang | 2044892d | 2009-12-24 09:04:16 +0800 | [diff] [blame] | 4001 | If exit_reason is KVM_EXIT_MMIO, then the vcpu has |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 4002 | executed a memory-mapped I/O instruction which could not be satisfied |
| 4003 | by kvm. The 'data' member contains the written data if 'is_write' is |
| 4004 | true, and should be filled by application code otherwise. |
| 4005 | |
Christoffer Dall | 6acdb16 | 2014-01-28 08:28:42 -0800 | [diff] [blame] | 4006 | The 'data' member contains, in its first 'len' bytes, the value as it would |
| 4007 | appear if the VCPU performed a load or store of the appropriate width directly |
| 4008 | to the byte array. |
| 4009 | |
Paolo Bonzini | cc568ea | 2014-08-05 09:55:22 +0200 | [diff] [blame] | 4010 | NOTE: For KVM_EXIT_IO, KVM_EXIT_MMIO, KVM_EXIT_OSI, KVM_EXIT_PAPR and |
Alexander Graf | ce91ddc | 2014-07-28 19:29:13 +0200 | [diff] [blame] | 4011 | KVM_EXIT_EPR the corresponding |
Alexander Graf | ad0a048 | 2010-03-24 21:48:30 +0100 | [diff] [blame] | 4012 | operations are complete (and guest state is consistent) only after userspace |
| 4013 | has re-entered the kernel with KVM_RUN. The kernel side will first finish |
Marcelo Tosatti | 6796134 | 2010-02-13 16:10:26 -0200 | [diff] [blame] | 4014 | incomplete operations and then check for pending signals. Userspace |
| 4015 | can re-enter the guest with an unmasked signal pending to complete |
| 4016 | pending operations. |
| 4017 | |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 4018 | /* KVM_EXIT_HYPERCALL */ |
| 4019 | struct { |
| 4020 | __u64 nr; |
| 4021 | __u64 args[6]; |
| 4022 | __u64 ret; |
| 4023 | __u32 longmode; |
| 4024 | __u32 pad; |
| 4025 | } hypercall; |
| 4026 | |
Avi Kivity | 647dc49 | 2010-04-01 14:39:21 +0300 | [diff] [blame] | 4027 | Unused. This was once used for 'hypercall to userspace'. To implement |
| 4028 | such functionality, use KVM_EXIT_IO (x86) or KVM_EXIT_MMIO (all except s390). |
| 4029 | Note KVM_EXIT_IO is significantly faster than KVM_EXIT_MMIO. |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 4030 | |
| 4031 | /* KVM_EXIT_TPR_ACCESS */ |
| 4032 | struct { |
| 4033 | __u64 rip; |
| 4034 | __u32 is_write; |
| 4035 | __u32 pad; |
| 4036 | } tpr_access; |
| 4037 | |
| 4038 | To be documented (KVM_TPR_ACCESS_REPORTING). |
| 4039 | |
| 4040 | /* KVM_EXIT_S390_SIEIC */ |
| 4041 | struct { |
| 4042 | __u8 icptcode; |
| 4043 | __u64 mask; /* psw upper half */ |
| 4044 | __u64 addr; /* psw lower half */ |
| 4045 | __u16 ipa; |
| 4046 | __u32 ipb; |
| 4047 | } s390_sieic; |
| 4048 | |
| 4049 | s390 specific. |
| 4050 | |
| 4051 | /* KVM_EXIT_S390_RESET */ |
| 4052 | #define KVM_S390_RESET_POR 1 |
| 4053 | #define KVM_S390_RESET_CLEAR 2 |
| 4054 | #define KVM_S390_RESET_SUBSYSTEM 4 |
| 4055 | #define KVM_S390_RESET_CPU_INIT 8 |
| 4056 | #define KVM_S390_RESET_IPL 16 |
| 4057 | __u64 s390_reset_flags; |
| 4058 | |
| 4059 | s390 specific. |
| 4060 | |
Carsten Otte | e168bf8 | 2012-01-04 10:25:22 +0100 | [diff] [blame] | 4061 | /* KVM_EXIT_S390_UCONTROL */ |
| 4062 | struct { |
| 4063 | __u64 trans_exc_code; |
| 4064 | __u32 pgm_code; |
| 4065 | } s390_ucontrol; |
| 4066 | |
| 4067 | s390 specific. A page fault has occurred for a user controlled virtual |
| 4068 | machine (KVM_VM_S390_UNCONTROL) on it's host page table that cannot be |
| 4069 | resolved by the kernel. |
| 4070 | The program code and the translation exception code that were placed |
| 4071 | in the cpu's lowcore are presented here as defined by the z Architecture |
| 4072 | Principles of Operation Book in the Chapter for Dynamic Address Translation |
| 4073 | (DAT) |
| 4074 | |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 4075 | /* KVM_EXIT_DCR */ |
| 4076 | struct { |
| 4077 | __u32 dcrn; |
| 4078 | __u32 data; |
| 4079 | __u8 is_write; |
| 4080 | } dcr; |
| 4081 | |
Alexander Graf | ce91ddc | 2014-07-28 19:29:13 +0200 | [diff] [blame] | 4082 | Deprecated - was used for 440 KVM. |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 4083 | |
Alexander Graf | ad0a048 | 2010-03-24 21:48:30 +0100 | [diff] [blame] | 4084 | /* KVM_EXIT_OSI */ |
| 4085 | struct { |
| 4086 | __u64 gprs[32]; |
| 4087 | } osi; |
| 4088 | |
| 4089 | MOL uses a special hypercall interface it calls 'OSI'. To enable it, we catch |
| 4090 | hypercalls and exit with this exit struct that contains all the guest gprs. |
| 4091 | |
| 4092 | If exit_reason is KVM_EXIT_OSI, then the vcpu has triggered such a hypercall. |
| 4093 | Userspace can now handle the hypercall and when it's done modify the gprs as |
| 4094 | necessary. Upon guest entry all guest GPRs will then be replaced by the values |
| 4095 | in this struct. |
| 4096 | |
Paul Mackerras | de56a94 | 2011-06-29 00:21:34 +0000 | [diff] [blame] | 4097 | /* KVM_EXIT_PAPR_HCALL */ |
| 4098 | struct { |
| 4099 | __u64 nr; |
| 4100 | __u64 ret; |
| 4101 | __u64 args[9]; |
| 4102 | } papr_hcall; |
| 4103 | |
| 4104 | This is used on 64-bit PowerPC when emulating a pSeries partition, |
| 4105 | e.g. with the 'pseries' machine type in qemu. It occurs when the |
| 4106 | guest does a hypercall using the 'sc 1' instruction. The 'nr' field |
| 4107 | contains the hypercall number (from the guest R3), and 'args' contains |
| 4108 | the arguments (from the guest R4 - R12). Userspace should put the |
| 4109 | return code in 'ret' and any extra returned values in args[]. |
| 4110 | The possible hypercalls are defined in the Power Architecture Platform |
| 4111 | Requirements (PAPR) document available from www.power.org (free |
| 4112 | developer registration required to access it). |
| 4113 | |
Cornelia Huck | fa6b7fe | 2012-12-20 15:32:12 +0100 | [diff] [blame] | 4114 | /* KVM_EXIT_S390_TSCH */ |
| 4115 | struct { |
| 4116 | __u16 subchannel_id; |
| 4117 | __u16 subchannel_nr; |
| 4118 | __u32 io_int_parm; |
| 4119 | __u32 io_int_word; |
| 4120 | __u32 ipb; |
| 4121 | __u8 dequeued; |
| 4122 | } s390_tsch; |
| 4123 | |
| 4124 | s390 specific. This exit occurs when KVM_CAP_S390_CSS_SUPPORT has been enabled |
| 4125 | and TEST SUBCHANNEL was intercepted. If dequeued is set, a pending I/O |
| 4126 | interrupt for the target subchannel has been dequeued and subchannel_id, |
| 4127 | subchannel_nr, io_int_parm and io_int_word contain the parameters for that |
| 4128 | interrupt. ipb is needed for instruction parameter decoding. |
| 4129 | |
Alexander Graf | 1c81063 | 2013-01-04 18:12:48 +0100 | [diff] [blame] | 4130 | /* KVM_EXIT_EPR */ |
| 4131 | struct { |
| 4132 | __u32 epr; |
| 4133 | } epr; |
| 4134 | |
| 4135 | On FSL BookE PowerPC chips, the interrupt controller has a fast patch |
| 4136 | interrupt acknowledge path to the core. When the core successfully |
| 4137 | delivers an interrupt, it automatically populates the EPR register with |
| 4138 | the interrupt vector number and acknowledges the interrupt inside |
| 4139 | the interrupt controller. |
| 4140 | |
| 4141 | In case the interrupt controller lives in user space, we need to do |
| 4142 | the interrupt acknowledge cycle through it to fetch the next to be |
| 4143 | delivered interrupt vector using this exit. |
| 4144 | |
| 4145 | It gets triggered whenever both KVM_CAP_PPC_EPR are enabled and an |
| 4146 | external interrupt has just been delivered into the guest. User space |
| 4147 | should put the acknowledged interrupt vector into the 'epr' field. |
| 4148 | |
Anup Patel | 8ad6b63 | 2014-04-29 11:24:19 +0530 | [diff] [blame] | 4149 | /* KVM_EXIT_SYSTEM_EVENT */ |
| 4150 | struct { |
| 4151 | #define KVM_SYSTEM_EVENT_SHUTDOWN 1 |
| 4152 | #define KVM_SYSTEM_EVENT_RESET 2 |
Andrey Smetanin | 2ce7918 | 2015-07-03 15:01:41 +0300 | [diff] [blame] | 4153 | #define KVM_SYSTEM_EVENT_CRASH 3 |
Anup Patel | 8ad6b63 | 2014-04-29 11:24:19 +0530 | [diff] [blame] | 4154 | __u32 type; |
| 4155 | __u64 flags; |
| 4156 | } system_event; |
| 4157 | |
| 4158 | If exit_reason is KVM_EXIT_SYSTEM_EVENT then the vcpu has triggered |
| 4159 | a system-level event using some architecture specific mechanism (hypercall |
| 4160 | or some special instruction). In case of ARM/ARM64, this is triggered using |
| 4161 | HVC instruction based PSCI call from the vcpu. The 'type' field describes |
| 4162 | the system-level event type. The 'flags' field describes architecture |
| 4163 | specific flags for the system-level event. |
| 4164 | |
Christoffer Dall | cf5d3188 | 2014-10-16 17:00:18 +0200 | [diff] [blame] | 4165 | Valid values for 'type' are: |
| 4166 | KVM_SYSTEM_EVENT_SHUTDOWN -- the guest has requested a shutdown of the |
| 4167 | VM. Userspace is not obliged to honour this, and if it does honour |
| 4168 | this does not need to destroy the VM synchronously (ie it may call |
| 4169 | KVM_RUN again before shutdown finally occurs). |
| 4170 | KVM_SYSTEM_EVENT_RESET -- the guest has requested a reset of the VM. |
| 4171 | As with SHUTDOWN, userspace can choose to ignore the request, or |
| 4172 | to schedule the reset to occur in the future and may call KVM_RUN again. |
Andrey Smetanin | 2ce7918 | 2015-07-03 15:01:41 +0300 | [diff] [blame] | 4173 | KVM_SYSTEM_EVENT_CRASH -- the guest crash occurred and the guest |
| 4174 | has requested a crash condition maintenance. Userspace can choose |
| 4175 | to ignore the request, or to gather VM memory core dump and/or |
| 4176 | reset/shutdown of the VM. |
Christoffer Dall | cf5d3188 | 2014-10-16 17:00:18 +0200 | [diff] [blame] | 4177 | |
Steve Rutherford | 7543a63 | 2015-07-29 23:21:41 -0700 | [diff] [blame] | 4178 | /* KVM_EXIT_IOAPIC_EOI */ |
| 4179 | struct { |
| 4180 | __u8 vector; |
| 4181 | } eoi; |
| 4182 | |
| 4183 | Indicates that the VCPU's in-kernel local APIC received an EOI for a |
| 4184 | level-triggered IOAPIC interrupt. This exit only triggers when the |
| 4185 | IOAPIC is implemented in userspace (i.e. KVM_CAP_SPLIT_IRQCHIP is enabled); |
| 4186 | the userspace IOAPIC should process the EOI and retrigger the interrupt if |
| 4187 | it is still asserted. Vector is the LAPIC interrupt vector for which the |
| 4188 | EOI was received. |
| 4189 | |
Andrey Smetanin | db397571 | 2015-11-10 15:36:35 +0300 | [diff] [blame] | 4190 | struct kvm_hyperv_exit { |
| 4191 | #define KVM_EXIT_HYPERV_SYNIC 1 |
Andrey Smetanin | 83326e4 | 2016-02-11 16:45:01 +0300 | [diff] [blame] | 4192 | #define KVM_EXIT_HYPERV_HCALL 2 |
Andrey Smetanin | db397571 | 2015-11-10 15:36:35 +0300 | [diff] [blame] | 4193 | __u32 type; |
| 4194 | union { |
| 4195 | struct { |
| 4196 | __u32 msr; |
| 4197 | __u64 control; |
| 4198 | __u64 evt_page; |
| 4199 | __u64 msg_page; |
| 4200 | } synic; |
Andrey Smetanin | 83326e4 | 2016-02-11 16:45:01 +0300 | [diff] [blame] | 4201 | struct { |
| 4202 | __u64 input; |
| 4203 | __u64 result; |
| 4204 | __u64 params[2]; |
| 4205 | } hcall; |
Andrey Smetanin | db397571 | 2015-11-10 15:36:35 +0300 | [diff] [blame] | 4206 | } u; |
| 4207 | }; |
| 4208 | /* KVM_EXIT_HYPERV */ |
| 4209 | struct kvm_hyperv_exit hyperv; |
| 4210 | Indicates that the VCPU exits into userspace to process some tasks |
| 4211 | related to Hyper-V emulation. |
| 4212 | Valid values for 'type' are: |
| 4213 | KVM_EXIT_HYPERV_SYNIC -- synchronously notify user-space about |
| 4214 | Hyper-V SynIC state change. Notification is used to remap SynIC |
| 4215 | event/message pages and to enable/disable SynIC messages/events processing |
| 4216 | in userspace. |
| 4217 | |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 4218 | /* Fix the size of the union. */ |
| 4219 | char padding[256]; |
| 4220 | }; |
Christian Borntraeger | b9e5dc8 | 2012-01-11 11:20:30 +0100 | [diff] [blame] | 4221 | |
| 4222 | /* |
| 4223 | * shared registers between kvm and userspace. |
| 4224 | * kvm_valid_regs specifies the register classes set by the host |
| 4225 | * kvm_dirty_regs specified the register classes dirtied by userspace |
| 4226 | * struct kvm_sync_regs is architecture specific, as well as the |
| 4227 | * bits for kvm_valid_regs and kvm_dirty_regs |
| 4228 | */ |
| 4229 | __u64 kvm_valid_regs; |
| 4230 | __u64 kvm_dirty_regs; |
| 4231 | union { |
| 4232 | struct kvm_sync_regs regs; |
Ken Hofsass | 7b7e395 | 2018-01-31 16:03:35 -0800 | [diff] [blame] | 4233 | char padding[SYNC_REGS_SIZE_BYTES]; |
Christian Borntraeger | b9e5dc8 | 2012-01-11 11:20:30 +0100 | [diff] [blame] | 4234 | } s; |
| 4235 | |
| 4236 | If KVM_CAP_SYNC_REGS is defined, these fields allow userspace to access |
| 4237 | certain guest registers without having to call SET/GET_*REGS. Thus we can |
| 4238 | avoid some system call overhead if userspace has to handle the exit. |
| 4239 | Userspace can query the validity of the structure by checking |
| 4240 | kvm_valid_regs for specific bits. These bits are architecture specific |
| 4241 | and usually define the validity of a groups of registers. (e.g. one bit |
| 4242 | for general purpose registers) |
| 4243 | |
David Hildenbrand | d8482c0 | 2014-07-29 08:19:26 +0200 | [diff] [blame] | 4244 | Please note that the kernel is allowed to use the kvm_run structure as the |
| 4245 | primary storage for certain register types. Therefore, the kernel may use the |
| 4246 | values in kvm_run even if the corresponding bit in kvm_dirty_regs is not set. |
| 4247 | |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 4248 | }; |
Alexander Graf | 821246a | 2011-08-31 10:58:55 +0200 | [diff] [blame] | 4249 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 4250 | |
Borislav Petkov | 9c15bb1 | 2013-09-22 16:44:50 +0200 | [diff] [blame] | 4251 | |
Paul Mackerras | 699a0ea | 2014-06-02 11:02:59 +1000 | [diff] [blame] | 4252 | 6. Capabilities that can be enabled on vCPUs |
| 4253 | -------------------------------------------- |
Alexander Graf | 821246a | 2011-08-31 10:58:55 +0200 | [diff] [blame] | 4254 | |
Cornelia Huck | 0907c85 | 2014-06-27 09:29:26 +0200 | [diff] [blame] | 4255 | There are certain capabilities that change the behavior of the virtual CPU or |
| 4256 | the virtual machine when enabled. To enable them, please see section 4.37. |
| 4257 | Below you can find a list of capabilities and what their effect on the vCPU or |
| 4258 | the virtual machine is when enabling them. |
Alexander Graf | 821246a | 2011-08-31 10:58:55 +0200 | [diff] [blame] | 4259 | |
| 4260 | The following information is provided along with the description: |
| 4261 | |
| 4262 | Architectures: which instruction set architectures provide this ioctl. |
| 4263 | x86 includes both i386 and x86_64. |
| 4264 | |
Cornelia Huck | 0907c85 | 2014-06-27 09:29:26 +0200 | [diff] [blame] | 4265 | Target: whether this is a per-vcpu or per-vm capability. |
| 4266 | |
Alexander Graf | 821246a | 2011-08-31 10:58:55 +0200 | [diff] [blame] | 4267 | Parameters: what parameters are accepted by the capability. |
| 4268 | |
| 4269 | Returns: the return value. General error numbers (EBADF, ENOMEM, EINVAL) |
| 4270 | are not detailed, but errors with specific meanings are. |
| 4271 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 4272 | |
Alexander Graf | 821246a | 2011-08-31 10:58:55 +0200 | [diff] [blame] | 4273 | 6.1 KVM_CAP_PPC_OSI |
| 4274 | |
| 4275 | Architectures: ppc |
Cornelia Huck | 0907c85 | 2014-06-27 09:29:26 +0200 | [diff] [blame] | 4276 | Target: vcpu |
Alexander Graf | 821246a | 2011-08-31 10:58:55 +0200 | [diff] [blame] | 4277 | Parameters: none |
| 4278 | Returns: 0 on success; -1 on error |
| 4279 | |
| 4280 | This capability enables interception of OSI hypercalls that otherwise would |
| 4281 | be treated as normal system calls to be injected into the guest. OSI hypercalls |
| 4282 | were invented by Mac-on-Linux to have a standardized communication mechanism |
| 4283 | between the guest and the host. |
| 4284 | |
| 4285 | When this capability is enabled, KVM_EXIT_OSI can occur. |
| 4286 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 4287 | |
Alexander Graf | 821246a | 2011-08-31 10:58:55 +0200 | [diff] [blame] | 4288 | 6.2 KVM_CAP_PPC_PAPR |
| 4289 | |
| 4290 | Architectures: ppc |
Cornelia Huck | 0907c85 | 2014-06-27 09:29:26 +0200 | [diff] [blame] | 4291 | Target: vcpu |
Alexander Graf | 821246a | 2011-08-31 10:58:55 +0200 | [diff] [blame] | 4292 | Parameters: none |
| 4293 | Returns: 0 on success; -1 on error |
| 4294 | |
| 4295 | This capability enables interception of PAPR hypercalls. PAPR hypercalls are |
| 4296 | done using the hypercall instruction "sc 1". |
| 4297 | |
| 4298 | It also sets the guest privilege level to "supervisor" mode. Usually the guest |
| 4299 | runs in "hypervisor" privilege mode with a few missing features. |
| 4300 | |
| 4301 | In addition to the above, it changes the semantics of SDR1. In this mode, the |
| 4302 | HTAB address part of SDR1 contains an HVA instead of a GPA, as PAPR keeps the |
| 4303 | HTAB invisible to the guest. |
| 4304 | |
| 4305 | When this capability is enabled, KVM_EXIT_PAPR_HCALL can occur. |
Scott Wood | dc83b8b | 2011-08-18 15:25:21 -0500 | [diff] [blame] | 4306 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 4307 | |
Scott Wood | dc83b8b | 2011-08-18 15:25:21 -0500 | [diff] [blame] | 4308 | 6.3 KVM_CAP_SW_TLB |
| 4309 | |
| 4310 | Architectures: ppc |
Cornelia Huck | 0907c85 | 2014-06-27 09:29:26 +0200 | [diff] [blame] | 4311 | Target: vcpu |
Scott Wood | dc83b8b | 2011-08-18 15:25:21 -0500 | [diff] [blame] | 4312 | Parameters: args[0] is the address of a struct kvm_config_tlb |
| 4313 | Returns: 0 on success; -1 on error |
| 4314 | |
| 4315 | struct kvm_config_tlb { |
| 4316 | __u64 params; |
| 4317 | __u64 array; |
| 4318 | __u32 mmu_type; |
| 4319 | __u32 array_len; |
| 4320 | }; |
| 4321 | |
| 4322 | Configures the virtual CPU's TLB array, establishing a shared memory area |
| 4323 | between userspace and KVM. The "params" and "array" fields are userspace |
| 4324 | addresses of mmu-type-specific data structures. The "array_len" field is an |
| 4325 | safety mechanism, and should be set to the size in bytes of the memory that |
| 4326 | userspace has reserved for the array. It must be at least the size dictated |
| 4327 | by "mmu_type" and "params". |
| 4328 | |
| 4329 | While KVM_RUN is active, the shared region is under control of KVM. Its |
| 4330 | contents are undefined, and any modification by userspace results in |
| 4331 | boundedly undefined behavior. |
| 4332 | |
| 4333 | On return from KVM_RUN, the shared region will reflect the current state of |
| 4334 | the guest's TLB. If userspace makes any changes, it must call KVM_DIRTY_TLB |
| 4335 | to tell KVM which entries have been changed, prior to calling KVM_RUN again |
| 4336 | on this vcpu. |
| 4337 | |
| 4338 | For mmu types KVM_MMU_FSL_BOOKE_NOHV and KVM_MMU_FSL_BOOKE_HV: |
| 4339 | - The "params" field is of type "struct kvm_book3e_206_tlb_params". |
| 4340 | - The "array" field points to an array of type "struct |
| 4341 | kvm_book3e_206_tlb_entry". |
| 4342 | - The array consists of all entries in the first TLB, followed by all |
| 4343 | entries in the second TLB. |
| 4344 | - Within a TLB, entries are ordered first by increasing set number. Within a |
| 4345 | set, entries are ordered by way (increasing ESEL). |
| 4346 | - The hash for determining set number in TLB0 is: (MAS2 >> 12) & (num_sets - 1) |
| 4347 | where "num_sets" is the tlb_sizes[] value divided by the tlb_ways[] value. |
| 4348 | - The tsize field of mas1 shall be set to 4K on TLB0, even though the |
| 4349 | hardware ignores this value for TLB0. |
Cornelia Huck | fa6b7fe | 2012-12-20 15:32:12 +0100 | [diff] [blame] | 4350 | |
| 4351 | 6.4 KVM_CAP_S390_CSS_SUPPORT |
| 4352 | |
| 4353 | Architectures: s390 |
Cornelia Huck | 0907c85 | 2014-06-27 09:29:26 +0200 | [diff] [blame] | 4354 | Target: vcpu |
Cornelia Huck | fa6b7fe | 2012-12-20 15:32:12 +0100 | [diff] [blame] | 4355 | Parameters: none |
| 4356 | Returns: 0 on success; -1 on error |
| 4357 | |
| 4358 | This capability enables support for handling of channel I/O instructions. |
| 4359 | |
| 4360 | TEST PENDING INTERRUPTION and the interrupt portion of TEST SUBCHANNEL are |
| 4361 | handled in-kernel, while the other I/O instructions are passed to userspace. |
| 4362 | |
| 4363 | When this capability is enabled, KVM_EXIT_S390_TSCH will occur on TEST |
| 4364 | SUBCHANNEL intercepts. |
Alexander Graf | 1c81063 | 2013-01-04 18:12:48 +0100 | [diff] [blame] | 4365 | |
Cornelia Huck | 0907c85 | 2014-06-27 09:29:26 +0200 | [diff] [blame] | 4366 | Note that even though this capability is enabled per-vcpu, the complete |
| 4367 | virtual machine is affected. |
| 4368 | |
Alexander Graf | 1c81063 | 2013-01-04 18:12:48 +0100 | [diff] [blame] | 4369 | 6.5 KVM_CAP_PPC_EPR |
| 4370 | |
| 4371 | Architectures: ppc |
Cornelia Huck | 0907c85 | 2014-06-27 09:29:26 +0200 | [diff] [blame] | 4372 | Target: vcpu |
Alexander Graf | 1c81063 | 2013-01-04 18:12:48 +0100 | [diff] [blame] | 4373 | Parameters: args[0] defines whether the proxy facility is active |
| 4374 | Returns: 0 on success; -1 on error |
| 4375 | |
| 4376 | This capability enables or disables the delivery of interrupts through the |
| 4377 | external proxy facility. |
| 4378 | |
| 4379 | When enabled (args[0] != 0), every time the guest gets an external interrupt |
| 4380 | delivered, it automatically exits into user space with a KVM_EXIT_EPR exit |
| 4381 | to receive the topmost interrupt vector. |
| 4382 | |
| 4383 | When disabled (args[0] == 0), behavior is as if this facility is unsupported. |
| 4384 | |
| 4385 | When this capability is enabled, KVM_EXIT_EPR can occur. |
Scott Wood | eb1e4f4 | 2013-04-12 14:08:47 +0000 | [diff] [blame] | 4386 | |
| 4387 | 6.6 KVM_CAP_IRQ_MPIC |
| 4388 | |
| 4389 | Architectures: ppc |
| 4390 | Parameters: args[0] is the MPIC device fd |
| 4391 | args[1] is the MPIC CPU number for this vcpu |
| 4392 | |
| 4393 | This capability connects the vcpu to an in-kernel MPIC device. |
Paul Mackerras | 5975a2e | 2013-04-27 00:28:37 +0000 | [diff] [blame] | 4394 | |
| 4395 | 6.7 KVM_CAP_IRQ_XICS |
| 4396 | |
| 4397 | Architectures: ppc |
Cornelia Huck | 0907c85 | 2014-06-27 09:29:26 +0200 | [diff] [blame] | 4398 | Target: vcpu |
Paul Mackerras | 5975a2e | 2013-04-27 00:28:37 +0000 | [diff] [blame] | 4399 | Parameters: args[0] is the XICS device fd |
| 4400 | args[1] is the XICS CPU number (server ID) for this vcpu |
| 4401 | |
| 4402 | This capability connects the vcpu to an in-kernel XICS device. |
Cornelia Huck | 8a366a4 | 2014-06-27 11:06:25 +0200 | [diff] [blame] | 4403 | |
| 4404 | 6.8 KVM_CAP_S390_IRQCHIP |
| 4405 | |
| 4406 | Architectures: s390 |
| 4407 | Target: vm |
| 4408 | Parameters: none |
| 4409 | |
| 4410 | This capability enables the in-kernel irqchip for s390. Please refer to |
| 4411 | "4.24 KVM_CREATE_IRQCHIP" for details. |
Paul Mackerras | 699a0ea | 2014-06-02 11:02:59 +1000 | [diff] [blame] | 4412 | |
James Hogan | 5fafd874 | 2014-12-08 23:07:56 +0000 | [diff] [blame] | 4413 | 6.9 KVM_CAP_MIPS_FPU |
| 4414 | |
| 4415 | Architectures: mips |
| 4416 | Target: vcpu |
| 4417 | Parameters: args[0] is reserved for future use (should be 0). |
| 4418 | |
| 4419 | This capability allows the use of the host Floating Point Unit by the guest. It |
| 4420 | allows the Config1.FP bit to be set to enable the FPU in the guest. Once this is |
| 4421 | done the KVM_REG_MIPS_FPR_* and KVM_REG_MIPS_FCR_* registers can be accessed |
| 4422 | (depending on the current guest FPU register mode), and the Status.FR, |
| 4423 | Config5.FRE bits are accessible via the KVM API and also from the guest, |
| 4424 | depending on them being supported by the FPU. |
| 4425 | |
James Hogan | d952bd0 | 2014-12-08 23:07:56 +0000 | [diff] [blame] | 4426 | 6.10 KVM_CAP_MIPS_MSA |
| 4427 | |
| 4428 | Architectures: mips |
| 4429 | Target: vcpu |
| 4430 | Parameters: args[0] is reserved for future use (should be 0). |
| 4431 | |
| 4432 | This capability allows the use of the MIPS SIMD Architecture (MSA) by the guest. |
| 4433 | It allows the Config3.MSAP bit to be set to enable the use of MSA by the guest. |
| 4434 | Once this is done the KVM_REG_MIPS_VEC_* and KVM_REG_MIPS_MSA_* registers can be |
| 4435 | accessed, and the Config5.MSAEn bit is accessible via the KVM API and also from |
| 4436 | the guest. |
| 4437 | |
Ken Hofsass | 01643c5 | 2018-01-31 16:03:36 -0800 | [diff] [blame] | 4438 | 6.74 KVM_CAP_SYNC_REGS |
| 4439 | Architectures: s390, x86 |
| 4440 | Target: s390: always enabled, x86: vcpu |
| 4441 | Parameters: none |
| 4442 | Returns: x86: KVM_CHECK_EXTENSION returns a bit-array indicating which register |
| 4443 | sets are supported (bitfields defined in arch/x86/include/uapi/asm/kvm.h). |
| 4444 | |
| 4445 | As described above in the kvm_sync_regs struct info in section 5 (kvm_run): |
| 4446 | KVM_CAP_SYNC_REGS "allow[s] userspace to access certain guest registers |
| 4447 | without having to call SET/GET_*REGS". This reduces overhead by eliminating |
| 4448 | repeated ioctl calls for setting and/or getting register values. This is |
| 4449 | particularly important when userspace is making synchronous guest state |
| 4450 | modifications, e.g. when emulating and/or intercepting instructions in |
| 4451 | userspace. |
| 4452 | |
| 4453 | For s390 specifics, please refer to the source code. |
| 4454 | |
| 4455 | For x86: |
| 4456 | - the register sets to be copied out to kvm_run are selectable |
| 4457 | by userspace (rather that all sets being copied out for every exit). |
| 4458 | - vcpu_events are available in addition to regs and sregs. |
| 4459 | |
| 4460 | For x86, the 'kvm_valid_regs' field of struct kvm_run is overloaded to |
| 4461 | function as an input bit-array field set by userspace to indicate the |
| 4462 | specific register sets to be copied out on the next exit. |
| 4463 | |
| 4464 | To indicate when userspace has modified values that should be copied into |
| 4465 | the vCPU, the all architecture bitarray field, 'kvm_dirty_regs' must be set. |
| 4466 | This is done using the same bitflags as for the 'kvm_valid_regs' field. |
| 4467 | If the dirty bit is not set, then the register set values will not be copied |
| 4468 | into the vCPU even if they've been modified. |
| 4469 | |
| 4470 | Unused bitfields in the bitarrays must be set to zero. |
| 4471 | |
| 4472 | struct kvm_sync_regs { |
| 4473 | struct kvm_regs regs; |
| 4474 | struct kvm_sregs sregs; |
| 4475 | struct kvm_vcpu_events events; |
| 4476 | }; |
| 4477 | |
Paul Mackerras | 699a0ea | 2014-06-02 11:02:59 +1000 | [diff] [blame] | 4478 | 7. Capabilities that can be enabled on VMs |
| 4479 | ------------------------------------------ |
| 4480 | |
| 4481 | There are certain capabilities that change the behavior of the virtual |
| 4482 | machine when enabled. To enable them, please see section 4.37. Below |
| 4483 | you can find a list of capabilities and what their effect on the VM |
| 4484 | is when enabling them. |
| 4485 | |
| 4486 | The following information is provided along with the description: |
| 4487 | |
| 4488 | Architectures: which instruction set architectures provide this ioctl. |
| 4489 | x86 includes both i386 and x86_64. |
| 4490 | |
| 4491 | Parameters: what parameters are accepted by the capability. |
| 4492 | |
| 4493 | Returns: the return value. General error numbers (EBADF, ENOMEM, EINVAL) |
| 4494 | are not detailed, but errors with specific meanings are. |
| 4495 | |
| 4496 | |
| 4497 | 7.1 KVM_CAP_PPC_ENABLE_HCALL |
| 4498 | |
| 4499 | Architectures: ppc |
| 4500 | Parameters: args[0] is the sPAPR hcall number |
| 4501 | args[1] is 0 to disable, 1 to enable in-kernel handling |
| 4502 | |
| 4503 | This capability controls whether individual sPAPR hypercalls (hcalls) |
| 4504 | get handled by the kernel or not. Enabling or disabling in-kernel |
| 4505 | handling of an hcall is effective across the VM. On creation, an |
| 4506 | initial set of hcalls are enabled for in-kernel handling, which |
| 4507 | consists of those hcalls for which in-kernel handlers were implemented |
| 4508 | before this capability was implemented. If disabled, the kernel will |
| 4509 | not to attempt to handle the hcall, but will always exit to userspace |
| 4510 | to handle it. Note that it may not make sense to enable some and |
| 4511 | disable others of a group of related hcalls, but KVM does not prevent |
| 4512 | userspace from doing that. |
Paul Mackerras | ae2113a | 2014-06-02 11:03:00 +1000 | [diff] [blame] | 4513 | |
| 4514 | If the hcall number specified is not one that has an in-kernel |
| 4515 | implementation, the KVM_ENABLE_CAP ioctl will fail with an EINVAL |
| 4516 | error. |
David Hildenbrand | 2444b35 | 2014-10-09 14:10:13 +0200 | [diff] [blame] | 4517 | |
| 4518 | 7.2 KVM_CAP_S390_USER_SIGP |
| 4519 | |
| 4520 | Architectures: s390 |
| 4521 | Parameters: none |
| 4522 | |
| 4523 | This capability controls which SIGP orders will be handled completely in user |
| 4524 | space. With this capability enabled, all fast orders will be handled completely |
| 4525 | in the kernel: |
| 4526 | - SENSE |
| 4527 | - SENSE RUNNING |
| 4528 | - EXTERNAL CALL |
| 4529 | - EMERGENCY SIGNAL |
| 4530 | - CONDITIONAL EMERGENCY SIGNAL |
| 4531 | |
| 4532 | All other orders will be handled completely in user space. |
| 4533 | |
| 4534 | Only privileged operation exceptions will be checked for in the kernel (or even |
| 4535 | in the hardware prior to interception). If this capability is not enabled, the |
| 4536 | old way of handling SIGP orders is used (partially in kernel and user space). |
Eric Farman | 68c5575 | 2014-06-09 10:57:26 -0400 | [diff] [blame] | 4537 | |
| 4538 | 7.3 KVM_CAP_S390_VECTOR_REGISTERS |
| 4539 | |
| 4540 | Architectures: s390 |
| 4541 | Parameters: none |
| 4542 | Returns: 0 on success, negative value on error |
| 4543 | |
| 4544 | Allows use of the vector registers introduced with z13 processor, and |
| 4545 | provides for the synchronization between host and user space. Will |
| 4546 | return -EINVAL if the machine does not support vectors. |
Ekaterina Tumanova | e44fc8c | 2015-01-30 16:55:56 +0100 | [diff] [blame] | 4547 | |
| 4548 | 7.4 KVM_CAP_S390_USER_STSI |
| 4549 | |
| 4550 | Architectures: s390 |
| 4551 | Parameters: none |
| 4552 | |
| 4553 | This capability allows post-handlers for the STSI instruction. After |
| 4554 | initial handling in the kernel, KVM exits to user space with |
| 4555 | KVM_EXIT_S390_STSI to allow user space to insert further data. |
| 4556 | |
| 4557 | Before exiting to userspace, kvm handlers should fill in s390_stsi field of |
| 4558 | vcpu->run: |
| 4559 | struct { |
| 4560 | __u64 addr; |
| 4561 | __u8 ar; |
| 4562 | __u8 reserved; |
| 4563 | __u8 fc; |
| 4564 | __u8 sel1; |
| 4565 | __u16 sel2; |
| 4566 | } s390_stsi; |
| 4567 | |
| 4568 | @addr - guest address of STSI SYSIB |
| 4569 | @fc - function code |
| 4570 | @sel1 - selector 1 |
| 4571 | @sel2 - selector 2 |
| 4572 | @ar - access register number |
| 4573 | |
| 4574 | KVM handlers should exit to userspace with rc = -EREMOTE. |
Michael Ellerman | e928e9c | 2015-03-20 20:39:41 +1100 | [diff] [blame] | 4575 | |
Steve Rutherford | 49df639 | 2015-07-29 23:21:40 -0700 | [diff] [blame] | 4576 | 7.5 KVM_CAP_SPLIT_IRQCHIP |
| 4577 | |
| 4578 | Architectures: x86 |
Steve Rutherford | b053b2a | 2015-07-29 23:32:35 -0700 | [diff] [blame] | 4579 | Parameters: args[0] - number of routes reserved for userspace IOAPICs |
Steve Rutherford | 49df639 | 2015-07-29 23:21:40 -0700 | [diff] [blame] | 4580 | Returns: 0 on success, -1 on error |
| 4581 | |
| 4582 | Create a local apic for each processor in the kernel. This can be used |
| 4583 | instead of KVM_CREATE_IRQCHIP if the userspace VMM wishes to emulate the |
| 4584 | IOAPIC and PIC (and also the PIT, even though this has to be enabled |
| 4585 | separately). |
| 4586 | |
Steve Rutherford | b053b2a | 2015-07-29 23:32:35 -0700 | [diff] [blame] | 4587 | This capability also enables in kernel routing of interrupt requests; |
| 4588 | when KVM_CAP_SPLIT_IRQCHIP only routes of KVM_IRQ_ROUTING_MSI type are |
| 4589 | used in the IRQ routing table. The first args[0] MSI routes are reserved |
| 4590 | for the IOAPIC pins. Whenever the LAPIC receives an EOI for these routes, |
| 4591 | a KVM_EXIT_IOAPIC_EOI vmexit will be reported to userspace. |
Steve Rutherford | 49df639 | 2015-07-29 23:21:40 -0700 | [diff] [blame] | 4592 | |
| 4593 | Fails if VCPU has already been created, or if the irqchip is already in the |
| 4594 | kernel (i.e. KVM_CREATE_IRQCHIP has already been called). |
| 4595 | |
David Hildenbrand | 051c87f | 2016-04-19 13:13:40 +0200 | [diff] [blame] | 4596 | 7.6 KVM_CAP_S390_RI |
| 4597 | |
| 4598 | Architectures: s390 |
| 4599 | Parameters: none |
| 4600 | |
| 4601 | Allows use of runtime-instrumentation introduced with zEC12 processor. |
| 4602 | Will return -EINVAL if the machine does not support runtime-instrumentation. |
| 4603 | Will return -EBUSY if a VCPU has already been created. |
Michael Ellerman | e928e9c | 2015-03-20 20:39:41 +1100 | [diff] [blame] | 4604 | |
Radim Krčmář | 37131313 | 2016-07-12 22:09:27 +0200 | [diff] [blame] | 4605 | 7.7 KVM_CAP_X2APIC_API |
| 4606 | |
| 4607 | Architectures: x86 |
| 4608 | Parameters: args[0] - features that should be enabled |
| 4609 | Returns: 0 on success, -EINVAL when args[0] contains invalid features |
| 4610 | |
| 4611 | Valid feature flags in args[0] are |
| 4612 | |
| 4613 | #define KVM_X2APIC_API_USE_32BIT_IDS (1ULL << 0) |
Radim Krčmář | c519265 | 2016-07-12 22:09:28 +0200 | [diff] [blame] | 4614 | #define KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK (1ULL << 1) |
Radim Krčmář | 37131313 | 2016-07-12 22:09:27 +0200 | [diff] [blame] | 4615 | |
| 4616 | Enabling KVM_X2APIC_API_USE_32BIT_IDS changes the behavior of |
| 4617 | KVM_SET_GSI_ROUTING, KVM_SIGNAL_MSI, KVM_SET_LAPIC, and KVM_GET_LAPIC, |
| 4618 | allowing the use of 32-bit APIC IDs. See KVM_CAP_X2APIC_API in their |
| 4619 | respective sections. |
| 4620 | |
Radim Krčmář | c519265 | 2016-07-12 22:09:28 +0200 | [diff] [blame] | 4621 | KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK must be enabled for x2APIC to work |
| 4622 | in logical mode or with more than 255 VCPUs. Otherwise, KVM treats 0xff |
| 4623 | as a broadcast even in x2APIC mode in order to support physical x2APIC |
| 4624 | without interrupt remapping. This is undesirable in logical mode, |
| 4625 | where 0xff represents CPUs 0-7 in cluster 0. |
Radim Krčmář | 37131313 | 2016-07-12 22:09:27 +0200 | [diff] [blame] | 4626 | |
David Hildenbrand | 6502a34 | 2016-06-21 14:19:51 +0200 | [diff] [blame] | 4627 | 7.8 KVM_CAP_S390_USER_INSTR0 |
| 4628 | |
| 4629 | Architectures: s390 |
| 4630 | Parameters: none |
| 4631 | |
| 4632 | With this capability enabled, all illegal instructions 0x0000 (2 bytes) will |
| 4633 | be intercepted and forwarded to user space. User space can use this |
| 4634 | mechanism e.g. to realize 2-byte software breakpoints. The kernel will |
| 4635 | not inject an operating exception for these instructions, user space has |
| 4636 | to take care of that. |
| 4637 | |
| 4638 | This capability can be enabled dynamically even if VCPUs were already |
| 4639 | created and are running. |
Radim Krčmář | 37131313 | 2016-07-12 22:09:27 +0200 | [diff] [blame] | 4640 | |
Fan Zhang | 4e0b1ab | 2016-11-29 07:17:55 +0100 | [diff] [blame] | 4641 | 7.9 KVM_CAP_S390_GS |
| 4642 | |
| 4643 | Architectures: s390 |
| 4644 | Parameters: none |
| 4645 | Returns: 0 on success; -EINVAL if the machine does not support |
| 4646 | guarded storage; -EBUSY if a VCPU has already been created. |
| 4647 | |
| 4648 | Allows use of guarded storage for the KVM guest. |
| 4649 | |
Yi Min Zhao | 47a4693 | 2017-03-10 09:29:38 +0100 | [diff] [blame] | 4650 | 7.10 KVM_CAP_S390_AIS |
| 4651 | |
| 4652 | Architectures: s390 |
| 4653 | Parameters: none |
| 4654 | |
| 4655 | Allow use of adapter-interruption suppression. |
| 4656 | Returns: 0 on success; -EBUSY if a VCPU has already been created. |
| 4657 | |
Paul Mackerras | 3c31352 | 2017-02-06 13:24:41 +1100 | [diff] [blame] | 4658 | 7.11 KVM_CAP_PPC_SMT |
| 4659 | |
| 4660 | Architectures: ppc |
| 4661 | Parameters: vsmt_mode, flags |
| 4662 | |
| 4663 | Enabling this capability on a VM provides userspace with a way to set |
| 4664 | the desired virtual SMT mode (i.e. the number of virtual CPUs per |
| 4665 | virtual core). The virtual SMT mode, vsmt_mode, must be a power of 2 |
| 4666 | between 1 and 8. On POWER8, vsmt_mode must also be no greater than |
| 4667 | the number of threads per subcore for the host. Currently flags must |
| 4668 | be 0. A successful call to enable this capability will result in |
| 4669 | vsmt_mode being returned when the KVM_CAP_PPC_SMT capability is |
| 4670 | subsequently queried for the VM. This capability is only supported by |
| 4671 | HV KVM, and can only be set before any VCPUs have been created. |
Paul Mackerras | 2ed4f9d | 2017-06-21 16:01:27 +1000 | [diff] [blame] | 4672 | The KVM_CAP_PPC_SMT_POSSIBLE capability indicates which virtual SMT |
| 4673 | modes are available. |
Paul Mackerras | 3c31352 | 2017-02-06 13:24:41 +1100 | [diff] [blame] | 4674 | |
Aravinda Prasad | 134764e | 2017-05-11 16:32:48 +0530 | [diff] [blame] | 4675 | 7.12 KVM_CAP_PPC_FWNMI |
| 4676 | |
| 4677 | Architectures: ppc |
| 4678 | Parameters: none |
| 4679 | |
| 4680 | With this capability a machine check exception in the guest address |
| 4681 | space will cause KVM to exit the guest with NMI exit reason. This |
| 4682 | enables QEMU to build error log and branch to guest kernel registered |
| 4683 | machine check handling routine. Without this capability KVM will |
| 4684 | branch to guests' 0x200 interrupt vector. |
| 4685 | |
Wanpeng Li | 4d5422c | 2018-03-12 04:53:02 -0700 | [diff] [blame] | 4686 | 7.13 KVM_CAP_X86_DISABLE_EXITS |
| 4687 | |
| 4688 | Architectures: x86 |
| 4689 | Parameters: args[0] defines which exits are disabled |
| 4690 | Returns: 0 on success, -EINVAL when args[0] contains invalid exits |
| 4691 | |
| 4692 | Valid bits in args[0] are |
| 4693 | |
| 4694 | #define KVM_X86_DISABLE_EXITS_MWAIT (1 << 0) |
Wanpeng Li | caa057a | 2018-03-12 04:53:03 -0700 | [diff] [blame] | 4695 | #define KVM_X86_DISABLE_EXITS_HLT (1 << 1) |
Wanpeng Li | 4d5422c | 2018-03-12 04:53:02 -0700 | [diff] [blame] | 4696 | |
| 4697 | Enabling this capability on a VM provides userspace with a way to no |
| 4698 | longer intercept some instructions for improved latency in some |
| 4699 | workloads, and is suggested when vCPUs are associated to dedicated |
| 4700 | physical CPUs. More bits can be added in the future; userspace can |
| 4701 | just pass the KVM_CHECK_EXTENSION result to KVM_ENABLE_CAP to disable |
| 4702 | all such vmexits. |
| 4703 | |
Wanpeng Li | caa057a | 2018-03-12 04:53:03 -0700 | [diff] [blame] | 4704 | Do not enable KVM_FEATURE_PV_UNHALT if you disable HLT exits. |
Wanpeng Li | 4d5422c | 2018-03-12 04:53:02 -0700 | [diff] [blame] | 4705 | |
Janosch Frank | a449938 | 2018-07-13 11:28:31 +0100 | [diff] [blame] | 4706 | 7.14 KVM_CAP_S390_HPAGE_1M |
| 4707 | |
| 4708 | Architectures: s390 |
| 4709 | Parameters: none |
| 4710 | Returns: 0 on success, -EINVAL if hpage module parameter was not set |
Janosch Frank | 40ebdb8 | 2018-08-01 11:48:28 +0100 | [diff] [blame] | 4711 | or cmma is enabled, or the VM has the KVM_VM_S390_UCONTROL |
| 4712 | flag set |
Janosch Frank | a449938 | 2018-07-13 11:28:31 +0100 | [diff] [blame] | 4713 | |
| 4714 | With this capability the KVM support for memory backing with 1m pages |
| 4715 | through hugetlbfs can be enabled for a VM. After the capability is |
| 4716 | enabled, cmma can't be enabled anymore and pfmfi and the storage key |
| 4717 | interpretation are disabled. If cmma has already been enabled or the |
| 4718 | hpage module parameter is not set to 1, -EINVAL is returned. |
| 4719 | |
| 4720 | While it is generally possible to create a huge page backed VM without |
| 4721 | this capability, the VM will not be able to run. |
| 4722 | |
Jim Mattson | c4f5519 | 2018-10-16 14:29:24 -0700 | [diff] [blame] | 4723 | 7.15 KVM_CAP_MSR_PLATFORM_INFO |
Drew Schmitt | 6fbbde9 | 2018-08-20 10:32:15 -0700 | [diff] [blame] | 4724 | |
| 4725 | Architectures: x86 |
| 4726 | Parameters: args[0] whether feature should be enabled or not |
| 4727 | |
| 4728 | With this capability, a guest may read the MSR_PLATFORM_INFO MSR. Otherwise, |
| 4729 | a #GP would be raised when the guest tries to access. Currently, this |
| 4730 | capability does not enable write permissions of this MSR for the guest. |
| 4731 | |
Paul Mackerras | aa069a9 | 2018-09-21 20:02:01 +1000 | [diff] [blame] | 4732 | 7.16 KVM_CAP_PPC_NESTED_HV |
| 4733 | |
| 4734 | Architectures: ppc |
| 4735 | Parameters: none |
| 4736 | Returns: 0 on success, -EINVAL when the implementation doesn't support |
| 4737 | nested-HV virtualization. |
| 4738 | |
| 4739 | HV-KVM on POWER9 and later systems allows for "nested-HV" |
| 4740 | virtualization, which provides a way for a guest VM to run guests that |
| 4741 | can run using the CPU's supervisor mode (privileged non-hypervisor |
| 4742 | state). Enabling this capability on a VM depends on the CPU having |
| 4743 | the necessary functionality and on the facility being enabled with a |
| 4744 | kvm-hv module parameter. |
| 4745 | |
Jim Mattson | c4f5519 | 2018-10-16 14:29:24 -0700 | [diff] [blame] | 4746 | 7.17 KVM_CAP_EXCEPTION_PAYLOAD |
| 4747 | |
| 4748 | Architectures: x86 |
| 4749 | Parameters: args[0] whether feature should be enabled or not |
| 4750 | |
| 4751 | With this capability enabled, CR2 will not be modified prior to the |
| 4752 | emulated VM-exit when L1 intercepts a #PF exception that occurs in |
| 4753 | L2. Similarly, for kvm-intel only, DR6 will not be modified prior to |
| 4754 | the emulated VM-exit when L1 intercepts a #DB exception that occurs in |
| 4755 | L2. As a result, when KVM_GET_VCPU_EVENTS reports a pending #PF (or |
| 4756 | #DB) exception for L2, exception.has_payload will be set and the |
| 4757 | faulting address (or the new DR6 bits*) will be reported in the |
| 4758 | exception_payload field. Similarly, when userspace injects a #PF (or |
| 4759 | #DB) into L2 using KVM_SET_VCPU_EVENTS, it is expected to set |
| 4760 | exception.has_payload and to put the faulting address (or the new DR6 |
| 4761 | bits*) in the exception_payload field. |
| 4762 | |
| 4763 | This capability also enables exception.pending in struct |
| 4764 | kvm_vcpu_events, which allows userspace to distinguish between pending |
| 4765 | and injected exceptions. |
| 4766 | |
| 4767 | |
| 4768 | * For the new DR6 bits, note that bit 16 is set iff the #DB exception |
| 4769 | will clear DR6.RTM. |
| 4770 | |
Paolo Bonzini | 2a31b9d | 2018-10-23 02:36:47 +0200 | [diff] [blame] | 4771 | 7.18 KVM_CAP_MANUAL_DIRTY_LOG_PROTECT |
| 4772 | |
| 4773 | Architectures: all |
| 4774 | Parameters: args[0] whether feature should be enabled or not |
| 4775 | |
| 4776 | With this capability enabled, KVM_GET_DIRTY_LOG will not automatically |
| 4777 | clear and write-protect all pages that are returned as dirty. |
| 4778 | Rather, userspace will have to do this operation separately using |
| 4779 | KVM_CLEAR_DIRTY_LOG. |
| 4780 | |
| 4781 | At the cost of a slightly more complicated operation, this provides better |
| 4782 | scalability and responsiveness for two reasons. First, |
| 4783 | KVM_CLEAR_DIRTY_LOG ioctl can operate on a 64-page granularity rather |
| 4784 | than requiring to sync a full memslot; this ensures that KVM does not |
| 4785 | take spinlocks for an extended period of time. Second, in some cases a |
| 4786 | large amount of time can pass between a call to KVM_GET_DIRTY_LOG and |
| 4787 | userspace actually using the data in the page. Pages can be modified |
| 4788 | during this time, which is inefficint for both the guest and userspace: |
| 4789 | the guest will incur a higher penalty due to write protection faults, |
| 4790 | while userspace can see false reports of dirty pages. Manual reprotection |
| 4791 | helps reducing this time, improving guest performance and reducing the |
| 4792 | number of dirty log false positives. |
| 4793 | |
| 4794 | |
Michael Ellerman | e928e9c | 2015-03-20 20:39:41 +1100 | [diff] [blame] | 4795 | 8. Other capabilities. |
| 4796 | ---------------------- |
| 4797 | |
| 4798 | This section lists capabilities that give information about other |
| 4799 | features of the KVM implementation. |
| 4800 | |
| 4801 | 8.1 KVM_CAP_PPC_HWRNG |
| 4802 | |
| 4803 | Architectures: ppc |
| 4804 | |
| 4805 | This capability, if KVM_CHECK_EXTENSION indicates that it is |
| 4806 | available, means that that the kernel has an implementation of the |
| 4807 | H_RANDOM hypercall backed by a hardware random-number generator. |
| 4808 | If present, the kernel H_RANDOM handler can be enabled for guest use |
| 4809 | with the KVM_CAP_PPC_ENABLE_HCALL capability. |
Andrey Smetanin | 5c919412 | 2015-11-10 15:36:34 +0300 | [diff] [blame] | 4810 | |
| 4811 | 8.2 KVM_CAP_HYPERV_SYNIC |
| 4812 | |
| 4813 | Architectures: x86 |
| 4814 | This capability, if KVM_CHECK_EXTENSION indicates that it is |
| 4815 | available, means that that the kernel has an implementation of the |
| 4816 | Hyper-V Synthetic interrupt controller(SynIC). Hyper-V SynIC is |
| 4817 | used to support Windows Hyper-V based guest paravirt drivers(VMBus). |
| 4818 | |
| 4819 | In order to use SynIC, it has to be activated by setting this |
| 4820 | capability via KVM_ENABLE_CAP ioctl on the vcpu fd. Note that this |
| 4821 | will disable the use of APIC hardware virtualization even if supported |
| 4822 | by the CPU, as it's incompatible with SynIC auto-EOI behavior. |
Paul Mackerras | c927013 | 2017-01-30 21:21:41 +1100 | [diff] [blame] | 4823 | |
| 4824 | 8.3 KVM_CAP_PPC_RADIX_MMU |
| 4825 | |
| 4826 | Architectures: ppc |
| 4827 | |
| 4828 | This capability, if KVM_CHECK_EXTENSION indicates that it is |
| 4829 | available, means that that the kernel can support guests using the |
| 4830 | radix MMU defined in Power ISA V3.00 (as implemented in the POWER9 |
| 4831 | processor). |
| 4832 | |
| 4833 | 8.4 KVM_CAP_PPC_HASH_MMU_V3 |
| 4834 | |
| 4835 | Architectures: ppc |
| 4836 | |
| 4837 | This capability, if KVM_CHECK_EXTENSION indicates that it is |
| 4838 | available, means that that the kernel can support guests using the |
| 4839 | hashed page table MMU defined in Power ISA V3.00 (as implemented in |
| 4840 | the POWER9 processor), including in-memory segment tables. |
James Hogan | a8a3c42 | 2017-03-14 10:15:19 +0000 | [diff] [blame] | 4841 | |
| 4842 | 8.5 KVM_CAP_MIPS_VZ |
| 4843 | |
| 4844 | Architectures: mips |
| 4845 | |
| 4846 | This capability, if KVM_CHECK_EXTENSION on the main kvm handle indicates that |
| 4847 | it is available, means that full hardware assisted virtualization capabilities |
| 4848 | of the hardware are available for use through KVM. An appropriate |
| 4849 | KVM_VM_MIPS_* type must be passed to KVM_CREATE_VM to create a VM which |
| 4850 | utilises it. |
| 4851 | |
| 4852 | If KVM_CHECK_EXTENSION on a kvm VM handle indicates that this capability is |
| 4853 | available, it means that the VM is using full hardware assisted virtualization |
| 4854 | capabilities of the hardware. This is useful to check after creating a VM with |
| 4855 | KVM_VM_MIPS_DEFAULT. |
| 4856 | |
| 4857 | The value returned by KVM_CHECK_EXTENSION should be compared against known |
| 4858 | values (see below). All other values are reserved. This is to allow for the |
| 4859 | possibility of other hardware assisted virtualization implementations which |
| 4860 | may be incompatible with the MIPS VZ ASE. |
| 4861 | |
| 4862 | 0: The trap & emulate implementation is in use to run guest code in user |
| 4863 | mode. Guest virtual memory segments are rearranged to fit the guest in the |
| 4864 | user mode address space. |
| 4865 | |
| 4866 | 1: The MIPS VZ ASE is in use, providing full hardware assisted |
| 4867 | virtualization, including standard guest virtual memory segments. |
| 4868 | |
| 4869 | 8.6 KVM_CAP_MIPS_TE |
| 4870 | |
| 4871 | Architectures: mips |
| 4872 | |
| 4873 | This capability, if KVM_CHECK_EXTENSION on the main kvm handle indicates that |
| 4874 | it is available, means that the trap & emulate implementation is available to |
| 4875 | run guest code in user mode, even if KVM_CAP_MIPS_VZ indicates that hardware |
| 4876 | assisted virtualisation is also available. KVM_VM_MIPS_TE (0) must be passed |
| 4877 | to KVM_CREATE_VM to create a VM which utilises it. |
| 4878 | |
| 4879 | If KVM_CHECK_EXTENSION on a kvm VM handle indicates that this capability is |
| 4880 | available, it means that the VM is using trap & emulate. |
James Hogan | 578fd61 | 2017-03-14 10:15:20 +0000 | [diff] [blame] | 4881 | |
| 4882 | 8.7 KVM_CAP_MIPS_64BIT |
| 4883 | |
| 4884 | Architectures: mips |
| 4885 | |
| 4886 | This capability indicates the supported architecture type of the guest, i.e. the |
| 4887 | supported register and address width. |
| 4888 | |
| 4889 | The values returned when this capability is checked by KVM_CHECK_EXTENSION on a |
| 4890 | kvm VM handle correspond roughly to the CP0_Config.AT register field, and should |
| 4891 | be checked specifically against known values (see below). All other values are |
| 4892 | reserved. |
| 4893 | |
| 4894 | 0: MIPS32 or microMIPS32. |
| 4895 | Both registers and addresses are 32-bits wide. |
| 4896 | It will only be possible to run 32-bit guest code. |
| 4897 | |
| 4898 | 1: MIPS64 or microMIPS64 with access only to 32-bit compatibility segments. |
| 4899 | Registers are 64-bits wide, but addresses are 32-bits wide. |
| 4900 | 64-bit guest code may run but cannot access MIPS64 memory segments. |
| 4901 | It will also be possible to run 32-bit guest code. |
| 4902 | |
| 4903 | 2: MIPS64 or microMIPS64 with access to all address segments. |
| 4904 | Both registers and addresses are 64-bits wide. |
| 4905 | It will be possible to run 64-bit or 32-bit guest code. |
Michael S. Tsirkin | 668fffa | 2017-04-21 12:27:17 +0200 | [diff] [blame] | 4906 | |
Paolo Bonzini | c24a7be | 2017-04-27 17:33:14 +0200 | [diff] [blame] | 4907 | 8.9 KVM_CAP_ARM_USER_IRQ |
Alexander Graf | 3fe17e6 | 2016-09-27 21:08:05 +0200 | [diff] [blame] | 4908 | |
| 4909 | Architectures: arm, arm64 |
| 4910 | This capability, if KVM_CHECK_EXTENSION indicates that it is available, means |
| 4911 | that if userspace creates a VM without an in-kernel interrupt controller, it |
| 4912 | will be notified of changes to the output level of in-kernel emulated devices, |
| 4913 | which can generate virtual interrupts, presented to the VM. |
| 4914 | For such VMs, on every return to userspace, the kernel |
| 4915 | updates the vcpu's run->s.regs.device_irq_level field to represent the actual |
| 4916 | output level of the device. |
| 4917 | |
| 4918 | Whenever kvm detects a change in the device output level, kvm guarantees at |
| 4919 | least one return to userspace before running the VM. This exit could either |
| 4920 | be a KVM_EXIT_INTR or any other exit event, like KVM_EXIT_MMIO. This way, |
| 4921 | userspace can always sample the device output level and re-compute the state of |
| 4922 | the userspace interrupt controller. Userspace should always check the state |
| 4923 | of run->s.regs.device_irq_level on every kvm exit. |
| 4924 | The value in run->s.regs.device_irq_level can represent both level and edge |
| 4925 | triggered interrupt signals, depending on the device. Edge triggered interrupt |
| 4926 | signals will exit to userspace with the bit in run->s.regs.device_irq_level |
| 4927 | set exactly once per edge signal. |
| 4928 | |
| 4929 | The field run->s.regs.device_irq_level is available independent of |
| 4930 | run->kvm_valid_regs or run->kvm_dirty_regs bits. |
| 4931 | |
| 4932 | If KVM_CAP_ARM_USER_IRQ is supported, the KVM_CHECK_EXTENSION ioctl returns a |
| 4933 | number larger than 0 indicating the version of this capability is implemented |
| 4934 | and thereby which bits in in run->s.regs.device_irq_level can signal values. |
| 4935 | |
| 4936 | Currently the following bits are defined for the device_irq_level bitmap: |
| 4937 | |
| 4938 | KVM_CAP_ARM_USER_IRQ >= 1: |
| 4939 | |
| 4940 | KVM_ARM_DEV_EL1_VTIMER - EL1 virtual timer |
| 4941 | KVM_ARM_DEV_EL1_PTIMER - EL1 physical timer |
| 4942 | KVM_ARM_DEV_PMU - ARM PMU overflow interrupt signal |
| 4943 | |
| 4944 | Future versions of kvm may implement additional events. These will get |
| 4945 | indicated by returning a higher number from KVM_CHECK_EXTENSION and will be |
| 4946 | listed above. |
Paul Mackerras | 2ed4f9d | 2017-06-21 16:01:27 +1000 | [diff] [blame] | 4947 | |
| 4948 | 8.10 KVM_CAP_PPC_SMT_POSSIBLE |
| 4949 | |
| 4950 | Architectures: ppc |
| 4951 | |
| 4952 | Querying this capability returns a bitmap indicating the possible |
| 4953 | virtual SMT modes that can be set using KVM_CAP_PPC_SMT. If bit N |
| 4954 | (counting from the right) is set, then a virtual SMT mode of 2^N is |
| 4955 | available. |
Roman Kagan | efc479e | 2017-06-22 16:51:01 +0300 | [diff] [blame] | 4956 | |
| 4957 | 8.11 KVM_CAP_HYPERV_SYNIC2 |
| 4958 | |
| 4959 | Architectures: x86 |
| 4960 | |
| 4961 | This capability enables a newer version of Hyper-V Synthetic interrupt |
| 4962 | controller (SynIC). The only difference with KVM_CAP_HYPERV_SYNIC is that KVM |
| 4963 | doesn't clear SynIC message and event flags pages when they are enabled by |
| 4964 | writing to the respective MSRs. |
Roman Kagan | d3457c8 | 2017-07-14 17:13:20 +0300 | [diff] [blame] | 4965 | |
| 4966 | 8.12 KVM_CAP_HYPERV_VP_INDEX |
| 4967 | |
| 4968 | Architectures: x86 |
| 4969 | |
| 4970 | This capability indicates that userspace can load HV_X64_MSR_VP_INDEX msr. Its |
| 4971 | value is used to denote the target vcpu for a SynIC interrupt. For |
| 4972 | compatibilty, KVM initializes this msr to KVM's internal vcpu index. When this |
| 4973 | capability is absent, userspace can still query this msr's value. |
Christian Borntraeger | da9a144 | 2017-11-09 10:00:45 +0100 | [diff] [blame] | 4974 | |
| 4975 | 8.13 KVM_CAP_S390_AIS_MIGRATION |
| 4976 | |
| 4977 | Architectures: s390 |
| 4978 | Parameters: none |
| 4979 | |
| 4980 | This capability indicates if the flic device will be able to get/set the |
| 4981 | AIS states for migration via the KVM_DEV_FLIC_AISM_ALL attribute and allows |
| 4982 | to discover this without having to create a flic device. |
Christian Borntraeger | 5c2b4d5 | 2018-02-22 13:40:04 +0000 | [diff] [blame] | 4983 | |
| 4984 | 8.14 KVM_CAP_S390_PSW |
| 4985 | |
| 4986 | Architectures: s390 |
| 4987 | |
| 4988 | This capability indicates that the PSW is exposed via the kvm_run structure. |
| 4989 | |
| 4990 | 8.15 KVM_CAP_S390_GMAP |
| 4991 | |
| 4992 | Architectures: s390 |
| 4993 | |
| 4994 | This capability indicates that the user space memory used as guest mapping can |
| 4995 | be anywhere in the user memory address space, as long as the memory slots are |
| 4996 | aligned and sized to a segment (1MB) boundary. |
| 4997 | |
| 4998 | 8.16 KVM_CAP_S390_COW |
| 4999 | |
| 5000 | Architectures: s390 |
| 5001 | |
| 5002 | This capability indicates that the user space memory used as guest mapping can |
| 5003 | use copy-on-write semantics as well as dirty pages tracking via read-only page |
| 5004 | tables. |
| 5005 | |
| 5006 | 8.17 KVM_CAP_S390_BPB |
| 5007 | |
| 5008 | Architectures: s390 |
| 5009 | |
| 5010 | This capability indicates that kvm will implement the interfaces to handle |
| 5011 | reset, migration and nested KVM for branch prediction blocking. The stfle |
| 5012 | facility 82 should not be provided to the guest without this capability. |
Vitaly Kuznetsov | c1aea91 | 2018-05-16 17:21:31 +0200 | [diff] [blame] | 5013 | |
Vitaly Kuznetsov | 2ddc649 | 2018-06-22 16:56:14 +0200 | [diff] [blame] | 5014 | 8.18 KVM_CAP_HYPERV_TLBFLUSH |
Vitaly Kuznetsov | c1aea91 | 2018-05-16 17:21:31 +0200 | [diff] [blame] | 5015 | |
| 5016 | Architectures: x86 |
| 5017 | |
| 5018 | This capability indicates that KVM supports paravirtualized Hyper-V TLB Flush |
| 5019 | hypercalls: |
| 5020 | HvFlushVirtualAddressSpace, HvFlushVirtualAddressSpaceEx, |
| 5021 | HvFlushVirtualAddressList, HvFlushVirtualAddressListEx. |
Dongjiu Geng | be26b3a | 2018-07-19 16:24:23 +0100 | [diff] [blame] | 5022 | |
Dongjiu Geng | 688e058 | 2018-08-20 17:39:25 -0400 | [diff] [blame] | 5023 | 8.19 KVM_CAP_ARM_INJECT_SERROR_ESR |
Dongjiu Geng | be26b3a | 2018-07-19 16:24:23 +0100 | [diff] [blame] | 5024 | |
| 5025 | Architectures: arm, arm64 |
| 5026 | |
| 5027 | This capability indicates that userspace can specify (via the |
| 5028 | KVM_SET_VCPU_EVENTS ioctl) the syndrome value reported to the guest when it |
| 5029 | takes a virtual SError interrupt exception. |
| 5030 | If KVM advertises this capability, userspace can only specify the ISS field for |
| 5031 | the ESR syndrome. Other parts of the ESR, such as the EC are generated by the |
| 5032 | CPU when the exception is taken. If this virtual SError is taken to EL1 using |
| 5033 | AArch64, this value will be reported in the ISS field of ESR_ELx. |
| 5034 | |
| 5035 | See KVM_CAP_VCPU_EVENTS for more details. |
Vitaly Kuznetsov | 214ff83 | 2018-09-26 19:02:59 +0200 | [diff] [blame] | 5036 | 8.20 KVM_CAP_HYPERV_SEND_IPI |
| 5037 | |
| 5038 | Architectures: x86 |
| 5039 | |
| 5040 | This capability indicates that KVM supports paravirtualized Hyper-V IPI send |
| 5041 | hypercalls: |
| 5042 | HvCallSendSyntheticClusterIpi, HvCallSendSyntheticClusterIpiEx. |