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 | |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 48 | 3. Extensions |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 49 | ------------- |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 50 | |
| 51 | As of Linux 2.6.22, the KVM ABI has been stabilized: no backward |
| 52 | incompatible change are allowed. However, there is an extension |
| 53 | facility that allows backward-compatible extensions to the API to be |
| 54 | queried and used. |
| 55 | |
Masanari Iida | c9f3f2d | 2013-07-18 01:29:12 +0900 | [diff] [blame] | 56 | The extension mechanism is not based on the Linux version number. |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 57 | Instead, kvm defines extension identifiers and a facility to query |
| 58 | whether a particular extension identifier is available. If it is, a |
| 59 | set of ioctls is available for application use. |
| 60 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 61 | |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 62 | 4. API description |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 63 | ------------------ |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 64 | |
| 65 | This section describes ioctls that can be used to control kvm guests. |
| 66 | For each ioctl, the following information is provided along with a |
| 67 | description: |
| 68 | |
| 69 | Capability: which KVM extension provides this ioctl. Can be 'basic', |
| 70 | which means that is will be provided by any kernel that supports |
| 71 | API version 12 (see section 4.1), or a KVM_CAP_xyz constant, which |
| 72 | means availability needs to be checked with KVM_CHECK_EXTENSION |
| 73 | (see section 4.4). |
| 74 | |
| 75 | Architectures: which instruction set architectures provide this ioctl. |
| 76 | x86 includes both i386 and x86_64. |
| 77 | |
| 78 | Type: system, vm, or vcpu. |
| 79 | |
| 80 | Parameters: what parameters are accepted by the ioctl. |
| 81 | |
| 82 | Returns: the return value. General error numbers (EBADF, ENOMEM, EINVAL) |
| 83 | are not detailed, but errors with specific meanings are. |
| 84 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 85 | |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 86 | 4.1 KVM_GET_API_VERSION |
| 87 | |
| 88 | Capability: basic |
| 89 | Architectures: all |
| 90 | Type: system ioctl |
| 91 | Parameters: none |
| 92 | Returns: the constant KVM_API_VERSION (=12) |
| 93 | |
| 94 | This identifies the API version as the stable kvm API. It is not |
| 95 | expected that this number will change. However, Linux 2.6.20 and |
| 96 | 2.6.21 report earlier versions; these are not documented and not |
| 97 | supported. Applications should refuse to run if KVM_GET_API_VERSION |
| 98 | returns a value other than 12. If this check passes, all ioctls |
| 99 | described as 'basic' will be available. |
| 100 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 101 | |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 102 | 4.2 KVM_CREATE_VM |
| 103 | |
| 104 | Capability: basic |
| 105 | Architectures: all |
| 106 | Type: system ioctl |
Carsten Otte | e08b963 | 2012-01-04 10:25:20 +0100 | [diff] [blame] | 107 | Parameters: machine type identifier (KVM_VM_*) |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 108 | Returns: a VM fd that can be used to control the new virtual machine. |
| 109 | |
| 110 | The new VM has no virtual cpus and no memory. An mmap() of a VM fd |
| 111 | will access the virtual machine's physical address space; offset zero |
| 112 | corresponds to guest physical address zero. Use of mmap() on a VM fd |
| 113 | is discouraged if userspace memory allocation (KVM_CAP_USER_MEMORY) is |
| 114 | available. |
Carsten Otte | e08b963 | 2012-01-04 10:25:20 +0100 | [diff] [blame] | 115 | You most certainly want to use 0 as machine type. |
| 116 | |
| 117 | In order to create user controlled virtual machines on S390, check |
| 118 | KVM_CAP_S390_UCONTROL and use the flag KVM_VM_S390_UCONTROL as |
| 119 | privileged user (CAP_SYS_ADMIN). |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 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.3 KVM_GET_MSR_INDEX_LIST |
| 123 | |
| 124 | Capability: basic |
| 125 | Architectures: x86 |
| 126 | Type: system |
| 127 | Parameters: struct kvm_msr_list (in/out) |
| 128 | Returns: 0 on success; -1 on error |
| 129 | Errors: |
| 130 | E2BIG: the msr index list is to be to fit in the array specified by |
| 131 | the user. |
| 132 | |
| 133 | struct kvm_msr_list { |
| 134 | __u32 nmsrs; /* number of msrs in entries */ |
| 135 | __u32 indices[0]; |
| 136 | }; |
| 137 | |
| 138 | This ioctl returns the guest msrs that are supported. The list varies |
| 139 | by kvm version and host processor, but does not change otherwise. The |
| 140 | user fills in the size of the indices array in nmsrs, and in return |
| 141 | kvm adjusts nmsrs to reflect the actual number of msrs and fills in |
| 142 | the indices array with their numbers. |
| 143 | |
Avi Kivity | 2e2602c | 2010-07-07 14:09:39 +0300 | [diff] [blame] | 144 | Note: if kvm indicates supports MCE (KVM_CAP_MCE), then the MCE bank MSRs are |
| 145 | not returned in the MSR list, as different vcpus can have a different number |
| 146 | of banks, as set via the KVM_X86_SETUP_MCE ioctl. |
| 147 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 148 | |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 149 | 4.4 KVM_CHECK_EXTENSION |
| 150 | |
Alexander Graf | 92b591a | 2014-07-14 18:33:08 +0200 | [diff] [blame] | 151 | Capability: basic, KVM_CAP_CHECK_EXTENSION_VM for vm ioctl |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 152 | Architectures: all |
Alexander Graf | 92b591a | 2014-07-14 18:33:08 +0200 | [diff] [blame] | 153 | Type: system ioctl, vm ioctl |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 154 | Parameters: extension identifier (KVM_CAP_*) |
| 155 | Returns: 0 if unsupported; 1 (or some other positive integer) if supported |
| 156 | |
| 157 | The API allows the application to query about extensions to the core |
| 158 | kvm API. Userspace passes an extension identifier (an integer) and |
| 159 | receives an integer that describes the extension availability. |
| 160 | Generally 0 means no and 1 means yes, but some extensions may report |
| 161 | additional information in the integer return value. |
| 162 | |
Alexander Graf | 92b591a | 2014-07-14 18:33:08 +0200 | [diff] [blame] | 163 | Based on their initialization different VMs may have different capabilities. |
| 164 | It is thus encouraged to use the vm ioctl to query for capabilities (available |
| 165 | with KVM_CAP_CHECK_EXTENSION_VM on the vm fd) |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 166 | |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 167 | 4.5 KVM_GET_VCPU_MMAP_SIZE |
| 168 | |
| 169 | Capability: basic |
| 170 | Architectures: all |
| 171 | Type: system ioctl |
| 172 | Parameters: none |
| 173 | Returns: size of vcpu mmap area, in bytes |
| 174 | |
| 175 | The KVM_RUN ioctl (cf.) communicates with userspace via a shared |
| 176 | memory region. This ioctl returns the size of that region. See the |
| 177 | KVM_RUN documentation for details. |
| 178 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 179 | |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 180 | 4.6 KVM_SET_MEMORY_REGION |
| 181 | |
| 182 | Capability: basic |
| 183 | Architectures: all |
| 184 | Type: vm ioctl |
| 185 | Parameters: struct kvm_memory_region (in) |
| 186 | Returns: 0 on success, -1 on error |
| 187 | |
Avi Kivity | b74a07b | 2010-06-21 11:48:05 +0300 | [diff] [blame] | 188 | This ioctl is obsolete and has been removed. |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 189 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 190 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 191 | 4.7 KVM_CREATE_VCPU |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 192 | |
| 193 | Capability: basic |
| 194 | Architectures: all |
| 195 | Type: vm ioctl |
| 196 | Parameters: vcpu id (apic id on x86) |
| 197 | Returns: vcpu fd on success, -1 on error |
| 198 | |
| 199 | This API adds a vcpu to a virtual machine. The vcpu id is a small integer |
Sasha Levin | 8c3ba33 | 2011-07-18 17:17:15 +0300 | [diff] [blame] | 200 | in the range [0, max_vcpus). |
| 201 | |
| 202 | The recommended max_vcpus value can be retrieved using the KVM_CAP_NR_VCPUS of |
| 203 | the KVM_CHECK_EXTENSION ioctl() at run-time. |
| 204 | The maximum possible value for max_vcpus can be retrieved using the |
| 205 | KVM_CAP_MAX_VCPUS of the KVM_CHECK_EXTENSION ioctl() at run-time. |
| 206 | |
Pekka Enberg | 76d2540 | 2011-05-09 22:48:54 +0300 | [diff] [blame] | 207 | If the KVM_CAP_NR_VCPUS does not exist, you should assume that max_vcpus is 4 |
| 208 | cpus max. |
Sasha Levin | 8c3ba33 | 2011-07-18 17:17:15 +0300 | [diff] [blame] | 209 | If the KVM_CAP_MAX_VCPUS does not exist, you should assume that max_vcpus is |
| 210 | same as the value returned from KVM_CAP_NR_VCPUS. |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 211 | |
Paul Mackerras | 371fefd | 2011-06-29 00:23:08 +0000 | [diff] [blame] | 212 | On powerpc using book3s_hv mode, the vcpus are mapped onto virtual |
| 213 | threads in one or more virtual CPU cores. (This is because the |
| 214 | hardware requires all the hardware threads in a CPU core to be in the |
| 215 | same partition.) The KVM_CAP_PPC_SMT capability indicates the number |
| 216 | of vcpus per virtual core (vcore). The vcore id is obtained by |
| 217 | dividing the vcpu id by the number of vcpus per vcore. The vcpus in a |
| 218 | given vcore will always be in the same physical core as each other |
| 219 | (though that might be a different physical core from time to time). |
| 220 | Userspace can control the threading (SMT) mode of the guest by its |
| 221 | allocation of vcpu ids. For example, if userspace wants |
| 222 | single-threaded guest vcpus, it should make all vcpu ids be a multiple |
| 223 | of the number of vcpus per vcore. |
| 224 | |
Carsten Otte | 5b1c149 | 2012-01-04 10:25:23 +0100 | [diff] [blame] | 225 | For virtual cpus that have been created with S390 user controlled virtual |
| 226 | machines, the resulting vcpu fd can be memory mapped at page offset |
| 227 | KVM_S390_SIE_PAGE_OFFSET in order to obtain a memory map of the virtual |
| 228 | cpu's hardware control block. |
| 229 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 230 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 231 | 4.8 KVM_GET_DIRTY_LOG (vm ioctl) |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 232 | |
| 233 | Capability: basic |
| 234 | Architectures: x86 |
| 235 | Type: vm ioctl |
| 236 | Parameters: struct kvm_dirty_log (in/out) |
| 237 | Returns: 0 on success, -1 on error |
| 238 | |
| 239 | /* for KVM_GET_DIRTY_LOG */ |
| 240 | struct kvm_dirty_log { |
| 241 | __u32 slot; |
| 242 | __u32 padding; |
| 243 | union { |
| 244 | void __user *dirty_bitmap; /* one bit per page */ |
| 245 | __u64 padding; |
| 246 | }; |
| 247 | }; |
| 248 | |
| 249 | Given a memory slot, return a bitmap containing any pages dirtied |
| 250 | since the last call to this ioctl. Bit 0 is the first page in the |
| 251 | memory slot. Ensure the entire structure is cleared to avoid padding |
| 252 | issues. |
| 253 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 254 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 255 | 4.9 KVM_SET_MEMORY_ALIAS |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 256 | |
| 257 | Capability: basic |
| 258 | Architectures: x86 |
| 259 | Type: vm ioctl |
| 260 | Parameters: struct kvm_memory_alias (in) |
| 261 | Returns: 0 (success), -1 (error) |
| 262 | |
Avi Kivity | a1f4d395 | 2010-06-21 11:44:20 +0300 | [diff] [blame] | 263 | This ioctl is obsolete and has been removed. |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 264 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 265 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 266 | 4.10 KVM_RUN |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 267 | |
| 268 | Capability: basic |
| 269 | Architectures: all |
| 270 | Type: vcpu ioctl |
| 271 | Parameters: none |
| 272 | Returns: 0 on success, -1 on error |
| 273 | Errors: |
| 274 | EINTR: an unmasked signal is pending |
| 275 | |
| 276 | This ioctl is used to run a guest virtual cpu. While there are no |
| 277 | explicit parameters, there is an implicit parameter block that can be |
| 278 | obtained by mmap()ing the vcpu fd at offset 0, with the size given by |
| 279 | KVM_GET_VCPU_MMAP_SIZE. The parameter block is formatted as a 'struct |
| 280 | kvm_run' (see below). |
| 281 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 282 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 283 | 4.11 KVM_GET_REGS |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 284 | |
| 285 | Capability: basic |
Marc Zyngier | 379e04c7 | 2013-04-02 17:46:31 +0100 | [diff] [blame] | 286 | Architectures: all except ARM, arm64 |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 287 | Type: vcpu ioctl |
| 288 | Parameters: struct kvm_regs (out) |
| 289 | Returns: 0 on success, -1 on error |
| 290 | |
| 291 | Reads the general purpose registers from the vcpu. |
| 292 | |
| 293 | /* x86 */ |
| 294 | struct kvm_regs { |
| 295 | /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */ |
| 296 | __u64 rax, rbx, rcx, rdx; |
| 297 | __u64 rsi, rdi, rsp, rbp; |
| 298 | __u64 r8, r9, r10, r11; |
| 299 | __u64 r12, r13, r14, r15; |
| 300 | __u64 rip, rflags; |
| 301 | }; |
| 302 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 303 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 304 | 4.12 KVM_SET_REGS |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 305 | |
| 306 | Capability: basic |
Marc Zyngier | 379e04c7 | 2013-04-02 17:46:31 +0100 | [diff] [blame] | 307 | Architectures: all except ARM, arm64 |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 308 | Type: vcpu ioctl |
| 309 | Parameters: struct kvm_regs (in) |
| 310 | Returns: 0 on success, -1 on error |
| 311 | |
| 312 | Writes the general purpose registers into the vcpu. |
| 313 | |
| 314 | See KVM_GET_REGS for the data structure. |
| 315 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 316 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 317 | 4.13 KVM_GET_SREGS |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 318 | |
| 319 | Capability: basic |
Scott Wood | 5ce941e | 2011-04-27 17:24:21 -0500 | [diff] [blame] | 320 | Architectures: x86, ppc |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 321 | Type: vcpu ioctl |
| 322 | Parameters: struct kvm_sregs (out) |
| 323 | Returns: 0 on success, -1 on error |
| 324 | |
| 325 | Reads special registers from the vcpu. |
| 326 | |
| 327 | /* x86 */ |
| 328 | struct kvm_sregs { |
| 329 | struct kvm_segment cs, ds, es, fs, gs, ss; |
| 330 | struct kvm_segment tr, ldt; |
| 331 | struct kvm_dtable gdt, idt; |
| 332 | __u64 cr0, cr2, cr3, cr4, cr8; |
| 333 | __u64 efer; |
| 334 | __u64 apic_base; |
| 335 | __u64 interrupt_bitmap[(KVM_NR_INTERRUPTS + 63) / 64]; |
| 336 | }; |
| 337 | |
Mihai Caraman | 68e2ffe | 2012-12-11 03:38:23 +0000 | [diff] [blame] | 338 | /* ppc -- see arch/powerpc/include/uapi/asm/kvm.h */ |
Scott Wood | 5ce941e | 2011-04-27 17:24:21 -0500 | [diff] [blame] | 339 | |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 340 | interrupt_bitmap is a bitmap of pending external interrupts. At most |
| 341 | one bit may be set. This interrupt has been acknowledged by the APIC |
| 342 | but not yet injected into the cpu core. |
| 343 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 344 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 345 | 4.14 KVM_SET_SREGS |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 346 | |
| 347 | Capability: basic |
Scott Wood | 5ce941e | 2011-04-27 17:24:21 -0500 | [diff] [blame] | 348 | Architectures: x86, ppc |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 349 | Type: vcpu ioctl |
| 350 | Parameters: struct kvm_sregs (in) |
| 351 | Returns: 0 on success, -1 on error |
| 352 | |
| 353 | Writes special registers into the vcpu. See KVM_GET_SREGS for the |
| 354 | data structures. |
| 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.15 KVM_TRANSLATE |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 358 | |
| 359 | Capability: basic |
| 360 | Architectures: x86 |
| 361 | Type: vcpu ioctl |
| 362 | Parameters: struct kvm_translation (in/out) |
| 363 | Returns: 0 on success, -1 on error |
| 364 | |
| 365 | Translates a virtual address according to the vcpu's current address |
| 366 | translation mode. |
| 367 | |
| 368 | struct kvm_translation { |
| 369 | /* in */ |
| 370 | __u64 linear_address; |
| 371 | |
| 372 | /* out */ |
| 373 | __u64 physical_address; |
| 374 | __u8 valid; |
| 375 | __u8 writeable; |
| 376 | __u8 usermode; |
| 377 | __u8 pad[5]; |
| 378 | }; |
| 379 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 380 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 381 | 4.16 KVM_INTERRUPT |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 382 | |
| 383 | Capability: basic |
Alexander Graf | 6f7a2bd | 2010-08-31 02:03:32 +0200 | [diff] [blame] | 384 | Architectures: x86, ppc |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 385 | Type: vcpu ioctl |
| 386 | Parameters: struct kvm_interrupt (in) |
| 387 | Returns: 0 on success, -1 on error |
| 388 | |
| 389 | Queues a hardware interrupt vector to be injected. This is only |
Alexander Graf | 6f7a2bd | 2010-08-31 02:03:32 +0200 | [diff] [blame] | 390 | useful if in-kernel local APIC or equivalent is not used. |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 391 | |
| 392 | /* for KVM_INTERRUPT */ |
| 393 | struct kvm_interrupt { |
| 394 | /* in */ |
| 395 | __u32 irq; |
| 396 | }; |
| 397 | |
Alexander Graf | 6f7a2bd | 2010-08-31 02:03:32 +0200 | [diff] [blame] | 398 | X86: |
| 399 | |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 400 | Note 'irq' is an interrupt vector, not an interrupt pin or line. |
| 401 | |
Alexander Graf | 6f7a2bd | 2010-08-31 02:03:32 +0200 | [diff] [blame] | 402 | PPC: |
| 403 | |
| 404 | Queues an external interrupt to be injected. This ioctl is overleaded |
| 405 | with 3 different irq values: |
| 406 | |
| 407 | a) KVM_INTERRUPT_SET |
| 408 | |
| 409 | This injects an edge type external interrupt into the guest once it's ready |
| 410 | to receive interrupts. When injected, the interrupt is done. |
| 411 | |
| 412 | b) KVM_INTERRUPT_UNSET |
| 413 | |
| 414 | This unsets any pending interrupt. |
| 415 | |
| 416 | Only available with KVM_CAP_PPC_UNSET_IRQ. |
| 417 | |
| 418 | c) KVM_INTERRUPT_SET_LEVEL |
| 419 | |
| 420 | This injects a level type external interrupt into the guest context. The |
| 421 | interrupt stays pending until a specific ioctl with KVM_INTERRUPT_UNSET |
| 422 | is triggered. |
| 423 | |
| 424 | Only available with KVM_CAP_PPC_IRQ_LEVEL. |
| 425 | |
| 426 | Note that any value for 'irq' other than the ones stated above is invalid |
| 427 | and incurs unexpected behavior. |
| 428 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 429 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 430 | 4.17 KVM_DEBUG_GUEST |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 431 | |
| 432 | Capability: basic |
| 433 | Architectures: none |
| 434 | Type: vcpu ioctl |
| 435 | Parameters: none) |
| 436 | Returns: -1 on error |
| 437 | |
| 438 | Support for this has been removed. Use KVM_SET_GUEST_DEBUG instead. |
| 439 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 440 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 441 | 4.18 KVM_GET_MSRS |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 442 | |
| 443 | Capability: basic |
| 444 | Architectures: x86 |
| 445 | Type: vcpu ioctl |
| 446 | Parameters: struct kvm_msrs (in/out) |
| 447 | Returns: 0 on success, -1 on error |
| 448 | |
| 449 | Reads model-specific registers from the vcpu. Supported msr indices can |
| 450 | be obtained using KVM_GET_MSR_INDEX_LIST. |
| 451 | |
| 452 | struct kvm_msrs { |
| 453 | __u32 nmsrs; /* number of msrs in entries */ |
| 454 | __u32 pad; |
| 455 | |
| 456 | struct kvm_msr_entry entries[0]; |
| 457 | }; |
| 458 | |
| 459 | struct kvm_msr_entry { |
| 460 | __u32 index; |
| 461 | __u32 reserved; |
| 462 | __u64 data; |
| 463 | }; |
| 464 | |
| 465 | Application code should set the 'nmsrs' member (which indicates the |
| 466 | size of the entries array) and the 'index' member of each array entry. |
| 467 | kvm will fill in the 'data' member. |
| 468 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 469 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 470 | 4.19 KVM_SET_MSRS |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 471 | |
| 472 | Capability: basic |
| 473 | Architectures: x86 |
| 474 | Type: vcpu ioctl |
| 475 | Parameters: struct kvm_msrs (in) |
| 476 | Returns: 0 on success, -1 on error |
| 477 | |
| 478 | Writes model-specific registers to the vcpu. See KVM_GET_MSRS for the |
| 479 | data structures. |
| 480 | |
| 481 | Application code should set the 'nmsrs' member (which indicates the |
| 482 | size of the entries array), and the 'index' and 'data' members of each |
| 483 | array entry. |
| 484 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 485 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 486 | 4.20 KVM_SET_CPUID |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 487 | |
| 488 | Capability: basic |
| 489 | Architectures: x86 |
| 490 | Type: vcpu ioctl |
| 491 | Parameters: struct kvm_cpuid (in) |
| 492 | Returns: 0 on success, -1 on error |
| 493 | |
| 494 | Defines the vcpu responses to the cpuid instruction. Applications |
| 495 | should use the KVM_SET_CPUID2 ioctl if available. |
| 496 | |
| 497 | |
| 498 | struct kvm_cpuid_entry { |
| 499 | __u32 function; |
| 500 | __u32 eax; |
| 501 | __u32 ebx; |
| 502 | __u32 ecx; |
| 503 | __u32 edx; |
| 504 | __u32 padding; |
| 505 | }; |
| 506 | |
| 507 | /* for KVM_SET_CPUID */ |
| 508 | struct kvm_cpuid { |
| 509 | __u32 nent; |
| 510 | __u32 padding; |
| 511 | struct kvm_cpuid_entry entries[0]; |
| 512 | }; |
| 513 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 514 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 515 | 4.21 KVM_SET_SIGNAL_MASK |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 516 | |
| 517 | Capability: basic |
| 518 | Architectures: x86 |
| 519 | Type: vcpu ioctl |
| 520 | Parameters: struct kvm_signal_mask (in) |
| 521 | Returns: 0 on success, -1 on error |
| 522 | |
| 523 | Defines which signals are blocked during execution of KVM_RUN. This |
| 524 | signal mask temporarily overrides the threads signal mask. Any |
| 525 | unblocked signal received (except SIGKILL and SIGSTOP, which retain |
| 526 | their traditional behaviour) will cause KVM_RUN to return with -EINTR. |
| 527 | |
| 528 | Note the signal will only be delivered if not blocked by the original |
| 529 | signal mask. |
| 530 | |
| 531 | /* for KVM_SET_SIGNAL_MASK */ |
| 532 | struct kvm_signal_mask { |
| 533 | __u32 len; |
| 534 | __u8 sigset[0]; |
| 535 | }; |
| 536 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 537 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 538 | 4.22 KVM_GET_FPU |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 539 | |
| 540 | Capability: basic |
| 541 | Architectures: x86 |
| 542 | Type: vcpu ioctl |
| 543 | Parameters: struct kvm_fpu (out) |
| 544 | Returns: 0 on success, -1 on error |
| 545 | |
| 546 | Reads the floating point state from the vcpu. |
| 547 | |
| 548 | /* for KVM_GET_FPU and KVM_SET_FPU */ |
| 549 | struct kvm_fpu { |
| 550 | __u8 fpr[8][16]; |
| 551 | __u16 fcw; |
| 552 | __u16 fsw; |
| 553 | __u8 ftwx; /* in fxsave format */ |
| 554 | __u8 pad1; |
| 555 | __u16 last_opcode; |
| 556 | __u64 last_ip; |
| 557 | __u64 last_dp; |
| 558 | __u8 xmm[16][16]; |
| 559 | __u32 mxcsr; |
| 560 | __u32 pad2; |
| 561 | }; |
| 562 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 563 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 564 | 4.23 KVM_SET_FPU |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 565 | |
| 566 | Capability: basic |
| 567 | Architectures: x86 |
| 568 | Type: vcpu ioctl |
| 569 | Parameters: struct kvm_fpu (in) |
| 570 | Returns: 0 on success, -1 on error |
| 571 | |
| 572 | Writes the floating point state to the vcpu. |
| 573 | |
| 574 | /* for KVM_GET_FPU and KVM_SET_FPU */ |
| 575 | struct kvm_fpu { |
| 576 | __u8 fpr[8][16]; |
| 577 | __u16 fcw; |
| 578 | __u16 fsw; |
| 579 | __u8 ftwx; /* in fxsave format */ |
| 580 | __u8 pad1; |
| 581 | __u16 last_opcode; |
| 582 | __u64 last_ip; |
| 583 | __u64 last_dp; |
| 584 | __u8 xmm[16][16]; |
| 585 | __u32 mxcsr; |
| 586 | __u32 pad2; |
| 587 | }; |
| 588 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 589 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 590 | 4.24 KVM_CREATE_IRQCHIP |
Avi Kivity | 5dadbfd | 2009-08-23 17:08:04 +0300 | [diff] [blame] | 591 | |
Cornelia Huck | 8422359 | 2013-07-15 13:36:01 +0200 | [diff] [blame] | 592 | Capability: KVM_CAP_IRQCHIP, KVM_CAP_S390_IRQCHIP (s390) |
| 593 | Architectures: x86, ia64, ARM, arm64, s390 |
Avi Kivity | 5dadbfd | 2009-08-23 17:08:04 +0300 | [diff] [blame] | 594 | Type: vm ioctl |
| 595 | Parameters: none |
| 596 | Returns: 0 on success, -1 on error |
| 597 | |
| 598 | Creates an interrupt controller model in the kernel. On x86, creates a virtual |
| 599 | ioapic, a virtual PIC (two PICs, nested), and sets up future vcpus to have a |
| 600 | local APIC. IRQ routing for GSIs 0-15 is set to both PIC and IOAPIC; GSI 16-23 |
Marc Zyngier | 379e04c7 | 2013-04-02 17:46:31 +0100 | [diff] [blame] | 601 | only go to the IOAPIC. On ia64, a IOSAPIC is created. On ARM/arm64, a GIC is |
Cornelia Huck | 8422359 | 2013-07-15 13:36:01 +0200 | [diff] [blame] | 602 | created. On s390, a dummy irq routing table is created. |
| 603 | |
| 604 | Note that on s390 the KVM_CAP_S390_IRQCHIP vm capability needs to be enabled |
| 605 | before KVM_CREATE_IRQCHIP can be used. |
Avi Kivity | 5dadbfd | 2009-08-23 17:08:04 +0300 | [diff] [blame] | 606 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 607 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 608 | 4.25 KVM_IRQ_LINE |
Avi Kivity | 5dadbfd | 2009-08-23 17:08:04 +0300 | [diff] [blame] | 609 | |
| 610 | Capability: KVM_CAP_IRQCHIP |
Marc Zyngier | 379e04c7 | 2013-04-02 17:46:31 +0100 | [diff] [blame] | 611 | Architectures: x86, ia64, arm, arm64 |
Avi Kivity | 5dadbfd | 2009-08-23 17:08:04 +0300 | [diff] [blame] | 612 | Type: vm ioctl |
| 613 | Parameters: struct kvm_irq_level |
| 614 | Returns: 0 on success, -1 on error |
| 615 | |
| 616 | 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] | 617 | On some architectures it is required that an interrupt controller model has |
| 618 | been previously created with KVM_CREATE_IRQCHIP. Note that edge-triggered |
| 619 | interrupts require the level to be set to 1 and then back to 0. |
| 620 | |
Gabriel L. Somlo | 100943c | 2014-02-27 23:06:17 -0500 | [diff] [blame] | 621 | On real hardware, interrupt pins can be active-low or active-high. This |
| 622 | does not matter for the level field of struct kvm_irq_level: 1 always |
| 623 | means active (asserted), 0 means inactive (deasserted). |
| 624 | |
| 625 | x86 allows the operating system to program the interrupt polarity |
| 626 | (active-low/active-high) for level-triggered interrupts, and KVM used |
| 627 | to consider the polarity. However, due to bitrot in the handling of |
| 628 | active-low interrupts, the above convention is now valid on x86 too. |
| 629 | This is signaled by KVM_CAP_X86_IOAPIC_POLARITY_IGNORED. Userspace |
| 630 | should not present interrupts to the guest as active-low unless this |
| 631 | capability is present (or unless it is not using the in-kernel irqchip, |
| 632 | of course). |
| 633 | |
| 634 | |
Marc Zyngier | 379e04c7 | 2013-04-02 17:46:31 +0100 | [diff] [blame] | 635 | ARM/arm64 can signal an interrupt either at the CPU level, or at the |
| 636 | in-kernel irqchip (GIC), and for in-kernel irqchip can tell the GIC to |
| 637 | use PPIs designated for specific cpus. The irq field is interpreted |
| 638 | like this: |
Christoffer Dall | 86ce853 | 2013-01-20 18:28:08 -0500 | [diff] [blame] | 639 | |
| 640 | Â bits: | 31 ... 24 | 23 ... 16 | 15 ... 0 | |
| 641 | field: | irq_type | vcpu_index | irq_id | |
| 642 | |
| 643 | The irq_type field has the following values: |
| 644 | - irq_type[0]: out-of-kernel GIC: irq_id 0 is IRQ, irq_id 1 is FIQ |
| 645 | - irq_type[1]: in-kernel GIC: SPI, irq_id between 32 and 1019 (incl.) |
| 646 | (the vcpu_index field is ignored) |
| 647 | - irq_type[2]: in-kernel GIC: PPI, irq_id between 16 and 31 (incl.) |
| 648 | |
| 649 | (The irq_id field thus corresponds nicely to the IRQ ID in the ARM GIC specs) |
| 650 | |
Gabriel L. Somlo | 100943c | 2014-02-27 23:06:17 -0500 | [diff] [blame] | 651 | In both cases, level is used to assert/deassert the line. |
Avi Kivity | 5dadbfd | 2009-08-23 17:08:04 +0300 | [diff] [blame] | 652 | |
| 653 | struct kvm_irq_level { |
| 654 | union { |
| 655 | __u32 irq; /* GSI */ |
| 656 | __s32 status; /* not used for KVM_IRQ_LEVEL */ |
| 657 | }; |
| 658 | __u32 level; /* 0 or 1 */ |
| 659 | }; |
| 660 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 661 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 662 | 4.26 KVM_GET_IRQCHIP |
Avi Kivity | 5dadbfd | 2009-08-23 17:08:04 +0300 | [diff] [blame] | 663 | |
| 664 | Capability: KVM_CAP_IRQCHIP |
| 665 | Architectures: x86, ia64 |
| 666 | Type: vm ioctl |
| 667 | Parameters: struct kvm_irqchip (in/out) |
| 668 | Returns: 0 on success, -1 on error |
| 669 | |
| 670 | Reads the state of a kernel interrupt controller created with |
| 671 | KVM_CREATE_IRQCHIP into a buffer provided by the caller. |
| 672 | |
| 673 | struct kvm_irqchip { |
| 674 | __u32 chip_id; /* 0 = PIC1, 1 = PIC2, 2 = IOAPIC */ |
| 675 | __u32 pad; |
| 676 | union { |
| 677 | char dummy[512]; /* reserving space */ |
| 678 | struct kvm_pic_state pic; |
| 679 | struct kvm_ioapic_state ioapic; |
| 680 | } chip; |
| 681 | }; |
| 682 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 683 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 684 | 4.27 KVM_SET_IRQCHIP |
Avi Kivity | 5dadbfd | 2009-08-23 17:08:04 +0300 | [diff] [blame] | 685 | |
| 686 | Capability: KVM_CAP_IRQCHIP |
| 687 | Architectures: x86, ia64 |
| 688 | Type: vm ioctl |
| 689 | Parameters: struct kvm_irqchip (in) |
| 690 | Returns: 0 on success, -1 on error |
| 691 | |
| 692 | Sets the state of a kernel interrupt controller created with |
| 693 | KVM_CREATE_IRQCHIP from a buffer provided by the caller. |
| 694 | |
| 695 | struct kvm_irqchip { |
| 696 | __u32 chip_id; /* 0 = PIC1, 1 = PIC2, 2 = IOAPIC */ |
| 697 | __u32 pad; |
| 698 | union { |
| 699 | char dummy[512]; /* reserving space */ |
| 700 | struct kvm_pic_state pic; |
| 701 | struct kvm_ioapic_state ioapic; |
| 702 | } chip; |
| 703 | }; |
| 704 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 705 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 706 | 4.28 KVM_XEN_HVM_CONFIG |
Ed Swierk | ffde22a | 2009-10-15 15:21:43 -0700 | [diff] [blame] | 707 | |
| 708 | Capability: KVM_CAP_XEN_HVM |
| 709 | Architectures: x86 |
| 710 | Type: vm ioctl |
| 711 | Parameters: struct kvm_xen_hvm_config (in) |
| 712 | Returns: 0 on success, -1 on error |
| 713 | |
| 714 | Sets the MSR that the Xen HVM guest uses to initialize its hypercall |
| 715 | page, and provides the starting address and size of the hypercall |
| 716 | blobs in userspace. When the guest writes the MSR, kvm copies one |
| 717 | page of a blob (32- or 64-bit, depending on the vcpu mode) to guest |
| 718 | memory. |
| 719 | |
| 720 | struct kvm_xen_hvm_config { |
| 721 | __u32 flags; |
| 722 | __u32 msr; |
| 723 | __u64 blob_addr_32; |
| 724 | __u64 blob_addr_64; |
| 725 | __u8 blob_size_32; |
| 726 | __u8 blob_size_64; |
| 727 | __u8 pad2[30]; |
| 728 | }; |
| 729 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 730 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 731 | 4.29 KVM_GET_CLOCK |
Glauber Costa | afbcf7a | 2009-10-16 15:28:36 -0400 | [diff] [blame] | 732 | |
| 733 | Capability: KVM_CAP_ADJUST_CLOCK |
| 734 | Architectures: x86 |
| 735 | Type: vm ioctl |
| 736 | Parameters: struct kvm_clock_data (out) |
| 737 | Returns: 0 on success, -1 on error |
| 738 | |
| 739 | Gets the current timestamp of kvmclock as seen by the current guest. In |
| 740 | conjunction with KVM_SET_CLOCK, it is used to ensure monotonicity on scenarios |
| 741 | such as migration. |
| 742 | |
| 743 | struct kvm_clock_data { |
| 744 | __u64 clock; /* kvmclock current value */ |
| 745 | __u32 flags; |
| 746 | __u32 pad[9]; |
| 747 | }; |
| 748 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 749 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 750 | 4.30 KVM_SET_CLOCK |
Glauber Costa | afbcf7a | 2009-10-16 15:28:36 -0400 | [diff] [blame] | 751 | |
| 752 | Capability: KVM_CAP_ADJUST_CLOCK |
| 753 | Architectures: x86 |
| 754 | Type: vm ioctl |
| 755 | Parameters: struct kvm_clock_data (in) |
| 756 | Returns: 0 on success, -1 on error |
| 757 | |
Wu Fengguang | 2044892d | 2009-12-24 09:04:16 +0800 | [diff] [blame] | 758 | 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] | 759 | In conjunction with KVM_GET_CLOCK, it is used to ensure monotonicity on scenarios |
| 760 | such as migration. |
| 761 | |
| 762 | struct kvm_clock_data { |
| 763 | __u64 clock; /* kvmclock current value */ |
| 764 | __u32 flags; |
| 765 | __u32 pad[9]; |
| 766 | }; |
| 767 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 768 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 769 | 4.31 KVM_GET_VCPU_EVENTS |
Jan Kiszka | 3cfc309 | 2009-11-12 01:04:25 +0100 | [diff] [blame] | 770 | |
| 771 | Capability: KVM_CAP_VCPU_EVENTS |
Jan Kiszka | 48005f6 | 2010-02-19 19:38:07 +0100 | [diff] [blame] | 772 | Extended by: KVM_CAP_INTR_SHADOW |
Jan Kiszka | 3cfc309 | 2009-11-12 01:04:25 +0100 | [diff] [blame] | 773 | Architectures: x86 |
| 774 | Type: vm ioctl |
| 775 | Parameters: struct kvm_vcpu_event (out) |
| 776 | Returns: 0 on success, -1 on error |
| 777 | |
| 778 | Gets currently pending exceptions, interrupts, and NMIs as well as related |
| 779 | states of the vcpu. |
| 780 | |
| 781 | struct kvm_vcpu_events { |
| 782 | struct { |
| 783 | __u8 injected; |
| 784 | __u8 nr; |
| 785 | __u8 has_error_code; |
| 786 | __u8 pad; |
| 787 | __u32 error_code; |
| 788 | } exception; |
| 789 | struct { |
| 790 | __u8 injected; |
| 791 | __u8 nr; |
| 792 | __u8 soft; |
Jan Kiszka | 48005f6 | 2010-02-19 19:38:07 +0100 | [diff] [blame] | 793 | __u8 shadow; |
Jan Kiszka | 3cfc309 | 2009-11-12 01:04:25 +0100 | [diff] [blame] | 794 | } interrupt; |
| 795 | struct { |
| 796 | __u8 injected; |
| 797 | __u8 pending; |
| 798 | __u8 masked; |
| 799 | __u8 pad; |
| 800 | } nmi; |
| 801 | __u32 sipi_vector; |
Jan Kiszka | dab4b91 | 2009-12-06 18:24:15 +0100 | [diff] [blame] | 802 | __u32 flags; |
Jan Kiszka | 3cfc309 | 2009-11-12 01:04:25 +0100 | [diff] [blame] | 803 | }; |
| 804 | |
Jan Kiszka | 48005f6 | 2010-02-19 19:38:07 +0100 | [diff] [blame] | 805 | KVM_VCPUEVENT_VALID_SHADOW may be set in the flags field to signal that |
| 806 | interrupt.shadow contains a valid state. Otherwise, this field is undefined. |
| 807 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 808 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 809 | 4.32 KVM_SET_VCPU_EVENTS |
Jan Kiszka | 3cfc309 | 2009-11-12 01:04:25 +0100 | [diff] [blame] | 810 | |
| 811 | Capability: KVM_CAP_VCPU_EVENTS |
Jan Kiszka | 48005f6 | 2010-02-19 19:38:07 +0100 | [diff] [blame] | 812 | Extended by: KVM_CAP_INTR_SHADOW |
Jan Kiszka | 3cfc309 | 2009-11-12 01:04:25 +0100 | [diff] [blame] | 813 | Architectures: x86 |
| 814 | Type: vm ioctl |
| 815 | Parameters: struct kvm_vcpu_event (in) |
| 816 | Returns: 0 on success, -1 on error |
| 817 | |
| 818 | Set pending exceptions, interrupts, and NMIs as well as related states of the |
| 819 | vcpu. |
| 820 | |
| 821 | See KVM_GET_VCPU_EVENTS for the data structure. |
| 822 | |
Jan Kiszka | dab4b91 | 2009-12-06 18:24:15 +0100 | [diff] [blame] | 823 | Fields that may be modified asynchronously by running VCPUs can be excluded |
| 824 | from the update. These fields are nmi.pending and sipi_vector. Keep the |
| 825 | corresponding bits in the flags field cleared to suppress overwriting the |
| 826 | current in-kernel state. The bits are: |
| 827 | |
| 828 | KVM_VCPUEVENT_VALID_NMI_PENDING - transfer nmi.pending to the kernel |
| 829 | KVM_VCPUEVENT_VALID_SIPI_VECTOR - transfer sipi_vector |
| 830 | |
Jan Kiszka | 48005f6 | 2010-02-19 19:38:07 +0100 | [diff] [blame] | 831 | If KVM_CAP_INTR_SHADOW is available, KVM_VCPUEVENT_VALID_SHADOW can be set in |
| 832 | the flags field to signal that interrupt.shadow contains a valid state and |
| 833 | shall be written into the VCPU. |
| 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.33 KVM_GET_DEBUGREGS |
Jan Kiszka | a1efbe7 | 2010-02-15 10:45:43 +0100 | [diff] [blame] | 837 | |
| 838 | Capability: KVM_CAP_DEBUGREGS |
| 839 | Architectures: x86 |
| 840 | Type: vm ioctl |
| 841 | Parameters: struct kvm_debugregs (out) |
| 842 | Returns: 0 on success, -1 on error |
| 843 | |
| 844 | Reads debug registers from the vcpu. |
| 845 | |
| 846 | struct kvm_debugregs { |
| 847 | __u64 db[4]; |
| 848 | __u64 dr6; |
| 849 | __u64 dr7; |
| 850 | __u64 flags; |
| 851 | __u64 reserved[9]; |
| 852 | }; |
| 853 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 854 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 855 | 4.34 KVM_SET_DEBUGREGS |
Jan Kiszka | a1efbe7 | 2010-02-15 10:45:43 +0100 | [diff] [blame] | 856 | |
| 857 | Capability: KVM_CAP_DEBUGREGS |
| 858 | Architectures: x86 |
| 859 | Type: vm ioctl |
| 860 | Parameters: struct kvm_debugregs (in) |
| 861 | Returns: 0 on success, -1 on error |
| 862 | |
| 863 | Writes debug registers into the vcpu. |
| 864 | |
| 865 | See KVM_GET_DEBUGREGS for the data structure. The flags field is unused |
| 866 | yet and must be cleared on entry. |
| 867 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 868 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 869 | 4.35 KVM_SET_USER_MEMORY_REGION |
Avi Kivity | 0f2d8f4 | 2010-03-25 12:16:48 +0200 | [diff] [blame] | 870 | |
| 871 | Capability: KVM_CAP_USER_MEM |
| 872 | Architectures: all |
| 873 | Type: vm ioctl |
| 874 | Parameters: struct kvm_userspace_memory_region (in) |
| 875 | Returns: 0 on success, -1 on error |
| 876 | |
| 877 | struct kvm_userspace_memory_region { |
| 878 | __u32 slot; |
| 879 | __u32 flags; |
| 880 | __u64 guest_phys_addr; |
| 881 | __u64 memory_size; /* bytes */ |
| 882 | __u64 userspace_addr; /* start of the userspace allocated memory */ |
| 883 | }; |
| 884 | |
| 885 | /* for kvm_memory_region::flags */ |
Xiao Guangrong | 4d8b81a | 2012-08-21 11:02:51 +0800 | [diff] [blame] | 886 | #define KVM_MEM_LOG_DIRTY_PAGES (1UL << 0) |
| 887 | #define KVM_MEM_READONLY (1UL << 1) |
Avi Kivity | 0f2d8f4 | 2010-03-25 12:16:48 +0200 | [diff] [blame] | 888 | |
| 889 | This ioctl allows the user to create or modify a guest physical memory |
| 890 | slot. When changing an existing slot, it may be moved in the guest |
| 891 | physical memory space, or its flags may be modified. It may not be |
| 892 | resized. Slots may not overlap in guest physical address space. |
| 893 | |
| 894 | Memory for the region is taken starting at the address denoted by the |
| 895 | field userspace_addr, which must point at user addressable memory for |
| 896 | the entire memory slot size. Any object may back this memory, including |
| 897 | anonymous memory, ordinary files, and hugetlbfs. |
| 898 | |
| 899 | It is recommended that the lower 21 bits of guest_phys_addr and userspace_addr |
| 900 | be identical. This allows large pages in the guest to be backed by large |
| 901 | pages in the host. |
| 902 | |
Takuya Yoshikawa | 75d61fb | 2013-01-30 19:40:41 +0900 | [diff] [blame] | 903 | The flags field supports two flags: KVM_MEM_LOG_DIRTY_PAGES and |
| 904 | KVM_MEM_READONLY. The former can be set to instruct KVM to keep track of |
| 905 | writes to memory within the slot. See KVM_GET_DIRTY_LOG ioctl to know how to |
| 906 | use it. The latter can be set, if KVM_CAP_READONLY_MEM capability allows it, |
| 907 | to make a new slot read-only. In this case, writes to this memory will be |
| 908 | posted to userspace as KVM_EXIT_MMIO exits. |
Avi Kivity | 0f2d8f4 | 2010-03-25 12:16:48 +0200 | [diff] [blame] | 909 | |
Jan Kiszka | 7efd8fa | 2012-09-07 13:17:47 +0200 | [diff] [blame] | 910 | When the KVM_CAP_SYNC_MMU capability is available, changes in the backing of |
| 911 | the memory region are automatically reflected into the guest. For example, an |
| 912 | mmap() that affects the region will be made visible immediately. Another |
| 913 | example is madvise(MADV_DROP). |
Avi Kivity | 0f2d8f4 | 2010-03-25 12:16:48 +0200 | [diff] [blame] | 914 | |
| 915 | It is recommended to use this API instead of the KVM_SET_MEMORY_REGION ioctl. |
| 916 | The KVM_SET_MEMORY_REGION does not allow fine grained control over memory |
| 917 | allocation and is deprecated. |
Jan Kiszka | 3cfc309 | 2009-11-12 01:04:25 +0100 | [diff] [blame] | 918 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 919 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 920 | 4.36 KVM_SET_TSS_ADDR |
Avi Kivity | 8a5416d | 2010-03-25 12:27:30 +0200 | [diff] [blame] | 921 | |
| 922 | Capability: KVM_CAP_SET_TSS_ADDR |
| 923 | Architectures: x86 |
| 924 | Type: vm ioctl |
| 925 | Parameters: unsigned long tss_address (in) |
| 926 | Returns: 0 on success, -1 on error |
| 927 | |
| 928 | This ioctl defines the physical address of a three-page region in the guest |
| 929 | physical address space. The region must be within the first 4GB of the |
| 930 | guest physical address space and must not conflict with any memory slot |
| 931 | or any mmio address. The guest may malfunction if it accesses this memory |
| 932 | region. |
| 933 | |
| 934 | This ioctl is required on Intel-based hosts. This is needed on Intel hardware |
| 935 | because of a quirk in the virtualization implementation (see the internals |
| 936 | documentation when it pops into existence). |
| 937 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 938 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 939 | 4.37 KVM_ENABLE_CAP |
Alexander Graf | 71fbfd5 | 2010-03-24 21:48:29 +0100 | [diff] [blame] | 940 | |
Cornelia Huck | d938dc5 | 2013-10-23 18:26:34 +0200 | [diff] [blame] | 941 | Capability: KVM_CAP_ENABLE_CAP, KVM_CAP_ENABLE_CAP_VM |
Cornelia Huck | d6712df | 2012-12-20 15:32:11 +0100 | [diff] [blame] | 942 | Architectures: ppc, s390 |
Cornelia Huck | d938dc5 | 2013-10-23 18:26:34 +0200 | [diff] [blame] | 943 | Type: vcpu ioctl, vm ioctl (with KVM_CAP_ENABLE_CAP_VM) |
Alexander Graf | 71fbfd5 | 2010-03-24 21:48:29 +0100 | [diff] [blame] | 944 | Parameters: struct kvm_enable_cap (in) |
| 945 | Returns: 0 on success; -1 on error |
| 946 | |
| 947 | +Not all extensions are enabled by default. Using this ioctl the application |
| 948 | can enable an extension, making it available to the guest. |
| 949 | |
| 950 | On systems that do not support this ioctl, it always fails. On systems that |
| 951 | do support it, it only works for extensions that are supported for enablement. |
| 952 | |
| 953 | To check if a capability can be enabled, the KVM_CHECK_EXTENSION ioctl should |
| 954 | be used. |
| 955 | |
| 956 | struct kvm_enable_cap { |
| 957 | /* in */ |
| 958 | __u32 cap; |
| 959 | |
| 960 | The capability that is supposed to get enabled. |
| 961 | |
| 962 | __u32 flags; |
| 963 | |
| 964 | A bitfield indicating future enhancements. Has to be 0 for now. |
| 965 | |
| 966 | __u64 args[4]; |
| 967 | |
| 968 | Arguments for enabling a feature. If a feature needs initial values to |
| 969 | function properly, this is the place to put them. |
| 970 | |
| 971 | __u8 pad[64]; |
| 972 | }; |
| 973 | |
Cornelia Huck | d938dc5 | 2013-10-23 18:26:34 +0200 | [diff] [blame] | 974 | The vcpu ioctl should be used for vcpu-specific capabilities, the vm ioctl |
| 975 | for vm-wide capabilities. |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 976 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 977 | 4.38 KVM_GET_MP_STATE |
Avi Kivity | b843f06 | 2010-04-25 15:51:46 +0300 | [diff] [blame] | 978 | |
| 979 | Capability: KVM_CAP_MP_STATE |
| 980 | Architectures: x86, ia64 |
| 981 | Type: vcpu ioctl |
| 982 | Parameters: struct kvm_mp_state (out) |
| 983 | Returns: 0 on success; -1 on error |
| 984 | |
| 985 | struct kvm_mp_state { |
| 986 | __u32 mp_state; |
| 987 | }; |
| 988 | |
| 989 | Returns the vcpu's current "multiprocessing state" (though also valid on |
| 990 | uniprocessor guests). |
| 991 | |
| 992 | Possible values are: |
| 993 | |
| 994 | - KVM_MP_STATE_RUNNABLE: the vcpu is currently running |
| 995 | - KVM_MP_STATE_UNINITIALIZED: the vcpu is an application processor (AP) |
| 996 | which has not yet received an INIT signal |
| 997 | - KVM_MP_STATE_INIT_RECEIVED: the vcpu has received an INIT signal, and is |
| 998 | now ready for a SIPI |
| 999 | - KVM_MP_STATE_HALTED: the vcpu has executed a HLT instruction and |
| 1000 | is waiting for an interrupt |
| 1001 | - KVM_MP_STATE_SIPI_RECEIVED: the vcpu has just received a SIPI (vector |
Uwe Kleine-König | b595076 | 2010-11-01 15:38:34 -0400 | [diff] [blame] | 1002 | accessible via KVM_GET_VCPU_EVENTS) |
Avi Kivity | b843f06 | 2010-04-25 15:51:46 +0300 | [diff] [blame] | 1003 | |
| 1004 | This ioctl is only useful after KVM_CREATE_IRQCHIP. Without an in-kernel |
| 1005 | irqchip, the multiprocessing state must be maintained by userspace. |
| 1006 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1007 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1008 | 4.39 KVM_SET_MP_STATE |
Avi Kivity | b843f06 | 2010-04-25 15:51:46 +0300 | [diff] [blame] | 1009 | |
| 1010 | Capability: KVM_CAP_MP_STATE |
| 1011 | Architectures: x86, ia64 |
| 1012 | Type: vcpu ioctl |
| 1013 | Parameters: struct kvm_mp_state (in) |
| 1014 | Returns: 0 on success; -1 on error |
| 1015 | |
| 1016 | Sets the vcpu's current "multiprocessing state"; see KVM_GET_MP_STATE for |
| 1017 | arguments. |
| 1018 | |
| 1019 | This ioctl is only useful after KVM_CREATE_IRQCHIP. Without an in-kernel |
| 1020 | irqchip, the multiprocessing state must be maintained by userspace. |
| 1021 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1022 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1023 | 4.40 KVM_SET_IDENTITY_MAP_ADDR |
Avi Kivity | 47dbb84 | 2010-04-29 12:08:56 +0300 | [diff] [blame] | 1024 | |
| 1025 | Capability: KVM_CAP_SET_IDENTITY_MAP_ADDR |
| 1026 | Architectures: x86 |
| 1027 | Type: vm ioctl |
| 1028 | Parameters: unsigned long identity (in) |
| 1029 | Returns: 0 on success, -1 on error |
| 1030 | |
| 1031 | This ioctl defines the physical address of a one-page region in the guest |
| 1032 | physical address space. The region must be within the first 4GB of the |
| 1033 | guest physical address space and must not conflict with any memory slot |
| 1034 | or any mmio address. The guest may malfunction if it accesses this memory |
| 1035 | region. |
| 1036 | |
| 1037 | This ioctl is required on Intel-based hosts. This is needed on Intel hardware |
| 1038 | because of a quirk in the virtualization implementation (see the internals |
| 1039 | documentation when it pops into existence). |
| 1040 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1041 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1042 | 4.41 KVM_SET_BOOT_CPU_ID |
Avi Kivity | 57bc24c | 2010-04-29 12:12:57 +0300 | [diff] [blame] | 1043 | |
| 1044 | Capability: KVM_CAP_SET_BOOT_CPU_ID |
| 1045 | Architectures: x86, ia64 |
| 1046 | Type: vm ioctl |
| 1047 | Parameters: unsigned long vcpu_id |
| 1048 | Returns: 0 on success, -1 on error |
| 1049 | |
| 1050 | Define which vcpu is the Bootstrap Processor (BSP). Values are the same |
| 1051 | as the vcpu id in KVM_CREATE_VCPU. If this ioctl is not called, the default |
| 1052 | is vcpu 0. |
| 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.42 KVM_GET_XSAVE |
Sheng Yang | 2d5b5a6 | 2010-06-13 17:29:39 +0800 | [diff] [blame] | 1056 | |
| 1057 | Capability: KVM_CAP_XSAVE |
| 1058 | Architectures: x86 |
| 1059 | Type: vcpu ioctl |
| 1060 | Parameters: struct kvm_xsave (out) |
| 1061 | Returns: 0 on success, -1 on error |
| 1062 | |
| 1063 | struct kvm_xsave { |
| 1064 | __u32 region[1024]; |
| 1065 | }; |
| 1066 | |
| 1067 | This ioctl would copy current vcpu's xsave struct to the userspace. |
| 1068 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1069 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1070 | 4.43 KVM_SET_XSAVE |
Sheng Yang | 2d5b5a6 | 2010-06-13 17:29:39 +0800 | [diff] [blame] | 1071 | |
| 1072 | Capability: KVM_CAP_XSAVE |
| 1073 | Architectures: x86 |
| 1074 | Type: vcpu ioctl |
| 1075 | Parameters: struct kvm_xsave (in) |
| 1076 | Returns: 0 on success, -1 on error |
| 1077 | |
| 1078 | struct kvm_xsave { |
| 1079 | __u32 region[1024]; |
| 1080 | }; |
| 1081 | |
| 1082 | This ioctl would copy userspace's xsave struct to the kernel. |
| 1083 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1084 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1085 | 4.44 KVM_GET_XCRS |
Sheng Yang | 2d5b5a6 | 2010-06-13 17:29:39 +0800 | [diff] [blame] | 1086 | |
| 1087 | Capability: KVM_CAP_XCRS |
| 1088 | Architectures: x86 |
| 1089 | Type: vcpu ioctl |
| 1090 | Parameters: struct kvm_xcrs (out) |
| 1091 | Returns: 0 on success, -1 on error |
| 1092 | |
| 1093 | struct kvm_xcr { |
| 1094 | __u32 xcr; |
| 1095 | __u32 reserved; |
| 1096 | __u64 value; |
| 1097 | }; |
| 1098 | |
| 1099 | struct kvm_xcrs { |
| 1100 | __u32 nr_xcrs; |
| 1101 | __u32 flags; |
| 1102 | struct kvm_xcr xcrs[KVM_MAX_XCRS]; |
| 1103 | __u64 padding[16]; |
| 1104 | }; |
| 1105 | |
| 1106 | This ioctl would copy current vcpu's xcrs to the userspace. |
| 1107 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1108 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1109 | 4.45 KVM_SET_XCRS |
Sheng Yang | 2d5b5a6 | 2010-06-13 17:29:39 +0800 | [diff] [blame] | 1110 | |
| 1111 | Capability: KVM_CAP_XCRS |
| 1112 | Architectures: x86 |
| 1113 | Type: vcpu ioctl |
| 1114 | Parameters: struct kvm_xcrs (in) |
| 1115 | Returns: 0 on success, -1 on error |
| 1116 | |
| 1117 | struct kvm_xcr { |
| 1118 | __u32 xcr; |
| 1119 | __u32 reserved; |
| 1120 | __u64 value; |
| 1121 | }; |
| 1122 | |
| 1123 | struct kvm_xcrs { |
| 1124 | __u32 nr_xcrs; |
| 1125 | __u32 flags; |
| 1126 | struct kvm_xcr xcrs[KVM_MAX_XCRS]; |
| 1127 | __u64 padding[16]; |
| 1128 | }; |
| 1129 | |
| 1130 | This ioctl would set vcpu's xcr to the value userspace specified. |
| 1131 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1132 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1133 | 4.46 KVM_GET_SUPPORTED_CPUID |
Avi Kivity | d153513 | 2010-07-14 09:45:21 +0300 | [diff] [blame] | 1134 | |
| 1135 | Capability: KVM_CAP_EXT_CPUID |
| 1136 | Architectures: x86 |
| 1137 | Type: system ioctl |
| 1138 | Parameters: struct kvm_cpuid2 (in/out) |
| 1139 | Returns: 0 on success, -1 on error |
| 1140 | |
| 1141 | struct kvm_cpuid2 { |
| 1142 | __u32 nent; |
| 1143 | __u32 padding; |
| 1144 | struct kvm_cpuid_entry2 entries[0]; |
| 1145 | }; |
| 1146 | |
Borislav Petkov | 9c15bb1 | 2013-09-22 16:44:50 +0200 | [diff] [blame] | 1147 | #define KVM_CPUID_FLAG_SIGNIFCANT_INDEX BIT(0) |
| 1148 | #define KVM_CPUID_FLAG_STATEFUL_FUNC BIT(1) |
| 1149 | #define KVM_CPUID_FLAG_STATE_READ_NEXT BIT(2) |
Avi Kivity | d153513 | 2010-07-14 09:45:21 +0300 | [diff] [blame] | 1150 | |
| 1151 | struct kvm_cpuid_entry2 { |
| 1152 | __u32 function; |
| 1153 | __u32 index; |
| 1154 | __u32 flags; |
| 1155 | __u32 eax; |
| 1156 | __u32 ebx; |
| 1157 | __u32 ecx; |
| 1158 | __u32 edx; |
| 1159 | __u32 padding[3]; |
| 1160 | }; |
| 1161 | |
| 1162 | This ioctl returns x86 cpuid features which are supported by both the hardware |
| 1163 | and kvm. Userspace can use the information returned by this ioctl to |
| 1164 | construct cpuid information (for KVM_SET_CPUID2) that is consistent with |
| 1165 | hardware, kernel, and userspace capabilities, and with user requirements (for |
| 1166 | example, the user may wish to constrain cpuid to emulate older hardware, |
| 1167 | or for feature consistency across a cluster). |
| 1168 | |
| 1169 | Userspace invokes KVM_GET_SUPPORTED_CPUID by passing a kvm_cpuid2 structure |
| 1170 | with the 'nent' field indicating the number of entries in the variable-size |
| 1171 | array 'entries'. If the number of entries is too low to describe the cpu |
| 1172 | capabilities, an error (E2BIG) is returned. If the number is too high, |
| 1173 | the 'nent' field is adjusted and an error (ENOMEM) is returned. If the |
| 1174 | number is just right, the 'nent' field is adjusted to the number of valid |
| 1175 | entries in the 'entries' array, which is then filled. |
| 1176 | |
| 1177 | 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] | 1178 | with unknown or unsupported features masked out. Some features (for example, |
| 1179 | x2apic), may not be present in the host cpu, but are exposed by kvm if it can |
| 1180 | emulate them efficiently. The fields in each entry are defined as follows: |
Avi Kivity | d153513 | 2010-07-14 09:45:21 +0300 | [diff] [blame] | 1181 | |
| 1182 | function: the eax value used to obtain the entry |
| 1183 | index: the ecx value used to obtain the entry (for entries that are |
| 1184 | affected by ecx) |
| 1185 | flags: an OR of zero or more of the following: |
| 1186 | KVM_CPUID_FLAG_SIGNIFCANT_INDEX: |
| 1187 | if the index field is valid |
| 1188 | KVM_CPUID_FLAG_STATEFUL_FUNC: |
| 1189 | if cpuid for this function returns different values for successive |
| 1190 | invocations; there will be several entries with the same function, |
| 1191 | all with this flag set |
| 1192 | KVM_CPUID_FLAG_STATE_READ_NEXT: |
| 1193 | for KVM_CPUID_FLAG_STATEFUL_FUNC entries, set if this entry is |
| 1194 | the first entry to be read by a cpu |
| 1195 | eax, ebx, ecx, edx: the values returned by the cpuid instruction for |
| 1196 | this function/index combination |
| 1197 | |
Jan Kiszka | 4d25a066 | 2011-12-21 12:28:29 +0100 | [diff] [blame] | 1198 | The TSC deadline timer feature (CPUID leaf 1, ecx[24]) is always returned |
| 1199 | as false, since the feature depends on KVM_CREATE_IRQCHIP for local APIC |
| 1200 | support. Instead it is reported via |
| 1201 | |
| 1202 | ioctl(KVM_CHECK_EXTENSION, KVM_CAP_TSC_DEADLINE_TIMER) |
| 1203 | |
| 1204 | if that returns true and you use KVM_CREATE_IRQCHIP, or if you emulate the |
| 1205 | feature in userspace, then you can enable the feature for KVM_SET_CPUID2. |
| 1206 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1207 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1208 | 4.47 KVM_PPC_GET_PVINFO |
Alexander Graf | 15711e9 | 2010-07-29 14:48:08 +0200 | [diff] [blame] | 1209 | |
| 1210 | Capability: KVM_CAP_PPC_GET_PVINFO |
| 1211 | Architectures: ppc |
| 1212 | Type: vm ioctl |
| 1213 | Parameters: struct kvm_ppc_pvinfo (out) |
| 1214 | Returns: 0 on success, !0 on error |
| 1215 | |
| 1216 | struct kvm_ppc_pvinfo { |
| 1217 | __u32 flags; |
| 1218 | __u32 hcall[4]; |
| 1219 | __u8 pad[108]; |
| 1220 | }; |
| 1221 | |
| 1222 | This ioctl fetches PV specific information that need to be passed to the guest |
| 1223 | using the device tree or other means from vm context. |
| 1224 | |
Liu Yu-B13201 | 9202e07 | 2012-07-03 05:48:52 +0000 | [diff] [blame] | 1225 | The hcall array defines 4 instructions that make up a hypercall. |
Alexander Graf | 15711e9 | 2010-07-29 14:48:08 +0200 | [diff] [blame] | 1226 | |
| 1227 | If any additional field gets added to this structure later on, a bit for that |
| 1228 | additional piece of information will be set in the flags bitmap. |
| 1229 | |
Liu Yu-B13201 | 9202e07 | 2012-07-03 05:48:52 +0000 | [diff] [blame] | 1230 | The flags bitmap is defined as: |
| 1231 | |
| 1232 | /* the host supports the ePAPR idle hcall |
| 1233 | #define KVM_PPC_PVINFO_FLAGS_EV_IDLE (1<<0) |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1234 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1235 | 4.48 KVM_ASSIGN_PCI_DEVICE |
Jan Kiszka | 49f4817 | 2010-11-16 22:30:07 +0100 | [diff] [blame] | 1236 | |
| 1237 | Capability: KVM_CAP_DEVICE_ASSIGNMENT |
| 1238 | Architectures: x86 ia64 |
| 1239 | Type: vm ioctl |
| 1240 | Parameters: struct kvm_assigned_pci_dev (in) |
| 1241 | Returns: 0 on success, -1 on error |
| 1242 | |
| 1243 | Assigns a host PCI device to the VM. |
| 1244 | |
| 1245 | struct kvm_assigned_pci_dev { |
| 1246 | __u32 assigned_dev_id; |
| 1247 | __u32 busnr; |
| 1248 | __u32 devfn; |
| 1249 | __u32 flags; |
| 1250 | __u32 segnr; |
| 1251 | union { |
| 1252 | __u32 reserved[11]; |
| 1253 | }; |
| 1254 | }; |
| 1255 | |
| 1256 | The PCI device is specified by the triple segnr, busnr, and devfn. |
| 1257 | Identification in succeeding service requests is done via assigned_dev_id. The |
| 1258 | following flags are specified: |
| 1259 | |
| 1260 | /* Depends on KVM_CAP_IOMMU */ |
| 1261 | #define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0) |
Jan Kiszka | 07700a9 | 2012-02-28 14:19:54 +0100 | [diff] [blame] | 1262 | /* The following two depend on KVM_CAP_PCI_2_3 */ |
| 1263 | #define KVM_DEV_ASSIGN_PCI_2_3 (1 << 1) |
| 1264 | #define KVM_DEV_ASSIGN_MASK_INTX (1 << 2) |
| 1265 | |
| 1266 | If KVM_DEV_ASSIGN_PCI_2_3 is set, the kernel will manage legacy INTx interrupts |
| 1267 | via the PCI-2.3-compliant device-level mask, thus enable IRQ sharing with other |
| 1268 | assigned devices or host devices. KVM_DEV_ASSIGN_MASK_INTX specifies the |
| 1269 | guest's view on the INTx mask, see KVM_ASSIGN_SET_INTX_MASK for details. |
Jan Kiszka | 49f4817 | 2010-11-16 22:30:07 +0100 | [diff] [blame] | 1270 | |
Alex Williamson | 4238737 | 2011-12-20 21:59:03 -0700 | [diff] [blame] | 1271 | The KVM_DEV_ASSIGN_ENABLE_IOMMU flag is a mandatory option to ensure |
| 1272 | isolation of the device. Usages not specifying this flag are deprecated. |
| 1273 | |
Alex Williamson | 3d27e23 | 2011-12-20 21:59:09 -0700 | [diff] [blame] | 1274 | Only PCI header type 0 devices with PCI BAR resources are supported by |
| 1275 | device assignment. The user requesting this ioctl must have read/write |
| 1276 | access to the PCI sysfs resource files associated with the device. |
| 1277 | |
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.49 KVM_DEASSIGN_PCI_DEVICE |
Jan Kiszka | 49f4817 | 2010-11-16 22:30:07 +0100 | [diff] [blame] | 1280 | |
| 1281 | Capability: KVM_CAP_DEVICE_DEASSIGNMENT |
| 1282 | Architectures: x86 ia64 |
| 1283 | Type: vm ioctl |
| 1284 | Parameters: struct kvm_assigned_pci_dev (in) |
| 1285 | Returns: 0 on success, -1 on error |
| 1286 | |
| 1287 | Ends PCI device assignment, releasing all associated resources. |
| 1288 | |
| 1289 | See KVM_CAP_DEVICE_ASSIGNMENT for the data structure. Only assigned_dev_id is |
| 1290 | used in kvm_assigned_pci_dev to identify the device. |
| 1291 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1292 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1293 | 4.50 KVM_ASSIGN_DEV_IRQ |
Jan Kiszka | 49f4817 | 2010-11-16 22:30:07 +0100 | [diff] [blame] | 1294 | |
| 1295 | Capability: KVM_CAP_ASSIGN_DEV_IRQ |
| 1296 | Architectures: x86 ia64 |
| 1297 | Type: vm ioctl |
| 1298 | Parameters: struct kvm_assigned_irq (in) |
| 1299 | Returns: 0 on success, -1 on error |
| 1300 | |
| 1301 | Assigns an IRQ to a passed-through device. |
| 1302 | |
| 1303 | struct kvm_assigned_irq { |
| 1304 | __u32 assigned_dev_id; |
Jan Kiszka | 91e3d71 | 2011-06-03 08:51:05 +0200 | [diff] [blame] | 1305 | __u32 host_irq; /* ignored (legacy field) */ |
Jan Kiszka | 49f4817 | 2010-11-16 22:30:07 +0100 | [diff] [blame] | 1306 | __u32 guest_irq; |
| 1307 | __u32 flags; |
| 1308 | union { |
Jan Kiszka | 49f4817 | 2010-11-16 22:30:07 +0100 | [diff] [blame] | 1309 | __u32 reserved[12]; |
| 1310 | }; |
| 1311 | }; |
| 1312 | |
| 1313 | The following flags are defined: |
| 1314 | |
| 1315 | #define KVM_DEV_IRQ_HOST_INTX (1 << 0) |
| 1316 | #define KVM_DEV_IRQ_HOST_MSI (1 << 1) |
| 1317 | #define KVM_DEV_IRQ_HOST_MSIX (1 << 2) |
| 1318 | |
| 1319 | #define KVM_DEV_IRQ_GUEST_INTX (1 << 8) |
| 1320 | #define KVM_DEV_IRQ_GUEST_MSI (1 << 9) |
| 1321 | #define KVM_DEV_IRQ_GUEST_MSIX (1 << 10) |
| 1322 | |
| 1323 | It is not valid to specify multiple types per host or guest IRQ. However, the |
| 1324 | IRQ type of host and guest can differ or can even be null. |
| 1325 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1326 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1327 | 4.51 KVM_DEASSIGN_DEV_IRQ |
Jan Kiszka | 49f4817 | 2010-11-16 22:30:07 +0100 | [diff] [blame] | 1328 | |
| 1329 | Capability: KVM_CAP_ASSIGN_DEV_IRQ |
| 1330 | Architectures: x86 ia64 |
| 1331 | Type: vm ioctl |
| 1332 | Parameters: struct kvm_assigned_irq (in) |
| 1333 | Returns: 0 on success, -1 on error |
| 1334 | |
| 1335 | Ends an IRQ assignment to a passed-through device. |
| 1336 | |
| 1337 | See KVM_ASSIGN_DEV_IRQ for the data structure. The target device is specified |
| 1338 | by assigned_dev_id, flags must correspond to the IRQ type specified on |
| 1339 | KVM_ASSIGN_DEV_IRQ. Partial deassignment of host or guest IRQ is allowed. |
| 1340 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1341 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1342 | 4.52 KVM_SET_GSI_ROUTING |
Jan Kiszka | 49f4817 | 2010-11-16 22:30:07 +0100 | [diff] [blame] | 1343 | |
| 1344 | Capability: KVM_CAP_IRQ_ROUTING |
Cornelia Huck | 8422359 | 2013-07-15 13:36:01 +0200 | [diff] [blame] | 1345 | Architectures: x86 ia64 s390 |
Jan Kiszka | 49f4817 | 2010-11-16 22:30:07 +0100 | [diff] [blame] | 1346 | Type: vm ioctl |
| 1347 | Parameters: struct kvm_irq_routing (in) |
| 1348 | Returns: 0 on success, -1 on error |
| 1349 | |
| 1350 | Sets the GSI routing table entries, overwriting any previously set entries. |
| 1351 | |
| 1352 | struct kvm_irq_routing { |
| 1353 | __u32 nr; |
| 1354 | __u32 flags; |
| 1355 | struct kvm_irq_routing_entry entries[0]; |
| 1356 | }; |
| 1357 | |
| 1358 | No flags are specified so far, the corresponding field must be set to zero. |
| 1359 | |
| 1360 | struct kvm_irq_routing_entry { |
| 1361 | __u32 gsi; |
| 1362 | __u32 type; |
| 1363 | __u32 flags; |
| 1364 | __u32 pad; |
| 1365 | union { |
| 1366 | struct kvm_irq_routing_irqchip irqchip; |
| 1367 | struct kvm_irq_routing_msi msi; |
Cornelia Huck | 8422359 | 2013-07-15 13:36:01 +0200 | [diff] [blame] | 1368 | struct kvm_irq_routing_s390_adapter adapter; |
Jan Kiszka | 49f4817 | 2010-11-16 22:30:07 +0100 | [diff] [blame] | 1369 | __u32 pad[8]; |
| 1370 | } u; |
| 1371 | }; |
| 1372 | |
| 1373 | /* gsi routing entry types */ |
| 1374 | #define KVM_IRQ_ROUTING_IRQCHIP 1 |
| 1375 | #define KVM_IRQ_ROUTING_MSI 2 |
Cornelia Huck | 8422359 | 2013-07-15 13:36:01 +0200 | [diff] [blame] | 1376 | #define KVM_IRQ_ROUTING_S390_ADAPTER 3 |
Jan Kiszka | 49f4817 | 2010-11-16 22:30:07 +0100 | [diff] [blame] | 1377 | |
| 1378 | No flags are specified so far, the corresponding field must be set to zero. |
| 1379 | |
| 1380 | struct kvm_irq_routing_irqchip { |
| 1381 | __u32 irqchip; |
| 1382 | __u32 pin; |
| 1383 | }; |
| 1384 | |
| 1385 | struct kvm_irq_routing_msi { |
| 1386 | __u32 address_lo; |
| 1387 | __u32 address_hi; |
| 1388 | __u32 data; |
| 1389 | __u32 pad; |
| 1390 | }; |
| 1391 | |
Cornelia Huck | 8422359 | 2013-07-15 13:36:01 +0200 | [diff] [blame] | 1392 | struct kvm_irq_routing_s390_adapter { |
| 1393 | __u64 ind_addr; |
| 1394 | __u64 summary_addr; |
| 1395 | __u64 ind_offset; |
| 1396 | __u32 summary_offset; |
| 1397 | __u32 adapter_id; |
| 1398 | }; |
| 1399 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1400 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1401 | 4.53 KVM_ASSIGN_SET_MSIX_NR |
Jan Kiszka | 49f4817 | 2010-11-16 22:30:07 +0100 | [diff] [blame] | 1402 | |
| 1403 | Capability: KVM_CAP_DEVICE_MSIX |
| 1404 | Architectures: x86 ia64 |
| 1405 | Type: vm ioctl |
| 1406 | Parameters: struct kvm_assigned_msix_nr (in) |
| 1407 | Returns: 0 on success, -1 on error |
| 1408 | |
Jan Kiszka | 58f0964 | 2011-06-11 12:24:24 +0200 | [diff] [blame] | 1409 | Set the number of MSI-X interrupts for an assigned device. The number is |
| 1410 | reset again by terminating the MSI-X assignment of the device via |
| 1411 | KVM_DEASSIGN_DEV_IRQ. Calling this service more than once at any earlier |
| 1412 | point will fail. |
Jan Kiszka | 49f4817 | 2010-11-16 22:30:07 +0100 | [diff] [blame] | 1413 | |
| 1414 | struct kvm_assigned_msix_nr { |
| 1415 | __u32 assigned_dev_id; |
| 1416 | __u16 entry_nr; |
| 1417 | __u16 padding; |
| 1418 | }; |
| 1419 | |
| 1420 | #define KVM_MAX_MSIX_PER_DEV 256 |
| 1421 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1422 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1423 | 4.54 KVM_ASSIGN_SET_MSIX_ENTRY |
Jan Kiszka | 49f4817 | 2010-11-16 22:30:07 +0100 | [diff] [blame] | 1424 | |
| 1425 | Capability: KVM_CAP_DEVICE_MSIX |
| 1426 | Architectures: x86 ia64 |
| 1427 | Type: vm ioctl |
| 1428 | Parameters: struct kvm_assigned_msix_entry (in) |
| 1429 | Returns: 0 on success, -1 on error |
| 1430 | |
| 1431 | Specifies the routing of an MSI-X assigned device interrupt to a GSI. Setting |
| 1432 | the GSI vector to zero means disabling the interrupt. |
| 1433 | |
| 1434 | struct kvm_assigned_msix_entry { |
| 1435 | __u32 assigned_dev_id; |
| 1436 | __u32 gsi; |
| 1437 | __u16 entry; /* The index of entry in the MSI-X table */ |
| 1438 | __u16 padding[3]; |
| 1439 | }; |
| 1440 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1441 | |
| 1442 | 4.55 KVM_SET_TSC_KHZ |
Joerg Roedel | 92a1f12 | 2011-03-25 09:44:51 +0100 | [diff] [blame] | 1443 | |
| 1444 | Capability: KVM_CAP_TSC_CONTROL |
| 1445 | Architectures: x86 |
| 1446 | Type: vcpu ioctl |
| 1447 | Parameters: virtual tsc_khz |
| 1448 | Returns: 0 on success, -1 on error |
| 1449 | |
| 1450 | Specifies the tsc frequency for the virtual machine. The unit of the |
| 1451 | frequency is KHz. |
| 1452 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1453 | |
| 1454 | 4.56 KVM_GET_TSC_KHZ |
Joerg Roedel | 92a1f12 | 2011-03-25 09:44:51 +0100 | [diff] [blame] | 1455 | |
| 1456 | Capability: KVM_CAP_GET_TSC_KHZ |
| 1457 | Architectures: x86 |
| 1458 | Type: vcpu ioctl |
| 1459 | Parameters: none |
| 1460 | Returns: virtual tsc-khz on success, negative value on error |
| 1461 | |
| 1462 | Returns the tsc frequency of the guest. The unit of the return value is |
| 1463 | KHz. If the host has unstable tsc this ioctl returns -EIO instead as an |
| 1464 | error. |
| 1465 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1466 | |
| 1467 | 4.57 KVM_GET_LAPIC |
Avi Kivity | e767793 | 2011-05-11 08:30:51 -0400 | [diff] [blame] | 1468 | |
| 1469 | Capability: KVM_CAP_IRQCHIP |
| 1470 | Architectures: x86 |
| 1471 | Type: vcpu ioctl |
| 1472 | Parameters: struct kvm_lapic_state (out) |
| 1473 | Returns: 0 on success, -1 on error |
| 1474 | |
| 1475 | #define KVM_APIC_REG_SIZE 0x400 |
| 1476 | struct kvm_lapic_state { |
| 1477 | char regs[KVM_APIC_REG_SIZE]; |
| 1478 | }; |
| 1479 | |
| 1480 | Reads the Local APIC registers and copies them into the input argument. The |
| 1481 | data format and layout are the same as documented in the architecture manual. |
| 1482 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1483 | |
| 1484 | 4.58 KVM_SET_LAPIC |
Avi Kivity | e767793 | 2011-05-11 08:30:51 -0400 | [diff] [blame] | 1485 | |
| 1486 | Capability: KVM_CAP_IRQCHIP |
| 1487 | Architectures: x86 |
| 1488 | Type: vcpu ioctl |
| 1489 | Parameters: struct kvm_lapic_state (in) |
| 1490 | Returns: 0 on success, -1 on error |
| 1491 | |
| 1492 | #define KVM_APIC_REG_SIZE 0x400 |
| 1493 | struct kvm_lapic_state { |
| 1494 | char regs[KVM_APIC_REG_SIZE]; |
| 1495 | }; |
| 1496 | |
Masanari Iida | df5cbb2 | 2014-03-21 10:04:30 +0900 | [diff] [blame] | 1497 | Copies the input argument into the Local APIC registers. The data format |
Avi Kivity | e767793 | 2011-05-11 08:30:51 -0400 | [diff] [blame] | 1498 | and layout are the same as documented in the architecture manual. |
| 1499 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1500 | |
| 1501 | 4.59 KVM_IOEVENTFD |
Sasha Levin | 55399a0 | 2011-05-28 14:12:30 +0300 | [diff] [blame] | 1502 | |
| 1503 | Capability: KVM_CAP_IOEVENTFD |
| 1504 | Architectures: all |
| 1505 | Type: vm ioctl |
| 1506 | Parameters: struct kvm_ioeventfd (in) |
| 1507 | Returns: 0 on success, !0 on error |
| 1508 | |
| 1509 | This ioctl attaches or detaches an ioeventfd to a legal pio/mmio address |
| 1510 | within the guest. A guest write in the registered address will signal the |
| 1511 | provided event instead of triggering an exit. |
| 1512 | |
| 1513 | struct kvm_ioeventfd { |
| 1514 | __u64 datamatch; |
| 1515 | __u64 addr; /* legal pio/mmio address */ |
| 1516 | __u32 len; /* 1, 2, 4, or 8 bytes */ |
| 1517 | __s32 fd; |
| 1518 | __u32 flags; |
| 1519 | __u8 pad[36]; |
| 1520 | }; |
| 1521 | |
Cornelia Huck | 2b83451 | 2013-02-28 12:33:20 +0100 | [diff] [blame] | 1522 | For the special case of virtio-ccw devices on s390, the ioevent is matched |
| 1523 | to a subchannel/virtqueue tuple instead. |
| 1524 | |
Sasha Levin | 55399a0 | 2011-05-28 14:12:30 +0300 | [diff] [blame] | 1525 | The following flags are defined: |
| 1526 | |
| 1527 | #define KVM_IOEVENTFD_FLAG_DATAMATCH (1 << kvm_ioeventfd_flag_nr_datamatch) |
| 1528 | #define KVM_IOEVENTFD_FLAG_PIO (1 << kvm_ioeventfd_flag_nr_pio) |
| 1529 | #define KVM_IOEVENTFD_FLAG_DEASSIGN (1 << kvm_ioeventfd_flag_nr_deassign) |
Cornelia Huck | 2b83451 | 2013-02-28 12:33:20 +0100 | [diff] [blame] | 1530 | #define KVM_IOEVENTFD_FLAG_VIRTIO_CCW_NOTIFY \ |
| 1531 | (1 << kvm_ioeventfd_flag_nr_virtio_ccw_notify) |
Sasha Levin | 55399a0 | 2011-05-28 14:12:30 +0300 | [diff] [blame] | 1532 | |
| 1533 | If datamatch flag is set, the event will be signaled only if the written value |
| 1534 | to the registered address is equal to datamatch in struct kvm_ioeventfd. |
| 1535 | |
Cornelia Huck | 2b83451 | 2013-02-28 12:33:20 +0100 | [diff] [blame] | 1536 | For virtio-ccw devices, addr contains the subchannel id and datamatch the |
| 1537 | virtqueue index. |
| 1538 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1539 | |
| 1540 | 4.60 KVM_DIRTY_TLB |
Scott Wood | dc83b8b | 2011-08-18 15:25:21 -0500 | [diff] [blame] | 1541 | |
| 1542 | Capability: KVM_CAP_SW_TLB |
| 1543 | Architectures: ppc |
| 1544 | Type: vcpu ioctl |
| 1545 | Parameters: struct kvm_dirty_tlb (in) |
| 1546 | Returns: 0 on success, -1 on error |
| 1547 | |
| 1548 | struct kvm_dirty_tlb { |
| 1549 | __u64 bitmap; |
| 1550 | __u32 num_dirty; |
| 1551 | }; |
| 1552 | |
| 1553 | This must be called whenever userspace has changed an entry in the shared |
| 1554 | TLB, prior to calling KVM_RUN on the associated vcpu. |
| 1555 | |
| 1556 | The "bitmap" field is the userspace address of an array. This array |
| 1557 | consists of a number of bits, equal to the total number of TLB entries as |
| 1558 | determined by the last successful call to KVM_CONFIG_TLB, rounded up to the |
| 1559 | nearest multiple of 64. |
| 1560 | |
| 1561 | Each bit corresponds to one TLB entry, ordered the same as in the shared TLB |
| 1562 | array. |
| 1563 | |
| 1564 | The array is little-endian: the bit 0 is the least significant bit of the |
| 1565 | first byte, bit 8 is the least significant bit of the second byte, etc. |
| 1566 | This avoids any complications with differing word sizes. |
| 1567 | |
| 1568 | The "num_dirty" field is a performance hint for KVM to determine whether it |
| 1569 | should skip processing the bitmap and just invalidate everything. It must |
| 1570 | be set to the number of set bits in the bitmap. |
| 1571 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1572 | |
| 1573 | 4.61 KVM_ASSIGN_SET_INTX_MASK |
Jan Kiszka | 07700a9 | 2012-02-28 14:19:54 +0100 | [diff] [blame] | 1574 | |
| 1575 | Capability: KVM_CAP_PCI_2_3 |
| 1576 | Architectures: x86 |
| 1577 | Type: vm ioctl |
| 1578 | Parameters: struct kvm_assigned_pci_dev (in) |
| 1579 | Returns: 0 on success, -1 on error |
| 1580 | |
| 1581 | Allows userspace to mask PCI INTx interrupts from the assigned device. The |
| 1582 | kernel will not deliver INTx interrupts to the guest between setting and |
| 1583 | clearing of KVM_ASSIGN_SET_INTX_MASK via this interface. This enables use of |
| 1584 | and emulation of PCI 2.3 INTx disable command register behavior. |
| 1585 | |
| 1586 | This may be used for both PCI 2.3 devices supporting INTx disable natively and |
| 1587 | older devices lacking this support. Userspace is responsible for emulating the |
| 1588 | read value of the INTx disable bit in the guest visible PCI command register. |
| 1589 | When modifying the INTx disable state, userspace should precede updating the |
| 1590 | physical device command register by calling this ioctl to inform the kernel of |
| 1591 | the new intended INTx mask state. |
| 1592 | |
| 1593 | Note that the kernel uses the device INTx disable bit to internally manage the |
| 1594 | device interrupt state for PCI 2.3 devices. Reads of this register may |
| 1595 | therefore not match the expected value. Writes should always use the guest |
| 1596 | intended INTx disable value rather than attempting to read-copy-update the |
| 1597 | current physical device state. Races between user and kernel updates to the |
| 1598 | INTx disable bit are handled lazily in the kernel. It's possible the device |
| 1599 | may generate unintended interrupts, but they will not be injected into the |
| 1600 | guest. |
| 1601 | |
| 1602 | See KVM_ASSIGN_DEV_IRQ for the data structure. The target device is specified |
| 1603 | by assigned_dev_id. In the flags field, only KVM_DEV_ASSIGN_MASK_INTX is |
| 1604 | evaluated. |
| 1605 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1606 | |
David Gibson | 54738c0 | 2011-06-29 00:22:41 +0000 | [diff] [blame] | 1607 | 4.62 KVM_CREATE_SPAPR_TCE |
| 1608 | |
| 1609 | Capability: KVM_CAP_SPAPR_TCE |
| 1610 | Architectures: powerpc |
| 1611 | Type: vm ioctl |
| 1612 | Parameters: struct kvm_create_spapr_tce (in) |
| 1613 | Returns: file descriptor for manipulating the created TCE table |
| 1614 | |
| 1615 | This creates a virtual TCE (translation control entry) table, which |
| 1616 | is an IOMMU for PAPR-style virtual I/O. It is used to translate |
| 1617 | logical addresses used in virtual I/O into guest physical addresses, |
| 1618 | and provides a scatter/gather capability for PAPR virtual I/O. |
| 1619 | |
| 1620 | /* for KVM_CAP_SPAPR_TCE */ |
| 1621 | struct kvm_create_spapr_tce { |
| 1622 | __u64 liobn; |
| 1623 | __u32 window_size; |
| 1624 | }; |
| 1625 | |
| 1626 | The liobn field gives the logical IO bus number for which to create a |
| 1627 | TCE table. The window_size field specifies the size of the DMA window |
| 1628 | which this TCE table will translate - the table will contain one 64 |
| 1629 | bit TCE entry for every 4kiB of the DMA window. |
| 1630 | |
| 1631 | When the guest issues an H_PUT_TCE hcall on a liobn for which a TCE |
| 1632 | table has been created using this ioctl(), the kernel will handle it |
| 1633 | in real mode, updating the TCE table. H_PUT_TCE calls for other |
| 1634 | liobns will cause a vm exit and must be handled by userspace. |
| 1635 | |
| 1636 | The return value is a file descriptor which can be passed to mmap(2) |
| 1637 | to map the created TCE table into userspace. This lets userspace read |
| 1638 | the entries written by kernel-handled H_PUT_TCE calls, and also lets |
| 1639 | userspace update the TCE table directly which is useful in some |
| 1640 | circumstances. |
| 1641 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1642 | |
Paul Mackerras | aa04b4c | 2011-06-29 00:25:44 +0000 | [diff] [blame] | 1643 | 4.63 KVM_ALLOCATE_RMA |
| 1644 | |
| 1645 | Capability: KVM_CAP_PPC_RMA |
| 1646 | Architectures: powerpc |
| 1647 | Type: vm ioctl |
| 1648 | Parameters: struct kvm_allocate_rma (out) |
| 1649 | Returns: file descriptor for mapping the allocated RMA |
| 1650 | |
| 1651 | This allocates a Real Mode Area (RMA) from the pool allocated at boot |
| 1652 | time by the kernel. An RMA is a physically-contiguous, aligned region |
| 1653 | of memory used on older POWER processors to provide the memory which |
| 1654 | will be accessed by real-mode (MMU off) accesses in a KVM guest. |
| 1655 | POWER processors support a set of sizes for the RMA that usually |
| 1656 | includes 64MB, 128MB, 256MB and some larger powers of two. |
| 1657 | |
| 1658 | /* for KVM_ALLOCATE_RMA */ |
| 1659 | struct kvm_allocate_rma { |
| 1660 | __u64 rma_size; |
| 1661 | }; |
| 1662 | |
| 1663 | The return value is a file descriptor which can be passed to mmap(2) |
| 1664 | to map the allocated RMA into userspace. The mapped area can then be |
| 1665 | passed to the KVM_SET_USER_MEMORY_REGION ioctl to establish it as the |
| 1666 | RMA for a virtual machine. The size of the RMA in bytes (which is |
| 1667 | fixed at host kernel boot time) is returned in the rma_size field of |
| 1668 | the argument structure. |
| 1669 | |
| 1670 | The KVM_CAP_PPC_RMA capability is 1 or 2 if the KVM_ALLOCATE_RMA ioctl |
| 1671 | is supported; 2 if the processor requires all virtual machines to have |
| 1672 | an RMA, or 1 if the processor can use an RMA but doesn't require it, |
| 1673 | because it supports the Virtual RMA (VRMA) facility. |
| 1674 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1675 | |
Avi Kivity | 3f745f1 | 2011-12-07 12:42:47 +0200 | [diff] [blame] | 1676 | 4.64 KVM_NMI |
| 1677 | |
| 1678 | Capability: KVM_CAP_USER_NMI |
| 1679 | Architectures: x86 |
| 1680 | Type: vcpu ioctl |
| 1681 | Parameters: none |
| 1682 | Returns: 0 on success, -1 on error |
| 1683 | |
| 1684 | Queues an NMI on the thread's vcpu. Note this is well defined only |
| 1685 | when KVM_CREATE_IRQCHIP has not been called, since this is an interface |
| 1686 | between the virtual cpu core and virtual local APIC. After KVM_CREATE_IRQCHIP |
| 1687 | has been called, this interface is completely emulated within the kernel. |
| 1688 | |
| 1689 | To use this to emulate the LINT1 input with KVM_CREATE_IRQCHIP, use the |
| 1690 | following algorithm: |
| 1691 | |
| 1692 | - pause the vpcu |
| 1693 | - read the local APIC's state (KVM_GET_LAPIC) |
| 1694 | - check whether changing LINT1 will queue an NMI (see the LVT entry for LINT1) |
| 1695 | - if so, issue KVM_NMI |
| 1696 | - resume the vcpu |
| 1697 | |
| 1698 | Some guests configure the LINT1 NMI input to cause a panic, aiding in |
| 1699 | debugging. |
| 1700 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1701 | |
Alexander Graf | e24ed81 | 2011-09-14 10:02:41 +0200 | [diff] [blame] | 1702 | 4.65 KVM_S390_UCAS_MAP |
Carsten Otte | 27e0393 | 2012-01-04 10:25:21 +0100 | [diff] [blame] | 1703 | |
| 1704 | Capability: KVM_CAP_S390_UCONTROL |
| 1705 | Architectures: s390 |
| 1706 | Type: vcpu ioctl |
| 1707 | Parameters: struct kvm_s390_ucas_mapping (in) |
| 1708 | Returns: 0 in case of success |
| 1709 | |
| 1710 | The parameter is defined like this: |
| 1711 | struct kvm_s390_ucas_mapping { |
| 1712 | __u64 user_addr; |
| 1713 | __u64 vcpu_addr; |
| 1714 | __u64 length; |
| 1715 | }; |
| 1716 | |
| 1717 | This ioctl maps the memory at "user_addr" with the length "length" to |
| 1718 | 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] | 1719 | be aligned by 1 megabyte. |
Carsten Otte | 27e0393 | 2012-01-04 10:25:21 +0100 | [diff] [blame] | 1720 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1721 | |
Alexander Graf | e24ed81 | 2011-09-14 10:02:41 +0200 | [diff] [blame] | 1722 | 4.66 KVM_S390_UCAS_UNMAP |
Carsten Otte | 27e0393 | 2012-01-04 10:25:21 +0100 | [diff] [blame] | 1723 | |
| 1724 | Capability: KVM_CAP_S390_UCONTROL |
| 1725 | Architectures: s390 |
| 1726 | Type: vcpu ioctl |
| 1727 | Parameters: struct kvm_s390_ucas_mapping (in) |
| 1728 | Returns: 0 in case of success |
| 1729 | |
| 1730 | The parameter is defined like this: |
| 1731 | struct kvm_s390_ucas_mapping { |
| 1732 | __u64 user_addr; |
| 1733 | __u64 vcpu_addr; |
| 1734 | __u64 length; |
| 1735 | }; |
| 1736 | |
| 1737 | This ioctl unmaps the memory in the vcpu's address space starting at |
| 1738 | "vcpu_addr" with the length "length". The field "user_addr" is ignored. |
Anatol Pomozov | f884ab1 | 2013-05-08 16:56:16 -0700 | [diff] [blame] | 1739 | All parameters need to be aligned by 1 megabyte. |
Carsten Otte | 27e0393 | 2012-01-04 10:25:21 +0100 | [diff] [blame] | 1740 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1741 | |
Alexander Graf | e24ed81 | 2011-09-14 10:02:41 +0200 | [diff] [blame] | 1742 | 4.67 KVM_S390_VCPU_FAULT |
Carsten Otte | ccc7910 | 2012-01-04 10:25:26 +0100 | [diff] [blame] | 1743 | |
| 1744 | Capability: KVM_CAP_S390_UCONTROL |
| 1745 | Architectures: s390 |
| 1746 | Type: vcpu ioctl |
| 1747 | Parameters: vcpu absolute address (in) |
| 1748 | Returns: 0 in case of success |
| 1749 | |
| 1750 | This call creates a page table entry on the virtual cpu's address space |
| 1751 | (for user controlled virtual machines) or the virtual machine's address |
| 1752 | space (for regular virtual machines). This only works for minor faults, |
| 1753 | thus it's recommended to access subject memory page via the user page |
| 1754 | table upfront. This is useful to handle validity intercepts for user |
| 1755 | controlled virtual machines to fault in the virtual cpu's lowcore pages |
| 1756 | prior to calling the KVM_RUN ioctl. |
| 1757 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1758 | |
Alexander Graf | e24ed81 | 2011-09-14 10:02:41 +0200 | [diff] [blame] | 1759 | 4.68 KVM_SET_ONE_REG |
| 1760 | |
| 1761 | Capability: KVM_CAP_ONE_REG |
| 1762 | Architectures: all |
| 1763 | Type: vcpu ioctl |
| 1764 | Parameters: struct kvm_one_reg (in) |
| 1765 | Returns: 0 on success, negative value on failure |
| 1766 | |
| 1767 | struct kvm_one_reg { |
| 1768 | __u64 id; |
| 1769 | __u64 addr; |
| 1770 | }; |
| 1771 | |
| 1772 | Using this ioctl, a single vcpu register can be set to a specific value |
| 1773 | defined by user space with the passed in struct kvm_one_reg, where id |
| 1774 | refers to the register identifier as described below and addr is a pointer |
| 1775 | to a variable with the respective size. There can be architecture agnostic |
| 1776 | and architecture specific registers. Each have their own range of operation |
| 1777 | and their own constants and width. To keep track of the implemented |
| 1778 | registers, find a list below: |
| 1779 | |
| 1780 | Arch | Register | Width (bits) |
| 1781 | | | |
Alexander Graf | 1022fc3 | 2011-09-14 21:45:23 +0200 | [diff] [blame] | 1782 | PPC | KVM_REG_PPC_HIOR | 64 |
Bharat Bhushan | 2e23270 | 2012-08-15 17:37:13 +0000 | [diff] [blame] | 1783 | PPC | KVM_REG_PPC_IAC1 | 64 |
| 1784 | PPC | KVM_REG_PPC_IAC2 | 64 |
| 1785 | PPC | KVM_REG_PPC_IAC3 | 64 |
| 1786 | PPC | KVM_REG_PPC_IAC4 | 64 |
| 1787 | PPC | KVM_REG_PPC_DAC1 | 64 |
| 1788 | PPC | KVM_REG_PPC_DAC2 | 64 |
Paul Mackerras | a136a8b | 2012-09-25 20:31:56 +0000 | [diff] [blame] | 1789 | PPC | KVM_REG_PPC_DABR | 64 |
| 1790 | PPC | KVM_REG_PPC_DSCR | 64 |
| 1791 | PPC | KVM_REG_PPC_PURR | 64 |
| 1792 | PPC | KVM_REG_PPC_SPURR | 64 |
| 1793 | PPC | KVM_REG_PPC_DAR | 64 |
| 1794 | PPC | KVM_REG_PPC_DSISR | 32 |
| 1795 | PPC | KVM_REG_PPC_AMR | 64 |
| 1796 | PPC | KVM_REG_PPC_UAMOR | 64 |
| 1797 | PPC | KVM_REG_PPC_MMCR0 | 64 |
| 1798 | PPC | KVM_REG_PPC_MMCR1 | 64 |
| 1799 | PPC | KVM_REG_PPC_MMCRA | 64 |
Paul Mackerras | 2f9c694 | 2014-05-26 19:48:34 +1000 | [diff] [blame] | 1800 | PPC | KVM_REG_PPC_MMCR2 | 64 |
| 1801 | PPC | KVM_REG_PPC_MMCRS | 64 |
| 1802 | PPC | KVM_REG_PPC_SIAR | 64 |
| 1803 | PPC | KVM_REG_PPC_SDAR | 64 |
| 1804 | PPC | KVM_REG_PPC_SIER | 64 |
Paul Mackerras | a136a8b | 2012-09-25 20:31:56 +0000 | [diff] [blame] | 1805 | PPC | KVM_REG_PPC_PMC1 | 32 |
| 1806 | PPC | KVM_REG_PPC_PMC2 | 32 |
| 1807 | PPC | KVM_REG_PPC_PMC3 | 32 |
| 1808 | PPC | KVM_REG_PPC_PMC4 | 32 |
| 1809 | PPC | KVM_REG_PPC_PMC5 | 32 |
| 1810 | PPC | KVM_REG_PPC_PMC6 | 32 |
| 1811 | PPC | KVM_REG_PPC_PMC7 | 32 |
| 1812 | PPC | KVM_REG_PPC_PMC8 | 32 |
Paul Mackerras | a8bd19e | 2012-09-25 20:32:30 +0000 | [diff] [blame] | 1813 | PPC | KVM_REG_PPC_FPR0 | 64 |
| 1814 | ... |
| 1815 | PPC | KVM_REG_PPC_FPR31 | 64 |
| 1816 | PPC | KVM_REG_PPC_VR0 | 128 |
| 1817 | ... |
| 1818 | PPC | KVM_REG_PPC_VR31 | 128 |
| 1819 | PPC | KVM_REG_PPC_VSR0 | 128 |
| 1820 | ... |
| 1821 | PPC | KVM_REG_PPC_VSR31 | 128 |
| 1822 | PPC | KVM_REG_PPC_FPSCR | 64 |
| 1823 | PPC | KVM_REG_PPC_VSCR | 32 |
Paul Mackerras | 55b665b | 2012-09-25 20:33:06 +0000 | [diff] [blame] | 1824 | PPC | KVM_REG_PPC_VPA_ADDR | 64 |
| 1825 | PPC | KVM_REG_PPC_VPA_SLB | 128 |
| 1826 | PPC | KVM_REG_PPC_VPA_DTL | 128 |
Mihai Caraman | 352df1d | 2012-10-11 06:13:29 +0000 | [diff] [blame] | 1827 | PPC | KVM_REG_PPC_EPCR | 32 |
Alexander Graf | 324b3e6 | 2013-01-04 18:28:51 +0100 | [diff] [blame] | 1828 | PPC | KVM_REG_PPC_EPR | 32 |
Bharat Bhushan | 78accda | 2013-02-24 18:57:12 +0000 | [diff] [blame] | 1829 | PPC | KVM_REG_PPC_TCR | 32 |
| 1830 | PPC | KVM_REG_PPC_TSR | 32 |
| 1831 | PPC | KVM_REG_PPC_OR_TSR | 32 |
| 1832 | PPC | KVM_REG_PPC_CLEAR_TSR | 32 |
Mihai Caraman | a85d2aa | 2013-04-11 00:03:08 +0000 | [diff] [blame] | 1833 | PPC | KVM_REG_PPC_MAS0 | 32 |
| 1834 | PPC | KVM_REG_PPC_MAS1 | 32 |
| 1835 | PPC | KVM_REG_PPC_MAS2 | 64 |
| 1836 | PPC | KVM_REG_PPC_MAS7_3 | 64 |
| 1837 | PPC | KVM_REG_PPC_MAS4 | 32 |
| 1838 | PPC | KVM_REG_PPC_MAS6 | 32 |
| 1839 | PPC | KVM_REG_PPC_MMUCFG | 32 |
| 1840 | PPC | KVM_REG_PPC_TLB0CFG | 32 |
| 1841 | PPC | KVM_REG_PPC_TLB1CFG | 32 |
| 1842 | PPC | KVM_REG_PPC_TLB2CFG | 32 |
| 1843 | PPC | KVM_REG_PPC_TLB3CFG | 32 |
Mihai Caraman | 307d900 | 2013-04-11 00:03:10 +0000 | [diff] [blame] | 1844 | PPC | KVM_REG_PPC_TLB0PS | 32 |
| 1845 | PPC | KVM_REG_PPC_TLB1PS | 32 |
| 1846 | PPC | KVM_REG_PPC_TLB2PS | 32 |
| 1847 | PPC | KVM_REG_PPC_TLB3PS | 32 |
Mihai Caraman | 9a6061d | 2013-04-11 00:03:11 +0000 | [diff] [blame] | 1848 | PPC | KVM_REG_PPC_EPTCFG | 32 |
Paul Mackerras | 8b78645 | 2013-04-17 20:32:26 +0000 | [diff] [blame] | 1849 | PPC | KVM_REG_PPC_ICP_STATE | 64 |
Paul Mackerras | 93b0f4d | 2013-09-06 13:17:46 +1000 | [diff] [blame] | 1850 | PPC | KVM_REG_PPC_TB_OFFSET | 64 |
Michael Neuling | 3b78347 | 2013-09-03 11:13:12 +1000 | [diff] [blame] | 1851 | PPC | KVM_REG_PPC_SPMC1 | 32 |
| 1852 | PPC | KVM_REG_PPC_SPMC2 | 32 |
| 1853 | PPC | KVM_REG_PPC_IAMR | 64 |
| 1854 | PPC | KVM_REG_PPC_TFHAR | 64 |
| 1855 | PPC | KVM_REG_PPC_TFIAR | 64 |
| 1856 | PPC | KVM_REG_PPC_TEXASR | 64 |
| 1857 | PPC | KVM_REG_PPC_FSCR | 64 |
| 1858 | PPC | KVM_REG_PPC_PSPB | 32 |
| 1859 | PPC | KVM_REG_PPC_EBBHR | 64 |
| 1860 | PPC | KVM_REG_PPC_EBBRR | 64 |
| 1861 | PPC | KVM_REG_PPC_BESCR | 64 |
| 1862 | PPC | KVM_REG_PPC_TAR | 64 |
| 1863 | PPC | KVM_REG_PPC_DPDES | 64 |
| 1864 | PPC | KVM_REG_PPC_DAWR | 64 |
| 1865 | PPC | KVM_REG_PPC_DAWRX | 64 |
| 1866 | PPC | KVM_REG_PPC_CIABR | 64 |
| 1867 | PPC | KVM_REG_PPC_IC | 64 |
| 1868 | PPC | KVM_REG_PPC_VTB | 64 |
| 1869 | PPC | KVM_REG_PPC_CSIGR | 64 |
| 1870 | PPC | KVM_REG_PPC_TACR | 64 |
| 1871 | PPC | KVM_REG_PPC_TCSCR | 64 |
| 1872 | PPC | KVM_REG_PPC_PID | 64 |
| 1873 | PPC | KVM_REG_PPC_ACOP | 64 |
Paul Mackerras | c0867fd | 2013-09-06 13:18:32 +1000 | [diff] [blame] | 1874 | PPC | KVM_REG_PPC_VRSAVE | 32 |
Alexey Kardashevskiy | a084024 | 2014-07-19 17:59:34 +1000 | [diff] [blame] | 1875 | PPC | KVM_REG_PPC_LPCR | 32 |
| 1876 | PPC | KVM_REG_PPC_LPCR_64 | 64 |
Paul Mackerras | 4b8473c | 2013-09-20 14:52:39 +1000 | [diff] [blame] | 1877 | PPC | KVM_REG_PPC_PPR | 64 |
Paul Mackerras | 388cc6e | 2013-09-21 14:35:02 +1000 | [diff] [blame] | 1878 | PPC | KVM_REG_PPC_ARCH_COMPAT 32 |
Paul Mackerras | 8563bf5 | 2014-01-08 21:25:29 +1100 | [diff] [blame] | 1879 | PPC | KVM_REG_PPC_DABRX | 32 |
Paul Mackerras | e1d8a96 | 2014-05-26 19:48:35 +1000 | [diff] [blame] | 1880 | PPC | KVM_REG_PPC_WORT | 64 |
Michael Neuling | 3b78347 | 2013-09-03 11:13:12 +1000 | [diff] [blame] | 1881 | PPC | KVM_REG_PPC_TM_GPR0 | 64 |
| 1882 | ... |
| 1883 | PPC | KVM_REG_PPC_TM_GPR31 | 64 |
| 1884 | PPC | KVM_REG_PPC_TM_VSR0 | 128 |
| 1885 | ... |
| 1886 | PPC | KVM_REG_PPC_TM_VSR63 | 128 |
| 1887 | PPC | KVM_REG_PPC_TM_CR | 64 |
| 1888 | PPC | KVM_REG_PPC_TM_LR | 64 |
| 1889 | PPC | KVM_REG_PPC_TM_CTR | 64 |
| 1890 | PPC | KVM_REG_PPC_TM_FPSCR | 64 |
| 1891 | PPC | KVM_REG_PPC_TM_AMR | 64 |
| 1892 | PPC | KVM_REG_PPC_TM_PPR | 64 |
| 1893 | PPC | KVM_REG_PPC_TM_VRSAVE | 64 |
| 1894 | PPC | KVM_REG_PPC_TM_VSCR | 32 |
| 1895 | PPC | KVM_REG_PPC_TM_DSCR | 64 |
| 1896 | PPC | KVM_REG_PPC_TM_TAR | 64 |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1897 | |
Christoffer Dall | 749cf76c | 2013-01-20 18:28:06 -0500 | [diff] [blame] | 1898 | ARM registers are mapped using the lower 32 bits. The upper 16 of that |
| 1899 | is the register group type, or coprocessor number: |
| 1900 | |
| 1901 | ARM core registers have the following id bit patterns: |
Christoffer Dall | aa404dd | 2013-04-22 18:57:46 -0700 | [diff] [blame] | 1902 | 0x4020 0000 0010 <index into the kvm_regs struct:16> |
Christoffer Dall | 749cf76c | 2013-01-20 18:28:06 -0500 | [diff] [blame] | 1903 | |
Christoffer Dall | 1138245 | 2013-01-20 18:28:10 -0500 | [diff] [blame] | 1904 | ARM 32-bit CP15 registers have the following id bit patterns: |
Christoffer Dall | aa404dd | 2013-04-22 18:57:46 -0700 | [diff] [blame] | 1905 | 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] | 1906 | |
| 1907 | ARM 64-bit CP15 registers have the following id bit patterns: |
Christoffer Dall | aa404dd | 2013-04-22 18:57:46 -0700 | [diff] [blame] | 1908 | 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] | 1909 | |
Christoffer Dall | c27581e | 2013-01-20 18:28:10 -0500 | [diff] [blame] | 1910 | ARM CCSIDR registers are demultiplexed by CSSELR value: |
Christoffer Dall | aa404dd | 2013-04-22 18:57:46 -0700 | [diff] [blame] | 1911 | 0x4020 0000 0011 00 <csselr:8> |
Christoffer Dall | 749cf76c | 2013-01-20 18:28:06 -0500 | [diff] [blame] | 1912 | |
Rusty Russell | 4fe21e4 | 2013-01-20 18:28:11 -0500 | [diff] [blame] | 1913 | ARM 32-bit VFP control registers have the following id bit patterns: |
Christoffer Dall | aa404dd | 2013-04-22 18:57:46 -0700 | [diff] [blame] | 1914 | 0x4020 0000 0012 1 <regno:12> |
Rusty Russell | 4fe21e4 | 2013-01-20 18:28:11 -0500 | [diff] [blame] | 1915 | |
| 1916 | ARM 64-bit FP registers have the following id bit patterns: |
Christoffer Dall | aa404dd | 2013-04-22 18:57:46 -0700 | [diff] [blame] | 1917 | 0x4030 0000 0012 0 <regno:12> |
Rusty Russell | 4fe21e4 | 2013-01-20 18:28:11 -0500 | [diff] [blame] | 1918 | |
Marc Zyngier | 379e04c7 | 2013-04-02 17:46:31 +0100 | [diff] [blame] | 1919 | |
| 1920 | arm64 registers are mapped using the lower 32 bits. The upper 16 of |
| 1921 | that is the register group type, or coprocessor number: |
| 1922 | |
| 1923 | arm64 core/FP-SIMD registers have the following id bit patterns. Note |
| 1924 | that the size of the access is variable, as the kvm_regs structure |
| 1925 | contains elements ranging from 32 to 128 bits. The index is a 32bit |
| 1926 | value in the kvm_regs structure seen as a 32bit array. |
| 1927 | 0x60x0 0000 0010 <index into the kvm_regs struct:16> |
| 1928 | |
| 1929 | arm64 CCSIDR registers are demultiplexed by CSSELR value: |
| 1930 | 0x6020 0000 0011 00 <csselr:8> |
| 1931 | |
| 1932 | arm64 system registers have the following id bit patterns: |
| 1933 | 0x6030 0000 0013 <op0:2> <op1:3> <crn:4> <crm:4> <op2:3> |
| 1934 | |
Alexander Graf | e24ed81 | 2011-09-14 10:02:41 +0200 | [diff] [blame] | 1935 | 4.69 KVM_GET_ONE_REG |
| 1936 | |
| 1937 | Capability: KVM_CAP_ONE_REG |
| 1938 | Architectures: all |
| 1939 | Type: vcpu ioctl |
| 1940 | Parameters: struct kvm_one_reg (in and out) |
| 1941 | Returns: 0 on success, negative value on failure |
| 1942 | |
| 1943 | This ioctl allows to receive the value of a single register implemented |
| 1944 | in a vcpu. The register to read is indicated by the "id" field of the |
| 1945 | kvm_one_reg struct passed in. On success, the register value can be found |
| 1946 | at the memory location pointed to by "addr". |
| 1947 | |
| 1948 | The list of registers accessible using this interface is identical to the |
Bharat Bhushan | 2e23270 | 2012-08-15 17:37:13 +0000 | [diff] [blame] | 1949 | list in 4.68. |
Alexander Graf | e24ed81 | 2011-09-14 10:02:41 +0200 | [diff] [blame] | 1950 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1951 | |
Eric B Munson | 1c0b28c | 2012-03-10 14:37:27 -0500 | [diff] [blame] | 1952 | 4.70 KVM_KVMCLOCK_CTRL |
| 1953 | |
| 1954 | Capability: KVM_CAP_KVMCLOCK_CTRL |
| 1955 | Architectures: Any that implement pvclocks (currently x86 only) |
| 1956 | Type: vcpu ioctl |
| 1957 | Parameters: None |
| 1958 | Returns: 0 on success, -1 on error |
| 1959 | |
| 1960 | This signals to the host kernel that the specified guest is being paused by |
| 1961 | userspace. The host will set a flag in the pvclock structure that is checked |
| 1962 | from the soft lockup watchdog. The flag is part of the pvclock structure that |
| 1963 | is shared between guest and host, specifically the second bit of the flags |
| 1964 | field of the pvclock_vcpu_time_info structure. It will be set exclusively by |
| 1965 | the host and read/cleared exclusively by the guest. The guest operation of |
| 1966 | checking and clearing the flag must an atomic operation so |
| 1967 | load-link/store-conditional, or equivalent must be used. There are two cases |
| 1968 | where the guest will clear the flag: when the soft lockup watchdog timer resets |
| 1969 | itself or when a soft lockup is detected. This ioctl can be called any time |
| 1970 | after pausing the vcpu, but before it is resumed. |
| 1971 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1972 | |
Jan Kiszka | 07975ad | 2012-03-29 21:14:12 +0200 | [diff] [blame] | 1973 | 4.71 KVM_SIGNAL_MSI |
| 1974 | |
| 1975 | Capability: KVM_CAP_SIGNAL_MSI |
| 1976 | Architectures: x86 |
| 1977 | Type: vm ioctl |
| 1978 | Parameters: struct kvm_msi (in) |
| 1979 | Returns: >0 on delivery, 0 if guest blocked the MSI, and -1 on error |
| 1980 | |
| 1981 | Directly inject a MSI message. Only valid with in-kernel irqchip that handles |
| 1982 | MSI messages. |
| 1983 | |
| 1984 | struct kvm_msi { |
| 1985 | __u32 address_lo; |
| 1986 | __u32 address_hi; |
| 1987 | __u32 data; |
| 1988 | __u32 flags; |
| 1989 | __u8 pad[16]; |
| 1990 | }; |
| 1991 | |
| 1992 | No flags are defined so far. The corresponding field must be 0. |
| 1993 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 1994 | |
Jan Kiszka | 0589ff6 | 2012-04-24 16:40:16 +0200 | [diff] [blame] | 1995 | 4.71 KVM_CREATE_PIT2 |
| 1996 | |
| 1997 | Capability: KVM_CAP_PIT2 |
| 1998 | Architectures: x86 |
| 1999 | Type: vm ioctl |
| 2000 | Parameters: struct kvm_pit_config (in) |
| 2001 | Returns: 0 on success, -1 on error |
| 2002 | |
| 2003 | Creates an in-kernel device model for the i8254 PIT. This call is only valid |
| 2004 | after enabling in-kernel irqchip support via KVM_CREATE_IRQCHIP. The following |
| 2005 | parameters have to be passed: |
| 2006 | |
| 2007 | struct kvm_pit_config { |
| 2008 | __u32 flags; |
| 2009 | __u32 pad[15]; |
| 2010 | }; |
| 2011 | |
| 2012 | Valid flags are: |
| 2013 | |
| 2014 | #define KVM_PIT_SPEAKER_DUMMY 1 /* emulate speaker port stub */ |
| 2015 | |
Jan Kiszka | b6ddf05 | 2012-04-24 16:40:17 +0200 | [diff] [blame] | 2016 | PIT timer interrupts may use a per-VM kernel thread for injection. If it |
| 2017 | exists, this thread will have a name of the following pattern: |
| 2018 | |
| 2019 | kvm-pit/<owner-process-pid> |
| 2020 | |
| 2021 | When running a guest with elevated priorities, the scheduling parameters of |
| 2022 | this thread may have to be adjusted accordingly. |
| 2023 | |
Jan Kiszka | 0589ff6 | 2012-04-24 16:40:16 +0200 | [diff] [blame] | 2024 | This IOCTL replaces the obsolete KVM_CREATE_PIT. |
| 2025 | |
| 2026 | |
| 2027 | 4.72 KVM_GET_PIT2 |
| 2028 | |
| 2029 | Capability: KVM_CAP_PIT_STATE2 |
| 2030 | Architectures: x86 |
| 2031 | Type: vm ioctl |
| 2032 | Parameters: struct kvm_pit_state2 (out) |
| 2033 | Returns: 0 on success, -1 on error |
| 2034 | |
| 2035 | Retrieves the state of the in-kernel PIT model. Only valid after |
| 2036 | KVM_CREATE_PIT2. The state is returned in the following structure: |
| 2037 | |
| 2038 | struct kvm_pit_state2 { |
| 2039 | struct kvm_pit_channel_state channels[3]; |
| 2040 | __u32 flags; |
| 2041 | __u32 reserved[9]; |
| 2042 | }; |
| 2043 | |
| 2044 | Valid flags are: |
| 2045 | |
| 2046 | /* disable PIT in HPET legacy mode */ |
| 2047 | #define KVM_PIT_FLAGS_HPET_LEGACY 0x00000001 |
| 2048 | |
| 2049 | This IOCTL replaces the obsolete KVM_GET_PIT. |
| 2050 | |
| 2051 | |
| 2052 | 4.73 KVM_SET_PIT2 |
| 2053 | |
| 2054 | Capability: KVM_CAP_PIT_STATE2 |
| 2055 | Architectures: x86 |
| 2056 | Type: vm ioctl |
| 2057 | Parameters: struct kvm_pit_state2 (in) |
| 2058 | Returns: 0 on success, -1 on error |
| 2059 | |
| 2060 | Sets the state of the in-kernel PIT model. Only valid after KVM_CREATE_PIT2. |
| 2061 | See KVM_GET_PIT2 for details on struct kvm_pit_state2. |
| 2062 | |
| 2063 | This IOCTL replaces the obsolete KVM_SET_PIT. |
| 2064 | |
| 2065 | |
Benjamin Herrenschmidt | 5b74716 | 2012-04-26 19:43:42 +0000 | [diff] [blame] | 2066 | 4.74 KVM_PPC_GET_SMMU_INFO |
| 2067 | |
| 2068 | Capability: KVM_CAP_PPC_GET_SMMU_INFO |
| 2069 | Architectures: powerpc |
| 2070 | Type: vm ioctl |
| 2071 | Parameters: None |
| 2072 | Returns: 0 on success, -1 on error |
| 2073 | |
| 2074 | This populates and returns a structure describing the features of |
| 2075 | the "Server" class MMU emulation supported by KVM. |
Stefan Huber | cc22c35 | 2013-06-05 12:24:37 +0200 | [diff] [blame] | 2076 | This can in turn be used by userspace to generate the appropriate |
Benjamin Herrenschmidt | 5b74716 | 2012-04-26 19:43:42 +0000 | [diff] [blame] | 2077 | device-tree properties for the guest operating system. |
| 2078 | |
Carlos Garcia | c98be0c | 2014-04-04 22:31:00 -0400 | [diff] [blame] | 2079 | The structure contains some global information, followed by an |
Benjamin Herrenschmidt | 5b74716 | 2012-04-26 19:43:42 +0000 | [diff] [blame] | 2080 | array of supported segment page sizes: |
| 2081 | |
| 2082 | struct kvm_ppc_smmu_info { |
| 2083 | __u64 flags; |
| 2084 | __u32 slb_size; |
| 2085 | __u32 pad; |
| 2086 | struct kvm_ppc_one_seg_page_size sps[KVM_PPC_PAGE_SIZES_MAX_SZ]; |
| 2087 | }; |
| 2088 | |
| 2089 | The supported flags are: |
| 2090 | |
| 2091 | - KVM_PPC_PAGE_SIZES_REAL: |
| 2092 | When that flag is set, guest page sizes must "fit" the backing |
| 2093 | store page sizes. When not set, any page size in the list can |
| 2094 | be used regardless of how they are backed by userspace. |
| 2095 | |
| 2096 | - KVM_PPC_1T_SEGMENTS |
| 2097 | The emulated MMU supports 1T segments in addition to the |
| 2098 | standard 256M ones. |
| 2099 | |
| 2100 | The "slb_size" field indicates how many SLB entries are supported |
| 2101 | |
| 2102 | The "sps" array contains 8 entries indicating the supported base |
| 2103 | page sizes for a segment in increasing order. Each entry is defined |
| 2104 | as follow: |
| 2105 | |
| 2106 | struct kvm_ppc_one_seg_page_size { |
| 2107 | __u32 page_shift; /* Base page shift of segment (or 0) */ |
| 2108 | __u32 slb_enc; /* SLB encoding for BookS */ |
| 2109 | struct kvm_ppc_one_page_size enc[KVM_PPC_PAGE_SIZES_MAX_SZ]; |
| 2110 | }; |
| 2111 | |
| 2112 | An entry with a "page_shift" of 0 is unused. Because the array is |
| 2113 | organized in increasing order, a lookup can stop when encoutering |
| 2114 | such an entry. |
| 2115 | |
| 2116 | The "slb_enc" field provides the encoding to use in the SLB for the |
| 2117 | page size. The bits are in positions such as the value can directly |
| 2118 | be OR'ed into the "vsid" argument of the slbmte instruction. |
| 2119 | |
| 2120 | The "enc" array is a list which for each of those segment base page |
| 2121 | size provides the list of supported actual page sizes (which can be |
| 2122 | only larger or equal to the base page size), along with the |
Anatol Pomozov | f884ab1 | 2013-05-08 16:56:16 -0700 | [diff] [blame] | 2123 | corresponding encoding in the hash PTE. Similarly, the array is |
Benjamin Herrenschmidt | 5b74716 | 2012-04-26 19:43:42 +0000 | [diff] [blame] | 2124 | 8 entries sorted by increasing sizes and an entry with a "0" shift |
| 2125 | is an empty entry and a terminator: |
| 2126 | |
| 2127 | struct kvm_ppc_one_page_size { |
| 2128 | __u32 page_shift; /* Page shift (or 0) */ |
| 2129 | __u32 pte_enc; /* Encoding in the HPTE (>>12) */ |
| 2130 | }; |
| 2131 | |
| 2132 | The "pte_enc" field provides a value that can OR'ed into the hash |
| 2133 | PTE's RPN field (ie, it needs to be shifted left by 12 to OR it |
| 2134 | into the hash PTE second double word). |
| 2135 | |
Alex Williamson | f36992e | 2012-06-29 09:56:16 -0600 | [diff] [blame] | 2136 | 4.75 KVM_IRQFD |
| 2137 | |
| 2138 | Capability: KVM_CAP_IRQFD |
Cornelia Huck | ebc3226 | 2014-05-09 15:00:46 +0200 | [diff] [blame] | 2139 | Architectures: x86 s390 |
Alex Williamson | f36992e | 2012-06-29 09:56:16 -0600 | [diff] [blame] | 2140 | Type: vm ioctl |
| 2141 | Parameters: struct kvm_irqfd (in) |
| 2142 | Returns: 0 on success, -1 on error |
| 2143 | |
| 2144 | Allows setting an eventfd to directly trigger a guest interrupt. |
| 2145 | kvm_irqfd.fd specifies the file descriptor to use as the eventfd and |
| 2146 | kvm_irqfd.gsi specifies the irqchip pin toggled by this event. When |
Masanari Iida | 1718003 | 2013-12-22 01:21:23 +0900 | [diff] [blame] | 2147 | an event is triggered on the eventfd, an interrupt is injected into |
Alex Williamson | f36992e | 2012-06-29 09:56:16 -0600 | [diff] [blame] | 2148 | the guest using the specified gsi pin. The irqfd is removed using |
| 2149 | the KVM_IRQFD_FLAG_DEASSIGN flag, specifying both kvm_irqfd.fd |
| 2150 | and kvm_irqfd.gsi. |
| 2151 | |
Alex Williamson | 7a84428 | 2012-09-21 11:58:03 -0600 | [diff] [blame] | 2152 | With KVM_CAP_IRQFD_RESAMPLE, KVM_IRQFD supports a de-assert and notify |
| 2153 | mechanism allowing emulation of level-triggered, irqfd-based |
| 2154 | interrupts. When KVM_IRQFD_FLAG_RESAMPLE is set the user must pass an |
| 2155 | additional eventfd in the kvm_irqfd.resamplefd field. When operating |
| 2156 | in resample mode, posting of an interrupt through kvm_irq.fd asserts |
| 2157 | the specified gsi in the irqchip. When the irqchip is resampled, such |
Masanari Iida | 1718003 | 2013-12-22 01:21:23 +0900 | [diff] [blame] | 2158 | 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] | 2159 | kvm_irqfd.resamplefd. It is the user's responsibility to re-queue |
| 2160 | the interrupt if the device making use of it still requires service. |
| 2161 | Note that closing the resamplefd is not sufficient to disable the |
| 2162 | irqfd. The KVM_IRQFD_FLAG_RESAMPLE is only necessary on assignment |
| 2163 | and need not be specified with KVM_IRQFD_FLAG_DEASSIGN. |
| 2164 | |
Linus Torvalds | 5fecc9d | 2012-07-24 12:01:20 -0700 | [diff] [blame] | 2165 | 4.76 KVM_PPC_ALLOCATE_HTAB |
Paul Mackerras | 32fad28 | 2012-05-04 02:32:53 +0000 | [diff] [blame] | 2166 | |
| 2167 | Capability: KVM_CAP_PPC_ALLOC_HTAB |
| 2168 | Architectures: powerpc |
| 2169 | Type: vm ioctl |
| 2170 | Parameters: Pointer to u32 containing hash table order (in/out) |
| 2171 | Returns: 0 on success, -1 on error |
| 2172 | |
| 2173 | This requests the host kernel to allocate an MMU hash table for a |
| 2174 | guest using the PAPR paravirtualization interface. This only does |
| 2175 | anything if the kernel is configured to use the Book 3S HV style of |
| 2176 | virtualization. Otherwise the capability doesn't exist and the ioctl |
| 2177 | returns an ENOTTY error. The rest of this description assumes Book 3S |
| 2178 | HV. |
| 2179 | |
| 2180 | There must be no vcpus running when this ioctl is called; if there |
| 2181 | are, it will do nothing and return an EBUSY error. |
| 2182 | |
| 2183 | The parameter is a pointer to a 32-bit unsigned integer variable |
| 2184 | containing the order (log base 2) of the desired size of the hash |
| 2185 | table, which must be between 18 and 46. On successful return from the |
| 2186 | ioctl, it will have been updated with the order of the hash table that |
| 2187 | was allocated. |
| 2188 | |
| 2189 | If no hash table has been allocated when any vcpu is asked to run |
| 2190 | (with the KVM_RUN ioctl), the host kernel will allocate a |
| 2191 | default-sized hash table (16 MB). |
| 2192 | |
| 2193 | If this ioctl is called when a hash table has already been allocated, |
| 2194 | the kernel will clear out the existing hash table (zero all HPTEs) and |
| 2195 | return the hash table order in the parameter. (If the guest is using |
| 2196 | the virtualized real-mode area (VRMA) facility, the kernel will |
| 2197 | re-create the VMRA HPTEs on the next KVM_RUN of any vcpu.) |
| 2198 | |
Cornelia Huck | 416ad65 | 2012-10-02 16:25:37 +0200 | [diff] [blame] | 2199 | 4.77 KVM_S390_INTERRUPT |
| 2200 | |
| 2201 | Capability: basic |
| 2202 | Architectures: s390 |
| 2203 | Type: vm ioctl, vcpu ioctl |
| 2204 | Parameters: struct kvm_s390_interrupt (in) |
| 2205 | Returns: 0 on success, -1 on error |
| 2206 | |
| 2207 | Allows to inject an interrupt to the guest. Interrupts can be floating |
| 2208 | (vm ioctl) or per cpu (vcpu ioctl), depending on the interrupt type. |
| 2209 | |
| 2210 | Interrupt parameters are passed via kvm_s390_interrupt: |
| 2211 | |
| 2212 | struct kvm_s390_interrupt { |
| 2213 | __u32 type; |
| 2214 | __u32 parm; |
| 2215 | __u64 parm64; |
| 2216 | }; |
| 2217 | |
| 2218 | type can be one of the following: |
| 2219 | |
| 2220 | KVM_S390_SIGP_STOP (vcpu) - sigp restart |
| 2221 | KVM_S390_PROGRAM_INT (vcpu) - program check; code in parm |
| 2222 | KVM_S390_SIGP_SET_PREFIX (vcpu) - sigp set prefix; prefix address in parm |
| 2223 | KVM_S390_RESTART (vcpu) - restart |
Thomas Huth | e029ae5 | 2014-03-26 16:11:54 +0100 | [diff] [blame] | 2224 | KVM_S390_INT_CLOCK_COMP (vcpu) - clock comparator interrupt |
| 2225 | KVM_S390_INT_CPU_TIMER (vcpu) - CPU timer interrupt |
Cornelia Huck | 416ad65 | 2012-10-02 16:25:37 +0200 | [diff] [blame] | 2226 | KVM_S390_INT_VIRTIO (vm) - virtio external interrupt; external interrupt |
| 2227 | parameters in parm and parm64 |
| 2228 | KVM_S390_INT_SERVICE (vm) - sclp external interrupt; sclp parameter in parm |
| 2229 | KVM_S390_INT_EMERGENCY (vcpu) - sigp emergency; source cpu in parm |
| 2230 | 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] | 2231 | KVM_S390_INT_IO(ai,cssid,ssid,schid) (vm) - compound value to indicate an |
| 2232 | I/O interrupt (ai - adapter interrupt; cssid,ssid,schid - subchannel); |
| 2233 | I/O interruption parameters in parm (subchannel) and parm64 (intparm, |
| 2234 | interruption subclass) |
Cornelia Huck | 48a3e95 | 2012-12-20 15:32:09 +0100 | [diff] [blame] | 2235 | KVM_S390_MCHK (vm, vcpu) - machine check interrupt; cr 14 bits in parm, |
| 2236 | machine check interrupt code in parm64 (note that |
| 2237 | machine checks needing further payload are not |
| 2238 | supported by this ioctl) |
Cornelia Huck | 416ad65 | 2012-10-02 16:25:37 +0200 | [diff] [blame] | 2239 | |
| 2240 | Note that the vcpu ioctl is asynchronous to vcpu execution. |
| 2241 | |
Paul Mackerras | a293292 | 2012-11-19 22:57:20 +0000 | [diff] [blame] | 2242 | 4.78 KVM_PPC_GET_HTAB_FD |
| 2243 | |
| 2244 | Capability: KVM_CAP_PPC_HTAB_FD |
| 2245 | Architectures: powerpc |
| 2246 | Type: vm ioctl |
| 2247 | Parameters: Pointer to struct kvm_get_htab_fd (in) |
| 2248 | Returns: file descriptor number (>= 0) on success, -1 on error |
| 2249 | |
| 2250 | This returns a file descriptor that can be used either to read out the |
| 2251 | entries in the guest's hashed page table (HPT), or to write entries to |
| 2252 | initialize the HPT. The returned fd can only be written to if the |
| 2253 | KVM_GET_HTAB_WRITE bit is set in the flags field of the argument, and |
| 2254 | can only be read if that bit is clear. The argument struct looks like |
| 2255 | this: |
| 2256 | |
| 2257 | /* For KVM_PPC_GET_HTAB_FD */ |
| 2258 | struct kvm_get_htab_fd { |
| 2259 | __u64 flags; |
| 2260 | __u64 start_index; |
| 2261 | __u64 reserved[2]; |
| 2262 | }; |
| 2263 | |
| 2264 | /* Values for kvm_get_htab_fd.flags */ |
| 2265 | #define KVM_GET_HTAB_BOLTED_ONLY ((__u64)0x1) |
| 2266 | #define KVM_GET_HTAB_WRITE ((__u64)0x2) |
| 2267 | |
| 2268 | The `start_index' field gives the index in the HPT of the entry at |
| 2269 | which to start reading. It is ignored when writing. |
| 2270 | |
| 2271 | Reads on the fd will initially supply information about all |
| 2272 | "interesting" HPT entries. Interesting entries are those with the |
| 2273 | bolted bit set, if the KVM_GET_HTAB_BOLTED_ONLY bit is set, otherwise |
| 2274 | all entries. When the end of the HPT is reached, the read() will |
| 2275 | return. If read() is called again on the fd, it will start again from |
| 2276 | the beginning of the HPT, but will only return HPT entries that have |
| 2277 | changed since they were last read. |
| 2278 | |
| 2279 | Data read or written is structured as a header (8 bytes) followed by a |
| 2280 | series of valid HPT entries (16 bytes) each. The header indicates how |
| 2281 | many valid HPT entries there are and how many invalid entries follow |
| 2282 | the valid entries. The invalid entries are not represented explicitly |
| 2283 | in the stream. The header format is: |
| 2284 | |
| 2285 | struct kvm_get_htab_header { |
| 2286 | __u32 index; |
| 2287 | __u16 n_valid; |
| 2288 | __u16 n_invalid; |
| 2289 | }; |
| 2290 | |
| 2291 | Writes to the fd create HPT entries starting at the index given in the |
| 2292 | header; first `n_valid' valid entries with contents from the data |
| 2293 | written, then `n_invalid' invalid entries, invalidating any previously |
| 2294 | valid entries found. |
| 2295 | |
Scott Wood | 852b6d5 | 2013-04-12 14:08:42 +0000 | [diff] [blame] | 2296 | 4.79 KVM_CREATE_DEVICE |
| 2297 | |
| 2298 | Capability: KVM_CAP_DEVICE_CTRL |
| 2299 | Type: vm ioctl |
| 2300 | Parameters: struct kvm_create_device (in/out) |
| 2301 | Returns: 0 on success, -1 on error |
| 2302 | Errors: |
| 2303 | ENODEV: The device type is unknown or unsupported |
| 2304 | EEXIST: Device already created, and this type of device may not |
| 2305 | be instantiated multiple times |
| 2306 | |
| 2307 | Other error conditions may be defined by individual device types or |
| 2308 | have their standard meanings. |
| 2309 | |
| 2310 | Creates an emulated device in the kernel. The file descriptor returned |
| 2311 | in fd can be used with KVM_SET/GET/HAS_DEVICE_ATTR. |
| 2312 | |
| 2313 | If the KVM_CREATE_DEVICE_TEST flag is set, only test whether the |
| 2314 | device type is supported (not necessarily whether it can be created |
| 2315 | in the current vm). |
| 2316 | |
| 2317 | Individual devices should not define flags. Attributes should be used |
| 2318 | for specifying any behavior that is not implied by the device type |
| 2319 | number. |
| 2320 | |
| 2321 | struct kvm_create_device { |
| 2322 | __u32 type; /* in: KVM_DEV_TYPE_xxx */ |
| 2323 | __u32 fd; /* out: device handle */ |
| 2324 | __u32 flags; /* in: KVM_CREATE_DEVICE_xxx */ |
| 2325 | }; |
| 2326 | |
| 2327 | 4.80 KVM_SET_DEVICE_ATTR/KVM_GET_DEVICE_ATTR |
| 2328 | |
Dominik Dingel | f206165 | 2014-04-09 13:13:00 +0200 | [diff] [blame] | 2329 | Capability: KVM_CAP_DEVICE_CTRL, KVM_CAP_VM_ATTRIBUTES for vm device |
| 2330 | Type: device ioctl, vm ioctl |
Scott Wood | 852b6d5 | 2013-04-12 14:08:42 +0000 | [diff] [blame] | 2331 | Parameters: struct kvm_device_attr |
| 2332 | Returns: 0 on success, -1 on error |
| 2333 | Errors: |
| 2334 | ENXIO: The group or attribute is unknown/unsupported for this device |
| 2335 | EPERM: The attribute cannot (currently) be accessed this way |
| 2336 | (e.g. read-only attribute, or attribute that only makes |
| 2337 | sense when the device is in a different state) |
| 2338 | |
| 2339 | Other error conditions may be defined by individual device types. |
| 2340 | |
| 2341 | Gets/sets a specified piece of device configuration and/or state. The |
| 2342 | semantics are device-specific. See individual device documentation in |
| 2343 | the "devices" directory. As with ONE_REG, the size of the data |
| 2344 | transferred is defined by the particular attribute. |
| 2345 | |
| 2346 | struct kvm_device_attr { |
| 2347 | __u32 flags; /* no flags currently defined */ |
| 2348 | __u32 group; /* device-defined */ |
| 2349 | __u64 attr; /* group-defined */ |
| 2350 | __u64 addr; /* userspace address of attr data */ |
| 2351 | }; |
| 2352 | |
| 2353 | 4.81 KVM_HAS_DEVICE_ATTR |
| 2354 | |
Dominik Dingel | f206165 | 2014-04-09 13:13:00 +0200 | [diff] [blame] | 2355 | Capability: KVM_CAP_DEVICE_CTRL, KVM_CAP_VM_ATTRIBUTES for vm device |
| 2356 | Type: device ioctl, vm ioctl |
Scott Wood | 852b6d5 | 2013-04-12 14:08:42 +0000 | [diff] [blame] | 2357 | Parameters: struct kvm_device_attr |
| 2358 | Returns: 0 on success, -1 on error |
| 2359 | Errors: |
| 2360 | ENXIO: The group or attribute is unknown/unsupported for this device |
| 2361 | |
| 2362 | Tests whether a device supports a particular attribute. A successful |
| 2363 | return indicates the attribute is implemented. It does not necessarily |
| 2364 | indicate that the attribute can be read or written in the device's |
| 2365 | current state. "addr" is ignored. |
Alex Williamson | f36992e | 2012-06-29 09:56:16 -0600 | [diff] [blame] | 2366 | |
Alexey Kardashevskiy | d8968f1 | 2013-06-19 11:42:07 +1000 | [diff] [blame] | 2367 | 4.82 KVM_ARM_VCPU_INIT |
Christoffer Dall | 749cf76c | 2013-01-20 18:28:06 -0500 | [diff] [blame] | 2368 | |
| 2369 | Capability: basic |
Marc Zyngier | 379e04c7 | 2013-04-02 17:46:31 +0100 | [diff] [blame] | 2370 | Architectures: arm, arm64 |
Christoffer Dall | 749cf76c | 2013-01-20 18:28:06 -0500 | [diff] [blame] | 2371 | Type: vcpu ioctl |
Anup Patel | beb11fc | 2013-12-12 21:42:24 +0530 | [diff] [blame] | 2372 | Parameters: struct kvm_vcpu_init (in) |
Christoffer Dall | 749cf76c | 2013-01-20 18:28:06 -0500 | [diff] [blame] | 2373 | Returns: 0 on success; -1 on error |
| 2374 | Errors: |
| 2375 | Â EINVAL: Â Â Â the target is unknown, or the combination of features is invalid. |
| 2376 | Â ENOENT: Â Â Â a features bit specified is unknown. |
| 2377 | |
| 2378 | This tells KVM what type of CPU to present to the guest, and what |
| 2379 | optional features it should have. Â This will cause a reset of the cpu |
| 2380 | registers to their initial values. Â If this is not called, KVM_RUN will |
| 2381 | return ENOEXEC for that vcpu. |
| 2382 | |
| 2383 | Note that because some registers reflect machine topology, all vcpus |
| 2384 | should be created before this ioctl is invoked. |
| 2385 | |
Marc Zyngier | aa024c2 | 2013-01-20 18:28:13 -0500 | [diff] [blame] | 2386 | Possible features: |
| 2387 | - KVM_ARM_VCPU_POWER_OFF: Starts the CPU in a power-off state. |
| 2388 | Depends on KVM_CAP_ARM_PSCI. |
Marc Zyngier | 379e04c7 | 2013-04-02 17:46:31 +0100 | [diff] [blame] | 2389 | - KVM_ARM_VCPU_EL1_32BIT: Starts the CPU in a 32bit mode. |
| 2390 | Depends on KVM_CAP_ARM_EL1_32BIT (arm64 only). |
Anup Patel | 50bb0c9 | 2014-04-29 11:24:17 +0530 | [diff] [blame] | 2391 | - KVM_ARM_VCPU_PSCI_0_2: Emulate PSCI v0.2 for the CPU. |
| 2392 | Depends on KVM_CAP_ARM_PSCI_0_2. |
Marc Zyngier | aa024c2 | 2013-01-20 18:28:13 -0500 | [diff] [blame] | 2393 | |
Christoffer Dall | 749cf76c | 2013-01-20 18:28:06 -0500 | [diff] [blame] | 2394 | |
Anup Patel | 740edfc | 2013-09-30 14:20:08 +0530 | [diff] [blame] | 2395 | 4.83 KVM_ARM_PREFERRED_TARGET |
| 2396 | |
| 2397 | Capability: basic |
| 2398 | Architectures: arm, arm64 |
| 2399 | Type: vm ioctl |
| 2400 | Parameters: struct struct kvm_vcpu_init (out) |
| 2401 | Returns: 0 on success; -1 on error |
| 2402 | Errors: |
Christoffer Dall | a7265fb | 2013-10-15 17:43:00 -0700 | [diff] [blame] | 2403 | ENODEV: no preferred target available for the host |
Anup Patel | 740edfc | 2013-09-30 14:20:08 +0530 | [diff] [blame] | 2404 | |
| 2405 | This queries KVM for preferred CPU target type which can be emulated |
| 2406 | by KVM on underlying host. |
| 2407 | |
| 2408 | The ioctl returns struct kvm_vcpu_init instance containing information |
| 2409 | about preferred CPU target type and recommended features for it. The |
| 2410 | kvm_vcpu_init->features bitmap returned will have feature bits set if |
| 2411 | the preferred target recommends setting these features, but this is |
| 2412 | not mandatory. |
| 2413 | |
| 2414 | The information returned by this ioctl can be used to prepare an instance |
| 2415 | of struct kvm_vcpu_init for KVM_ARM_VCPU_INIT ioctl which will result in |
| 2416 | in VCPU matching underlying host. |
| 2417 | |
| 2418 | |
| 2419 | 4.84 KVM_GET_REG_LIST |
Christoffer Dall | 749cf76c | 2013-01-20 18:28:06 -0500 | [diff] [blame] | 2420 | |
| 2421 | Capability: basic |
Marc Zyngier | 379e04c7 | 2013-04-02 17:46:31 +0100 | [diff] [blame] | 2422 | Architectures: arm, arm64 |
Christoffer Dall | 749cf76c | 2013-01-20 18:28:06 -0500 | [diff] [blame] | 2423 | Type: vcpu ioctl |
| 2424 | Parameters: struct kvm_reg_list (in/out) |
| 2425 | Returns: 0 on success; -1 on error |
| 2426 | Errors: |
| 2427 | Â E2BIG: Â Â Â Â the reg index list is too big to fit in the array specified by |
| 2428 | Â Â Â Â Â Â Â Â Â Â Â Â the user (the number required will be written into n). |
| 2429 | |
| 2430 | struct kvm_reg_list { |
| 2431 | __u64 n; /* number of registers in reg[] */ |
| 2432 | __u64 reg[0]; |
| 2433 | }; |
| 2434 | |
| 2435 | This ioctl returns the guest registers that are supported for the |
| 2436 | KVM_GET_ONE_REG/KVM_SET_ONE_REG calls. |
| 2437 | |
Christoffer Dall | ce01e4e | 2013-09-23 14:55:56 -0700 | [diff] [blame] | 2438 | |
| 2439 | 4.85 KVM_ARM_SET_DEVICE_ADDR (deprecated) |
Christoffer Dall | 3401d546 | 2013-01-23 13:18:04 -0500 | [diff] [blame] | 2440 | |
| 2441 | Capability: KVM_CAP_ARM_SET_DEVICE_ADDR |
Marc Zyngier | 379e04c7 | 2013-04-02 17:46:31 +0100 | [diff] [blame] | 2442 | Architectures: arm, arm64 |
Christoffer Dall | 3401d546 | 2013-01-23 13:18:04 -0500 | [diff] [blame] | 2443 | Type: vm ioctl |
| 2444 | Parameters: struct kvm_arm_device_address (in) |
| 2445 | Returns: 0 on success, -1 on error |
| 2446 | Errors: |
| 2447 | ENODEV: The device id is unknown |
| 2448 | ENXIO: Device not supported on current system |
| 2449 | EEXIST: Address already set |
| 2450 | E2BIG: Address outside guest physical address space |
Christoffer Dall | 330690c | 2013-01-21 19:36:13 -0500 | [diff] [blame] | 2451 | EBUSY: Address overlaps with other device range |
Christoffer Dall | 3401d546 | 2013-01-23 13:18:04 -0500 | [diff] [blame] | 2452 | |
| 2453 | struct kvm_arm_device_addr { |
| 2454 | __u64 id; |
| 2455 | __u64 addr; |
| 2456 | }; |
| 2457 | |
| 2458 | Specify a device address in the guest's physical address space where guests |
| 2459 | can access emulated or directly exposed devices, which the host kernel needs |
| 2460 | to know about. The id field is an architecture specific identifier for a |
| 2461 | specific device. |
| 2462 | |
Marc Zyngier | 379e04c7 | 2013-04-02 17:46:31 +0100 | [diff] [blame] | 2463 | ARM/arm64 divides the id field into two parts, a device id and an |
| 2464 | address type id specific to the individual device. |
Christoffer Dall | 3401d546 | 2013-01-23 13:18:04 -0500 | [diff] [blame] | 2465 | |
| 2466 | Â bits: | 63 ... 32 | 31 ... 16 | 15 ... 0 | |
| 2467 | field: | 0x00000000 | device id | addr type id | |
| 2468 | |
Marc Zyngier | 379e04c7 | 2013-04-02 17:46:31 +0100 | [diff] [blame] | 2469 | ARM/arm64 currently only require this when using the in-kernel GIC |
| 2470 | support for the hardware VGIC features, using KVM_ARM_DEVICE_VGIC_V2 |
| 2471 | as the device id. When setting the base address for the guest's |
| 2472 | mapping of the VGIC virtual CPU and distributor interface, the ioctl |
| 2473 | must be called after calling KVM_CREATE_IRQCHIP, but before calling |
| 2474 | KVM_RUN on any of the VCPUs. Calling this ioctl twice for any of the |
| 2475 | base addresses will return -EEXIST. |
Christoffer Dall | 3401d546 | 2013-01-23 13:18:04 -0500 | [diff] [blame] | 2476 | |
Christoffer Dall | ce01e4e | 2013-09-23 14:55:56 -0700 | [diff] [blame] | 2477 | Note, this IOCTL is deprecated and the more flexible SET/GET_DEVICE_ATTR API |
| 2478 | should be used instead. |
| 2479 | |
| 2480 | |
Anup Patel | 740edfc | 2013-09-30 14:20:08 +0530 | [diff] [blame] | 2481 | 4.86 KVM_PPC_RTAS_DEFINE_TOKEN |
Michael Ellerman | 8e591cb | 2013-04-17 20:30:00 +0000 | [diff] [blame] | 2482 | |
| 2483 | Capability: KVM_CAP_PPC_RTAS |
| 2484 | Architectures: ppc |
| 2485 | Type: vm ioctl |
| 2486 | Parameters: struct kvm_rtas_token_args |
| 2487 | Returns: 0 on success, -1 on error |
| 2488 | |
| 2489 | Defines a token value for a RTAS (Run Time Abstraction Services) |
| 2490 | service in order to allow it to be handled in the kernel. The |
| 2491 | argument struct gives the name of the service, which must be the name |
| 2492 | of a service that has a kernel-side implementation. If the token |
| 2493 | value is non-zero, it will be associated with that service, and |
| 2494 | subsequent RTAS calls by the guest specifying that token will be |
| 2495 | handled by the kernel. If the token value is 0, then any token |
| 2496 | associated with the service will be forgotten, and subsequent RTAS |
| 2497 | calls by the guest for that service will be passed to userspace to be |
| 2498 | handled. |
| 2499 | |
Christoffer Dall | 3401d546 | 2013-01-23 13:18:04 -0500 | [diff] [blame] | 2500 | |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 2501 | 5. The kvm_run structure |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 2502 | ------------------------ |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 2503 | |
| 2504 | Application code obtains a pointer to the kvm_run structure by |
| 2505 | mmap()ing a vcpu fd. From that point, application code can control |
| 2506 | execution by changing fields in kvm_run prior to calling the KVM_RUN |
| 2507 | ioctl, and obtain information about the reason KVM_RUN returned by |
| 2508 | looking up structure members. |
| 2509 | |
| 2510 | struct kvm_run { |
| 2511 | /* in */ |
| 2512 | __u8 request_interrupt_window; |
| 2513 | |
| 2514 | Request that KVM_RUN return when it becomes possible to inject external |
| 2515 | interrupts into the guest. Useful in conjunction with KVM_INTERRUPT. |
| 2516 | |
| 2517 | __u8 padding1[7]; |
| 2518 | |
| 2519 | /* out */ |
| 2520 | __u32 exit_reason; |
| 2521 | |
| 2522 | When KVM_RUN has returned successfully (return value 0), this informs |
| 2523 | application code why KVM_RUN has returned. Allowable values for this |
| 2524 | field are detailed below. |
| 2525 | |
| 2526 | __u8 ready_for_interrupt_injection; |
| 2527 | |
| 2528 | If request_interrupt_window has been specified, this field indicates |
| 2529 | an interrupt can be injected now with KVM_INTERRUPT. |
| 2530 | |
| 2531 | __u8 if_flag; |
| 2532 | |
| 2533 | The value of the current interrupt flag. Only valid if in-kernel |
| 2534 | local APIC is not used. |
| 2535 | |
| 2536 | __u8 padding2[2]; |
| 2537 | |
| 2538 | /* in (pre_kvm_run), out (post_kvm_run) */ |
| 2539 | __u64 cr8; |
| 2540 | |
| 2541 | The value of the cr8 register. Only valid if in-kernel local APIC is |
| 2542 | not used. Both input and output. |
| 2543 | |
| 2544 | __u64 apic_base; |
| 2545 | |
| 2546 | The value of the APIC BASE msr. Only valid if in-kernel local |
| 2547 | APIC is not used. Both input and output. |
| 2548 | |
| 2549 | union { |
| 2550 | /* KVM_EXIT_UNKNOWN */ |
| 2551 | struct { |
| 2552 | __u64 hardware_exit_reason; |
| 2553 | } hw; |
| 2554 | |
| 2555 | If exit_reason is KVM_EXIT_UNKNOWN, the vcpu has exited due to unknown |
| 2556 | reasons. Further architecture-specific information is available in |
| 2557 | hardware_exit_reason. |
| 2558 | |
| 2559 | /* KVM_EXIT_FAIL_ENTRY */ |
| 2560 | struct { |
| 2561 | __u64 hardware_entry_failure_reason; |
| 2562 | } fail_entry; |
| 2563 | |
| 2564 | If exit_reason is KVM_EXIT_FAIL_ENTRY, the vcpu could not be run due |
| 2565 | to unknown reasons. Further architecture-specific information is |
| 2566 | available in hardware_entry_failure_reason. |
| 2567 | |
| 2568 | /* KVM_EXIT_EXCEPTION */ |
| 2569 | struct { |
| 2570 | __u32 exception; |
| 2571 | __u32 error_code; |
| 2572 | } ex; |
| 2573 | |
| 2574 | Unused. |
| 2575 | |
| 2576 | /* KVM_EXIT_IO */ |
| 2577 | struct { |
| 2578 | #define KVM_EXIT_IO_IN 0 |
| 2579 | #define KVM_EXIT_IO_OUT 1 |
| 2580 | __u8 direction; |
| 2581 | __u8 size; /* bytes */ |
| 2582 | __u16 port; |
| 2583 | __u32 count; |
| 2584 | __u64 data_offset; /* relative to kvm_run start */ |
| 2585 | } io; |
| 2586 | |
Wu Fengguang | 2044892d | 2009-12-24 09:04:16 +0800 | [diff] [blame] | 2587 | If exit_reason is KVM_EXIT_IO, then the vcpu has |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 2588 | executed a port I/O instruction which could not be satisfied by kvm. |
| 2589 | data_offset describes where the data is located (KVM_EXIT_IO_OUT) or |
| 2590 | where kvm expects application code to place the data for the next |
Wu Fengguang | 2044892d | 2009-12-24 09:04:16 +0800 | [diff] [blame] | 2591 | 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] | 2592 | |
| 2593 | struct { |
| 2594 | struct kvm_debug_exit_arch arch; |
| 2595 | } debug; |
| 2596 | |
| 2597 | Unused. |
| 2598 | |
| 2599 | /* KVM_EXIT_MMIO */ |
| 2600 | struct { |
| 2601 | __u64 phys_addr; |
| 2602 | __u8 data[8]; |
| 2603 | __u32 len; |
| 2604 | __u8 is_write; |
| 2605 | } mmio; |
| 2606 | |
Wu Fengguang | 2044892d | 2009-12-24 09:04:16 +0800 | [diff] [blame] | 2607 | If exit_reason is KVM_EXIT_MMIO, then the vcpu has |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 2608 | executed a memory-mapped I/O instruction which could not be satisfied |
| 2609 | by kvm. The 'data' member contains the written data if 'is_write' is |
| 2610 | true, and should be filled by application code otherwise. |
| 2611 | |
Christoffer Dall | 6acdb16 | 2014-01-28 08:28:42 -0800 | [diff] [blame] | 2612 | The 'data' member contains, in its first 'len' bytes, the value as it would |
| 2613 | appear if the VCPU performed a load or store of the appropriate width directly |
| 2614 | to the byte array. |
| 2615 | |
Alexander Graf | ce91ddc | 2014-07-28 19:29:13 +0200 | [diff] [blame^] | 2616 | NOTE: For KVM_EXIT_IO, KVM_EXIT_MMIO, KVM_EXIT_OSI KVM_EXIT_PAPR and |
| 2617 | KVM_EXIT_EPR the corresponding |
Alexander Graf | ad0a048 | 2010-03-24 21:48:30 +0100 | [diff] [blame] | 2618 | operations are complete (and guest state is consistent) only after userspace |
| 2619 | 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] | 2620 | incomplete operations and then check for pending signals. Userspace |
| 2621 | can re-enter the guest with an unmasked signal pending to complete |
| 2622 | pending operations. |
| 2623 | |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 2624 | /* KVM_EXIT_HYPERCALL */ |
| 2625 | struct { |
| 2626 | __u64 nr; |
| 2627 | __u64 args[6]; |
| 2628 | __u64 ret; |
| 2629 | __u32 longmode; |
| 2630 | __u32 pad; |
| 2631 | } hypercall; |
| 2632 | |
Avi Kivity | 647dc49 | 2010-04-01 14:39:21 +0300 | [diff] [blame] | 2633 | Unused. This was once used for 'hypercall to userspace'. To implement |
| 2634 | such functionality, use KVM_EXIT_IO (x86) or KVM_EXIT_MMIO (all except s390). |
| 2635 | Note KVM_EXIT_IO is significantly faster than KVM_EXIT_MMIO. |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 2636 | |
| 2637 | /* KVM_EXIT_TPR_ACCESS */ |
| 2638 | struct { |
| 2639 | __u64 rip; |
| 2640 | __u32 is_write; |
| 2641 | __u32 pad; |
| 2642 | } tpr_access; |
| 2643 | |
| 2644 | To be documented (KVM_TPR_ACCESS_REPORTING). |
| 2645 | |
| 2646 | /* KVM_EXIT_S390_SIEIC */ |
| 2647 | struct { |
| 2648 | __u8 icptcode; |
| 2649 | __u64 mask; /* psw upper half */ |
| 2650 | __u64 addr; /* psw lower half */ |
| 2651 | __u16 ipa; |
| 2652 | __u32 ipb; |
| 2653 | } s390_sieic; |
| 2654 | |
| 2655 | s390 specific. |
| 2656 | |
| 2657 | /* KVM_EXIT_S390_RESET */ |
| 2658 | #define KVM_S390_RESET_POR 1 |
| 2659 | #define KVM_S390_RESET_CLEAR 2 |
| 2660 | #define KVM_S390_RESET_SUBSYSTEM 4 |
| 2661 | #define KVM_S390_RESET_CPU_INIT 8 |
| 2662 | #define KVM_S390_RESET_IPL 16 |
| 2663 | __u64 s390_reset_flags; |
| 2664 | |
| 2665 | s390 specific. |
| 2666 | |
Carsten Otte | e168bf8 | 2012-01-04 10:25:22 +0100 | [diff] [blame] | 2667 | /* KVM_EXIT_S390_UCONTROL */ |
| 2668 | struct { |
| 2669 | __u64 trans_exc_code; |
| 2670 | __u32 pgm_code; |
| 2671 | } s390_ucontrol; |
| 2672 | |
| 2673 | s390 specific. A page fault has occurred for a user controlled virtual |
| 2674 | machine (KVM_VM_S390_UNCONTROL) on it's host page table that cannot be |
| 2675 | resolved by the kernel. |
| 2676 | The program code and the translation exception code that were placed |
| 2677 | in the cpu's lowcore are presented here as defined by the z Architecture |
| 2678 | Principles of Operation Book in the Chapter for Dynamic Address Translation |
| 2679 | (DAT) |
| 2680 | |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 2681 | /* KVM_EXIT_DCR */ |
| 2682 | struct { |
| 2683 | __u32 dcrn; |
| 2684 | __u32 data; |
| 2685 | __u8 is_write; |
| 2686 | } dcr; |
| 2687 | |
Alexander Graf | ce91ddc | 2014-07-28 19:29:13 +0200 | [diff] [blame^] | 2688 | Deprecated - was used for 440 KVM. |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 2689 | |
Alexander Graf | ad0a048 | 2010-03-24 21:48:30 +0100 | [diff] [blame] | 2690 | /* KVM_EXIT_OSI */ |
| 2691 | struct { |
| 2692 | __u64 gprs[32]; |
| 2693 | } osi; |
| 2694 | |
| 2695 | MOL uses a special hypercall interface it calls 'OSI'. To enable it, we catch |
| 2696 | hypercalls and exit with this exit struct that contains all the guest gprs. |
| 2697 | |
| 2698 | If exit_reason is KVM_EXIT_OSI, then the vcpu has triggered such a hypercall. |
| 2699 | Userspace can now handle the hypercall and when it's done modify the gprs as |
| 2700 | necessary. Upon guest entry all guest GPRs will then be replaced by the values |
| 2701 | in this struct. |
| 2702 | |
Paul Mackerras | de56a94 | 2011-06-29 00:21:34 +0000 | [diff] [blame] | 2703 | /* KVM_EXIT_PAPR_HCALL */ |
| 2704 | struct { |
| 2705 | __u64 nr; |
| 2706 | __u64 ret; |
| 2707 | __u64 args[9]; |
| 2708 | } papr_hcall; |
| 2709 | |
| 2710 | This is used on 64-bit PowerPC when emulating a pSeries partition, |
| 2711 | e.g. with the 'pseries' machine type in qemu. It occurs when the |
| 2712 | guest does a hypercall using the 'sc 1' instruction. The 'nr' field |
| 2713 | contains the hypercall number (from the guest R3), and 'args' contains |
| 2714 | the arguments (from the guest R4 - R12). Userspace should put the |
| 2715 | return code in 'ret' and any extra returned values in args[]. |
| 2716 | The possible hypercalls are defined in the Power Architecture Platform |
| 2717 | Requirements (PAPR) document available from www.power.org (free |
| 2718 | developer registration required to access it). |
| 2719 | |
Cornelia Huck | fa6b7fe | 2012-12-20 15:32:12 +0100 | [diff] [blame] | 2720 | /* KVM_EXIT_S390_TSCH */ |
| 2721 | struct { |
| 2722 | __u16 subchannel_id; |
| 2723 | __u16 subchannel_nr; |
| 2724 | __u32 io_int_parm; |
| 2725 | __u32 io_int_word; |
| 2726 | __u32 ipb; |
| 2727 | __u8 dequeued; |
| 2728 | } s390_tsch; |
| 2729 | |
| 2730 | s390 specific. This exit occurs when KVM_CAP_S390_CSS_SUPPORT has been enabled |
| 2731 | and TEST SUBCHANNEL was intercepted. If dequeued is set, a pending I/O |
| 2732 | interrupt for the target subchannel has been dequeued and subchannel_id, |
| 2733 | subchannel_nr, io_int_parm and io_int_word contain the parameters for that |
| 2734 | interrupt. ipb is needed for instruction parameter decoding. |
| 2735 | |
Alexander Graf | 1c81063 | 2013-01-04 18:12:48 +0100 | [diff] [blame] | 2736 | /* KVM_EXIT_EPR */ |
| 2737 | struct { |
| 2738 | __u32 epr; |
| 2739 | } epr; |
| 2740 | |
| 2741 | On FSL BookE PowerPC chips, the interrupt controller has a fast patch |
| 2742 | interrupt acknowledge path to the core. When the core successfully |
| 2743 | delivers an interrupt, it automatically populates the EPR register with |
| 2744 | the interrupt vector number and acknowledges the interrupt inside |
| 2745 | the interrupt controller. |
| 2746 | |
| 2747 | In case the interrupt controller lives in user space, we need to do |
| 2748 | the interrupt acknowledge cycle through it to fetch the next to be |
| 2749 | delivered interrupt vector using this exit. |
| 2750 | |
| 2751 | It gets triggered whenever both KVM_CAP_PPC_EPR are enabled and an |
| 2752 | external interrupt has just been delivered into the guest. User space |
| 2753 | should put the acknowledged interrupt vector into the 'epr' field. |
| 2754 | |
Anup Patel | 8ad6b63 | 2014-04-29 11:24:19 +0530 | [diff] [blame] | 2755 | /* KVM_EXIT_SYSTEM_EVENT */ |
| 2756 | struct { |
| 2757 | #define KVM_SYSTEM_EVENT_SHUTDOWN 1 |
| 2758 | #define KVM_SYSTEM_EVENT_RESET 2 |
| 2759 | __u32 type; |
| 2760 | __u64 flags; |
| 2761 | } system_event; |
| 2762 | |
| 2763 | If exit_reason is KVM_EXIT_SYSTEM_EVENT then the vcpu has triggered |
| 2764 | a system-level event using some architecture specific mechanism (hypercall |
| 2765 | or some special instruction). In case of ARM/ARM64, this is triggered using |
| 2766 | HVC instruction based PSCI call from the vcpu. The 'type' field describes |
| 2767 | the system-level event type. The 'flags' field describes architecture |
| 2768 | specific flags for the system-level event. |
| 2769 | |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 2770 | /* Fix the size of the union. */ |
| 2771 | char padding[256]; |
| 2772 | }; |
Christian Borntraeger | b9e5dc8 | 2012-01-11 11:20:30 +0100 | [diff] [blame] | 2773 | |
| 2774 | /* |
| 2775 | * shared registers between kvm and userspace. |
| 2776 | * kvm_valid_regs specifies the register classes set by the host |
| 2777 | * kvm_dirty_regs specified the register classes dirtied by userspace |
| 2778 | * struct kvm_sync_regs is architecture specific, as well as the |
| 2779 | * bits for kvm_valid_regs and kvm_dirty_regs |
| 2780 | */ |
| 2781 | __u64 kvm_valid_regs; |
| 2782 | __u64 kvm_dirty_regs; |
| 2783 | union { |
| 2784 | struct kvm_sync_regs regs; |
| 2785 | char padding[1024]; |
| 2786 | } s; |
| 2787 | |
| 2788 | If KVM_CAP_SYNC_REGS is defined, these fields allow userspace to access |
| 2789 | certain guest registers without having to call SET/GET_*REGS. Thus we can |
| 2790 | avoid some system call overhead if userspace has to handle the exit. |
| 2791 | Userspace can query the validity of the structure by checking |
| 2792 | kvm_valid_regs for specific bits. These bits are architecture specific |
| 2793 | and usually define the validity of a groups of registers. (e.g. one bit |
| 2794 | for general purpose registers) |
| 2795 | |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 2796 | }; |
Alexander Graf | 821246a | 2011-08-31 10:58:55 +0200 | [diff] [blame] | 2797 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 2798 | |
Borislav Petkov | 9c15bb1 | 2013-09-22 16:44:50 +0200 | [diff] [blame] | 2799 | 4.81 KVM_GET_EMULATED_CPUID |
| 2800 | |
| 2801 | Capability: KVM_CAP_EXT_EMUL_CPUID |
| 2802 | Architectures: x86 |
| 2803 | Type: system ioctl |
| 2804 | Parameters: struct kvm_cpuid2 (in/out) |
| 2805 | Returns: 0 on success, -1 on error |
| 2806 | |
| 2807 | struct kvm_cpuid2 { |
| 2808 | __u32 nent; |
| 2809 | __u32 flags; |
| 2810 | struct kvm_cpuid_entry2 entries[0]; |
| 2811 | }; |
| 2812 | |
| 2813 | The member 'flags' is used for passing flags from userspace. |
| 2814 | |
| 2815 | #define KVM_CPUID_FLAG_SIGNIFCANT_INDEX BIT(0) |
| 2816 | #define KVM_CPUID_FLAG_STATEFUL_FUNC BIT(1) |
| 2817 | #define KVM_CPUID_FLAG_STATE_READ_NEXT BIT(2) |
| 2818 | |
| 2819 | struct kvm_cpuid_entry2 { |
| 2820 | __u32 function; |
| 2821 | __u32 index; |
| 2822 | __u32 flags; |
| 2823 | __u32 eax; |
| 2824 | __u32 ebx; |
| 2825 | __u32 ecx; |
| 2826 | __u32 edx; |
| 2827 | __u32 padding[3]; |
| 2828 | }; |
| 2829 | |
| 2830 | This ioctl returns x86 cpuid features which are emulated by |
| 2831 | kvm.Userspace can use the information returned by this ioctl to query |
| 2832 | which features are emulated by kvm instead of being present natively. |
| 2833 | |
| 2834 | Userspace invokes KVM_GET_EMULATED_CPUID by passing a kvm_cpuid2 |
| 2835 | structure with the 'nent' field indicating the number of entries in |
| 2836 | the variable-size array 'entries'. If the number of entries is too low |
| 2837 | to describe the cpu capabilities, an error (E2BIG) is returned. If the |
| 2838 | number is too high, the 'nent' field is adjusted and an error (ENOMEM) |
| 2839 | is returned. If the number is just right, the 'nent' field is adjusted |
| 2840 | to the number of valid entries in the 'entries' array, which is then |
| 2841 | filled. |
| 2842 | |
| 2843 | The entries returned are the set CPUID bits of the respective features |
| 2844 | which kvm emulates, as returned by the CPUID instruction, with unknown |
| 2845 | or unsupported feature bits cleared. |
| 2846 | |
| 2847 | Features like x2apic, for example, may not be present in the host cpu |
| 2848 | but are exposed by kvm in KVM_GET_SUPPORTED_CPUID because they can be |
| 2849 | emulated efficiently and thus not included here. |
| 2850 | |
| 2851 | The fields in each entry are defined as follows: |
| 2852 | |
| 2853 | function: the eax value used to obtain the entry |
| 2854 | index: the ecx value used to obtain the entry (for entries that are |
| 2855 | affected by ecx) |
| 2856 | flags: an OR of zero or more of the following: |
| 2857 | KVM_CPUID_FLAG_SIGNIFCANT_INDEX: |
| 2858 | if the index field is valid |
| 2859 | KVM_CPUID_FLAG_STATEFUL_FUNC: |
| 2860 | if cpuid for this function returns different values for successive |
| 2861 | invocations; there will be several entries with the same function, |
| 2862 | all with this flag set |
| 2863 | KVM_CPUID_FLAG_STATE_READ_NEXT: |
| 2864 | for KVM_CPUID_FLAG_STATEFUL_FUNC entries, set if this entry is |
| 2865 | the first entry to be read by a cpu |
| 2866 | eax, ebx, ecx, edx: the values returned by the cpuid instruction for |
| 2867 | this function/index combination |
| 2868 | |
| 2869 | |
Paul Mackerras | 699a0ea | 2014-06-02 11:02:59 +1000 | [diff] [blame] | 2870 | 6. Capabilities that can be enabled on vCPUs |
| 2871 | -------------------------------------------- |
Alexander Graf | 821246a | 2011-08-31 10:58:55 +0200 | [diff] [blame] | 2872 | |
| 2873 | There are certain capabilities that change the behavior of the virtual CPU when |
| 2874 | enabled. To enable them, please see section 4.37. Below you can find a list of |
| 2875 | capabilities and what their effect on the vCPU is when enabling them. |
| 2876 | |
| 2877 | The following information is provided along with the description: |
| 2878 | |
| 2879 | Architectures: which instruction set architectures provide this ioctl. |
| 2880 | x86 includes both i386 and x86_64. |
| 2881 | |
| 2882 | Parameters: what parameters are accepted by the capability. |
| 2883 | |
| 2884 | Returns: the return value. General error numbers (EBADF, ENOMEM, EINVAL) |
| 2885 | are not detailed, but errors with specific meanings are. |
| 2886 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 2887 | |
Alexander Graf | 821246a | 2011-08-31 10:58:55 +0200 | [diff] [blame] | 2888 | 6.1 KVM_CAP_PPC_OSI |
| 2889 | |
| 2890 | Architectures: ppc |
| 2891 | Parameters: none |
| 2892 | Returns: 0 on success; -1 on error |
| 2893 | |
| 2894 | This capability enables interception of OSI hypercalls that otherwise would |
| 2895 | be treated as normal system calls to be injected into the guest. OSI hypercalls |
| 2896 | were invented by Mac-on-Linux to have a standardized communication mechanism |
| 2897 | between the guest and the host. |
| 2898 | |
| 2899 | When this capability is enabled, KVM_EXIT_OSI can occur. |
| 2900 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 2901 | |
Alexander Graf | 821246a | 2011-08-31 10:58:55 +0200 | [diff] [blame] | 2902 | 6.2 KVM_CAP_PPC_PAPR |
| 2903 | |
| 2904 | Architectures: ppc |
| 2905 | Parameters: none |
| 2906 | Returns: 0 on success; -1 on error |
| 2907 | |
| 2908 | This capability enables interception of PAPR hypercalls. PAPR hypercalls are |
| 2909 | done using the hypercall instruction "sc 1". |
| 2910 | |
| 2911 | It also sets the guest privilege level to "supervisor" mode. Usually the guest |
| 2912 | runs in "hypervisor" privilege mode with a few missing features. |
| 2913 | |
| 2914 | In addition to the above, it changes the semantics of SDR1. In this mode, the |
| 2915 | HTAB address part of SDR1 contains an HVA instead of a GPA, as PAPR keeps the |
| 2916 | HTAB invisible to the guest. |
| 2917 | |
| 2918 | When this capability is enabled, KVM_EXIT_PAPR_HCALL can occur. |
Scott Wood | dc83b8b | 2011-08-18 15:25:21 -0500 | [diff] [blame] | 2919 | |
Jan Kiszka | 414fa98 | 2012-04-24 16:40:15 +0200 | [diff] [blame] | 2920 | |
Scott Wood | dc83b8b | 2011-08-18 15:25:21 -0500 | [diff] [blame] | 2921 | 6.3 KVM_CAP_SW_TLB |
| 2922 | |
| 2923 | Architectures: ppc |
| 2924 | Parameters: args[0] is the address of a struct kvm_config_tlb |
| 2925 | Returns: 0 on success; -1 on error |
| 2926 | |
| 2927 | struct kvm_config_tlb { |
| 2928 | __u64 params; |
| 2929 | __u64 array; |
| 2930 | __u32 mmu_type; |
| 2931 | __u32 array_len; |
| 2932 | }; |
| 2933 | |
| 2934 | Configures the virtual CPU's TLB array, establishing a shared memory area |
| 2935 | between userspace and KVM. The "params" and "array" fields are userspace |
| 2936 | addresses of mmu-type-specific data structures. The "array_len" field is an |
| 2937 | safety mechanism, and should be set to the size in bytes of the memory that |
| 2938 | userspace has reserved for the array. It must be at least the size dictated |
| 2939 | by "mmu_type" and "params". |
| 2940 | |
| 2941 | While KVM_RUN is active, the shared region is under control of KVM. Its |
| 2942 | contents are undefined, and any modification by userspace results in |
| 2943 | boundedly undefined behavior. |
| 2944 | |
| 2945 | On return from KVM_RUN, the shared region will reflect the current state of |
| 2946 | the guest's TLB. If userspace makes any changes, it must call KVM_DIRTY_TLB |
| 2947 | to tell KVM which entries have been changed, prior to calling KVM_RUN again |
| 2948 | on this vcpu. |
| 2949 | |
| 2950 | For mmu types KVM_MMU_FSL_BOOKE_NOHV and KVM_MMU_FSL_BOOKE_HV: |
| 2951 | - The "params" field is of type "struct kvm_book3e_206_tlb_params". |
| 2952 | - The "array" field points to an array of type "struct |
| 2953 | kvm_book3e_206_tlb_entry". |
| 2954 | - The array consists of all entries in the first TLB, followed by all |
| 2955 | entries in the second TLB. |
| 2956 | - Within a TLB, entries are ordered first by increasing set number. Within a |
| 2957 | set, entries are ordered by way (increasing ESEL). |
| 2958 | - The hash for determining set number in TLB0 is: (MAS2 >> 12) & (num_sets - 1) |
| 2959 | where "num_sets" is the tlb_sizes[] value divided by the tlb_ways[] value. |
| 2960 | - The tsize field of mas1 shall be set to 4K on TLB0, even though the |
| 2961 | hardware ignores this value for TLB0. |
Cornelia Huck | fa6b7fe | 2012-12-20 15:32:12 +0100 | [diff] [blame] | 2962 | |
| 2963 | 6.4 KVM_CAP_S390_CSS_SUPPORT |
| 2964 | |
| 2965 | Architectures: s390 |
| 2966 | Parameters: none |
| 2967 | Returns: 0 on success; -1 on error |
| 2968 | |
| 2969 | This capability enables support for handling of channel I/O instructions. |
| 2970 | |
| 2971 | TEST PENDING INTERRUPTION and the interrupt portion of TEST SUBCHANNEL are |
| 2972 | handled in-kernel, while the other I/O instructions are passed to userspace. |
| 2973 | |
| 2974 | When this capability is enabled, KVM_EXIT_S390_TSCH will occur on TEST |
| 2975 | SUBCHANNEL intercepts. |
Alexander Graf | 1c81063 | 2013-01-04 18:12:48 +0100 | [diff] [blame] | 2976 | |
| 2977 | 6.5 KVM_CAP_PPC_EPR |
| 2978 | |
| 2979 | Architectures: ppc |
| 2980 | Parameters: args[0] defines whether the proxy facility is active |
| 2981 | Returns: 0 on success; -1 on error |
| 2982 | |
| 2983 | This capability enables or disables the delivery of interrupts through the |
| 2984 | external proxy facility. |
| 2985 | |
| 2986 | When enabled (args[0] != 0), every time the guest gets an external interrupt |
| 2987 | delivered, it automatically exits into user space with a KVM_EXIT_EPR exit |
| 2988 | to receive the topmost interrupt vector. |
| 2989 | |
| 2990 | When disabled (args[0] == 0), behavior is as if this facility is unsupported. |
| 2991 | |
| 2992 | When this capability is enabled, KVM_EXIT_EPR can occur. |
Scott Wood | eb1e4f4 | 2013-04-12 14:08:47 +0000 | [diff] [blame] | 2993 | |
| 2994 | 6.6 KVM_CAP_IRQ_MPIC |
| 2995 | |
| 2996 | Architectures: ppc |
| 2997 | Parameters: args[0] is the MPIC device fd |
| 2998 | args[1] is the MPIC CPU number for this vcpu |
| 2999 | |
| 3000 | This capability connects the vcpu to an in-kernel MPIC device. |
Paul Mackerras | 5975a2e | 2013-04-27 00:28:37 +0000 | [diff] [blame] | 3001 | |
| 3002 | 6.7 KVM_CAP_IRQ_XICS |
| 3003 | |
| 3004 | Architectures: ppc |
| 3005 | Parameters: args[0] is the XICS device fd |
| 3006 | args[1] is the XICS CPU number (server ID) for this vcpu |
| 3007 | |
| 3008 | This capability connects the vcpu to an in-kernel XICS device. |
Paul Mackerras | 699a0ea | 2014-06-02 11:02:59 +1000 | [diff] [blame] | 3009 | |
| 3010 | |
| 3011 | 7. Capabilities that can be enabled on VMs |
| 3012 | ------------------------------------------ |
| 3013 | |
| 3014 | There are certain capabilities that change the behavior of the virtual |
| 3015 | machine when enabled. To enable them, please see section 4.37. Below |
| 3016 | you can find a list of capabilities and what their effect on the VM |
| 3017 | is when enabling them. |
| 3018 | |
| 3019 | The following information is provided along with the description: |
| 3020 | |
| 3021 | Architectures: which instruction set architectures provide this ioctl. |
| 3022 | x86 includes both i386 and x86_64. |
| 3023 | |
| 3024 | Parameters: what parameters are accepted by the capability. |
| 3025 | |
| 3026 | Returns: the return value. General error numbers (EBADF, ENOMEM, EINVAL) |
| 3027 | are not detailed, but errors with specific meanings are. |
| 3028 | |
| 3029 | |
| 3030 | 7.1 KVM_CAP_PPC_ENABLE_HCALL |
| 3031 | |
| 3032 | Architectures: ppc |
| 3033 | Parameters: args[0] is the sPAPR hcall number |
| 3034 | args[1] is 0 to disable, 1 to enable in-kernel handling |
| 3035 | |
| 3036 | This capability controls whether individual sPAPR hypercalls (hcalls) |
| 3037 | get handled by the kernel or not. Enabling or disabling in-kernel |
| 3038 | handling of an hcall is effective across the VM. On creation, an |
| 3039 | initial set of hcalls are enabled for in-kernel handling, which |
| 3040 | consists of those hcalls for which in-kernel handlers were implemented |
| 3041 | before this capability was implemented. If disabled, the kernel will |
| 3042 | not to attempt to handle the hcall, but will always exit to userspace |
| 3043 | to handle it. Note that it may not make sense to enable some and |
| 3044 | disable others of a group of related hcalls, but KVM does not prevent |
| 3045 | userspace from doing that. |
Paul Mackerras | ae2113a | 2014-06-02 11:03:00 +1000 | [diff] [blame] | 3046 | |
| 3047 | If the hcall number specified is not one that has an in-kernel |
| 3048 | implementation, the KVM_ENABLE_CAP ioctl will fail with an EINVAL |
| 3049 | error. |