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 |
| 5 | |
| 6 | The kvm API is a set of ioctls that are issued to control various aspects |
| 7 | of a virtual machine. The ioctls belong to three classes |
| 8 | |
| 9 | - System ioctls: These query and set global attributes which affect the |
| 10 | whole kvm subsystem. In addition a system ioctl is used to create |
| 11 | virtual machines |
| 12 | |
| 13 | - VM ioctls: These query and set attributes that affect an entire virtual |
| 14 | machine, for example memory layout. In addition a VM ioctl is used to |
| 15 | create virtual cpus (vcpus). |
| 16 | |
| 17 | Only run VM ioctls from the same process (address space) that was used |
| 18 | to create the VM. |
| 19 | |
| 20 | - vcpu ioctls: These query and set attributes that control the operation |
| 21 | of a single virtual cpu. |
| 22 | |
| 23 | Only run vcpu ioctls from the same thread that was used to create the |
| 24 | vcpu. |
| 25 | |
Wu Fengguang | 2044892d | 2009-12-24 09:04:16 +0800 | [diff] [blame] | 26 | 2. File descriptors |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 27 | |
| 28 | The kvm API is centered around file descriptors. An initial |
| 29 | open("/dev/kvm") obtains a handle to the kvm subsystem; this handle |
| 30 | 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] | 31 | 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] | 32 | ioctls. A KVM_CREATE_VCPU ioctl on a VM fd will create a virtual cpu |
| 33 | and return a file descriptor pointing to it. Finally, ioctls on a vcpu |
| 34 | fd can be used to control the vcpu, including the important task of |
| 35 | actually running guest code. |
| 36 | |
| 37 | In general file descriptors can be migrated among processes by means |
| 38 | of fork() and the SCM_RIGHTS facility of unix domain socket. These |
| 39 | kinds of tricks are explicitly not supported by kvm. While they will |
| 40 | not cause harm to the host, their actual behavior is not guaranteed by |
| 41 | the API. The only supported use is one virtual machine per process, |
| 42 | and one vcpu per thread. |
| 43 | |
| 44 | 3. Extensions |
| 45 | |
| 46 | As of Linux 2.6.22, the KVM ABI has been stabilized: no backward |
| 47 | incompatible change are allowed. However, there is an extension |
| 48 | facility that allows backward-compatible extensions to the API to be |
| 49 | queried and used. |
| 50 | |
| 51 | The extension mechanism is not based on on the Linux version number. |
| 52 | Instead, kvm defines extension identifiers and a facility to query |
| 53 | whether a particular extension identifier is available. If it is, a |
| 54 | set of ioctls is available for application use. |
| 55 | |
| 56 | 4. API description |
| 57 | |
| 58 | This section describes ioctls that can be used to control kvm guests. |
| 59 | For each ioctl, the following information is provided along with a |
| 60 | description: |
| 61 | |
| 62 | Capability: which KVM extension provides this ioctl. Can be 'basic', |
| 63 | which means that is will be provided by any kernel that supports |
| 64 | API version 12 (see section 4.1), or a KVM_CAP_xyz constant, which |
| 65 | means availability needs to be checked with KVM_CHECK_EXTENSION |
| 66 | (see section 4.4). |
| 67 | |
| 68 | Architectures: which instruction set architectures provide this ioctl. |
| 69 | x86 includes both i386 and x86_64. |
| 70 | |
| 71 | Type: system, vm, or vcpu. |
| 72 | |
| 73 | Parameters: what parameters are accepted by the ioctl. |
| 74 | |
| 75 | Returns: the return value. General error numbers (EBADF, ENOMEM, EINVAL) |
| 76 | are not detailed, but errors with specific meanings are. |
| 77 | |
| 78 | 4.1 KVM_GET_API_VERSION |
| 79 | |
| 80 | Capability: basic |
| 81 | Architectures: all |
| 82 | Type: system ioctl |
| 83 | Parameters: none |
| 84 | Returns: the constant KVM_API_VERSION (=12) |
| 85 | |
| 86 | This identifies the API version as the stable kvm API. It is not |
| 87 | expected that this number will change. However, Linux 2.6.20 and |
| 88 | 2.6.21 report earlier versions; these are not documented and not |
| 89 | supported. Applications should refuse to run if KVM_GET_API_VERSION |
| 90 | returns a value other than 12. If this check passes, all ioctls |
| 91 | described as 'basic' will be available. |
| 92 | |
| 93 | 4.2 KVM_CREATE_VM |
| 94 | |
| 95 | Capability: basic |
| 96 | Architectures: all |
| 97 | Type: system ioctl |
Carsten Otte | e08b963 | 2012-01-04 10:25:20 +0100 | [diff] [blame] | 98 | Parameters: machine type identifier (KVM_VM_*) |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 99 | Returns: a VM fd that can be used to control the new virtual machine. |
| 100 | |
| 101 | The new VM has no virtual cpus and no memory. An mmap() of a VM fd |
| 102 | will access the virtual machine's physical address space; offset zero |
| 103 | corresponds to guest physical address zero. Use of mmap() on a VM fd |
| 104 | is discouraged if userspace memory allocation (KVM_CAP_USER_MEMORY) is |
| 105 | available. |
Carsten Otte | e08b963 | 2012-01-04 10:25:20 +0100 | [diff] [blame] | 106 | You most certainly want to use 0 as machine type. |
| 107 | |
| 108 | In order to create user controlled virtual machines on S390, check |
| 109 | KVM_CAP_S390_UCONTROL and use the flag KVM_VM_S390_UCONTROL as |
| 110 | privileged user (CAP_SYS_ADMIN). |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 111 | |
| 112 | 4.3 KVM_GET_MSR_INDEX_LIST |
| 113 | |
| 114 | Capability: basic |
| 115 | Architectures: x86 |
| 116 | Type: system |
| 117 | Parameters: struct kvm_msr_list (in/out) |
| 118 | Returns: 0 on success; -1 on error |
| 119 | Errors: |
| 120 | E2BIG: the msr index list is to be to fit in the array specified by |
| 121 | the user. |
| 122 | |
| 123 | struct kvm_msr_list { |
| 124 | __u32 nmsrs; /* number of msrs in entries */ |
| 125 | __u32 indices[0]; |
| 126 | }; |
| 127 | |
| 128 | This ioctl returns the guest msrs that are supported. The list varies |
| 129 | by kvm version and host processor, but does not change otherwise. The |
| 130 | user fills in the size of the indices array in nmsrs, and in return |
| 131 | kvm adjusts nmsrs to reflect the actual number of msrs and fills in |
| 132 | the indices array with their numbers. |
| 133 | |
Avi Kivity | 2e2602c | 2010-07-07 14:09:39 +0300 | [diff] [blame] | 134 | Note: if kvm indicates supports MCE (KVM_CAP_MCE), then the MCE bank MSRs are |
| 135 | not returned in the MSR list, as different vcpus can have a different number |
| 136 | of banks, as set via the KVM_X86_SETUP_MCE ioctl. |
| 137 | |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 138 | 4.4 KVM_CHECK_EXTENSION |
| 139 | |
| 140 | Capability: basic |
| 141 | Architectures: all |
| 142 | Type: system ioctl |
| 143 | Parameters: extension identifier (KVM_CAP_*) |
| 144 | Returns: 0 if unsupported; 1 (or some other positive integer) if supported |
| 145 | |
| 146 | The API allows the application to query about extensions to the core |
| 147 | kvm API. Userspace passes an extension identifier (an integer) and |
| 148 | receives an integer that describes the extension availability. |
| 149 | Generally 0 means no and 1 means yes, but some extensions may report |
| 150 | additional information in the integer return value. |
| 151 | |
| 152 | 4.5 KVM_GET_VCPU_MMAP_SIZE |
| 153 | |
| 154 | Capability: basic |
| 155 | Architectures: all |
| 156 | Type: system ioctl |
| 157 | Parameters: none |
| 158 | Returns: size of vcpu mmap area, in bytes |
| 159 | |
| 160 | The KVM_RUN ioctl (cf.) communicates with userspace via a shared |
| 161 | memory region. This ioctl returns the size of that region. See the |
| 162 | KVM_RUN documentation for details. |
| 163 | |
| 164 | 4.6 KVM_SET_MEMORY_REGION |
| 165 | |
| 166 | Capability: basic |
| 167 | Architectures: all |
| 168 | Type: vm ioctl |
| 169 | Parameters: struct kvm_memory_region (in) |
| 170 | Returns: 0 on success, -1 on error |
| 171 | |
Avi Kivity | b74a07b | 2010-06-21 11:48:05 +0300 | [diff] [blame] | 172 | This ioctl is obsolete and has been removed. |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 173 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 174 | 4.7 KVM_CREATE_VCPU |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 175 | |
| 176 | Capability: basic |
| 177 | Architectures: all |
| 178 | Type: vm ioctl |
| 179 | Parameters: vcpu id (apic id on x86) |
| 180 | Returns: vcpu fd on success, -1 on error |
| 181 | |
| 182 | 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] | 183 | in the range [0, max_vcpus). |
| 184 | |
| 185 | The recommended max_vcpus value can be retrieved using the KVM_CAP_NR_VCPUS of |
| 186 | the KVM_CHECK_EXTENSION ioctl() at run-time. |
| 187 | The maximum possible value for max_vcpus can be retrieved using the |
| 188 | KVM_CAP_MAX_VCPUS of the KVM_CHECK_EXTENSION ioctl() at run-time. |
| 189 | |
Pekka Enberg | 76d2540 | 2011-05-09 22:48:54 +0300 | [diff] [blame] | 190 | If the KVM_CAP_NR_VCPUS does not exist, you should assume that max_vcpus is 4 |
| 191 | cpus max. |
Sasha Levin | 8c3ba33 | 2011-07-18 17:17:15 +0300 | [diff] [blame] | 192 | If the KVM_CAP_MAX_VCPUS does not exist, you should assume that max_vcpus is |
| 193 | same as the value returned from KVM_CAP_NR_VCPUS. |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 194 | |
Paul Mackerras | 371fefd | 2011-06-29 00:23:08 +0000 | [diff] [blame] | 195 | On powerpc using book3s_hv mode, the vcpus are mapped onto virtual |
| 196 | threads in one or more virtual CPU cores. (This is because the |
| 197 | hardware requires all the hardware threads in a CPU core to be in the |
| 198 | same partition.) The KVM_CAP_PPC_SMT capability indicates the number |
| 199 | of vcpus per virtual core (vcore). The vcore id is obtained by |
| 200 | dividing the vcpu id by the number of vcpus per vcore. The vcpus in a |
| 201 | given vcore will always be in the same physical core as each other |
| 202 | (though that might be a different physical core from time to time). |
| 203 | Userspace can control the threading (SMT) mode of the guest by its |
| 204 | allocation of vcpu ids. For example, if userspace wants |
| 205 | single-threaded guest vcpus, it should make all vcpu ids be a multiple |
| 206 | of the number of vcpus per vcore. |
| 207 | |
Avi Kivity | 3644268 | 2011-08-29 16:27:08 +0300 | [diff] [blame] | 208 | On powerpc using book3s_hv mode, the vcpus are mapped onto virtual |
| 209 | threads in one or more virtual CPU cores. (This is because the |
| 210 | hardware requires all the hardware threads in a CPU core to be in the |
| 211 | same partition.) The KVM_CAP_PPC_SMT capability indicates the number |
| 212 | of vcpus per virtual core (vcore). The vcore id is obtained by |
| 213 | dividing the vcpu id by the number of vcpus per vcore. The vcpus in a |
| 214 | given vcore will always be in the same physical core as each other |
| 215 | (though that might be a different physical core from time to time). |
| 216 | Userspace can control the threading (SMT) mode of the guest by its |
| 217 | allocation of vcpu ids. For example, if userspace wants |
| 218 | single-threaded guest vcpus, it should make all vcpu ids be a multiple |
| 219 | of the number of vcpus per vcore. |
| 220 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 221 | 4.8 KVM_GET_DIRTY_LOG (vm ioctl) |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 222 | |
| 223 | Capability: basic |
| 224 | Architectures: x86 |
| 225 | Type: vm ioctl |
| 226 | Parameters: struct kvm_dirty_log (in/out) |
| 227 | Returns: 0 on success, -1 on error |
| 228 | |
| 229 | /* for KVM_GET_DIRTY_LOG */ |
| 230 | struct kvm_dirty_log { |
| 231 | __u32 slot; |
| 232 | __u32 padding; |
| 233 | union { |
| 234 | void __user *dirty_bitmap; /* one bit per page */ |
| 235 | __u64 padding; |
| 236 | }; |
| 237 | }; |
| 238 | |
| 239 | Given a memory slot, return a bitmap containing any pages dirtied |
| 240 | since the last call to this ioctl. Bit 0 is the first page in the |
| 241 | memory slot. Ensure the entire structure is cleared to avoid padding |
| 242 | issues. |
| 243 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 244 | 4.9 KVM_SET_MEMORY_ALIAS |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 245 | |
| 246 | Capability: basic |
| 247 | Architectures: x86 |
| 248 | Type: vm ioctl |
| 249 | Parameters: struct kvm_memory_alias (in) |
| 250 | Returns: 0 (success), -1 (error) |
| 251 | |
Avi Kivity | a1f4d395 | 2010-06-21 11:44:20 +0300 | [diff] [blame] | 252 | This ioctl is obsolete and has been removed. |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 253 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 254 | 4.10 KVM_RUN |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 255 | |
| 256 | Capability: basic |
| 257 | Architectures: all |
| 258 | Type: vcpu ioctl |
| 259 | Parameters: none |
| 260 | Returns: 0 on success, -1 on error |
| 261 | Errors: |
| 262 | EINTR: an unmasked signal is pending |
| 263 | |
| 264 | This ioctl is used to run a guest virtual cpu. While there are no |
| 265 | explicit parameters, there is an implicit parameter block that can be |
| 266 | obtained by mmap()ing the vcpu fd at offset 0, with the size given by |
| 267 | KVM_GET_VCPU_MMAP_SIZE. The parameter block is formatted as a 'struct |
| 268 | kvm_run' (see below). |
| 269 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 270 | 4.11 KVM_GET_REGS |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 271 | |
| 272 | Capability: basic |
| 273 | Architectures: all |
| 274 | Type: vcpu ioctl |
| 275 | Parameters: struct kvm_regs (out) |
| 276 | Returns: 0 on success, -1 on error |
| 277 | |
| 278 | Reads the general purpose registers from the vcpu. |
| 279 | |
| 280 | /* x86 */ |
| 281 | struct kvm_regs { |
| 282 | /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */ |
| 283 | __u64 rax, rbx, rcx, rdx; |
| 284 | __u64 rsi, rdi, rsp, rbp; |
| 285 | __u64 r8, r9, r10, r11; |
| 286 | __u64 r12, r13, r14, r15; |
| 287 | __u64 rip, rflags; |
| 288 | }; |
| 289 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 290 | 4.12 KVM_SET_REGS |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 291 | |
| 292 | Capability: basic |
| 293 | Architectures: all |
| 294 | Type: vcpu ioctl |
| 295 | Parameters: struct kvm_regs (in) |
| 296 | Returns: 0 on success, -1 on error |
| 297 | |
| 298 | Writes the general purpose registers into the vcpu. |
| 299 | |
| 300 | See KVM_GET_REGS for the data structure. |
| 301 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 302 | 4.13 KVM_GET_SREGS |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 303 | |
| 304 | Capability: basic |
Scott Wood | 5ce941e | 2011-04-27 17:24:21 -0500 | [diff] [blame] | 305 | Architectures: x86, ppc |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 306 | Type: vcpu ioctl |
| 307 | Parameters: struct kvm_sregs (out) |
| 308 | Returns: 0 on success, -1 on error |
| 309 | |
| 310 | Reads special registers from the vcpu. |
| 311 | |
| 312 | /* x86 */ |
| 313 | struct kvm_sregs { |
| 314 | struct kvm_segment cs, ds, es, fs, gs, ss; |
| 315 | struct kvm_segment tr, ldt; |
| 316 | struct kvm_dtable gdt, idt; |
| 317 | __u64 cr0, cr2, cr3, cr4, cr8; |
| 318 | __u64 efer; |
| 319 | __u64 apic_base; |
| 320 | __u64 interrupt_bitmap[(KVM_NR_INTERRUPTS + 63) / 64]; |
| 321 | }; |
| 322 | |
Scott Wood | 5ce941e | 2011-04-27 17:24:21 -0500 | [diff] [blame] | 323 | /* ppc -- see arch/powerpc/include/asm/kvm.h */ |
| 324 | |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 325 | interrupt_bitmap is a bitmap of pending external interrupts. At most |
| 326 | one bit may be set. This interrupt has been acknowledged by the APIC |
| 327 | but not yet injected into the cpu core. |
| 328 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 329 | 4.14 KVM_SET_SREGS |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 330 | |
| 331 | Capability: basic |
Scott Wood | 5ce941e | 2011-04-27 17:24:21 -0500 | [diff] [blame] | 332 | Architectures: x86, ppc |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 333 | Type: vcpu ioctl |
| 334 | Parameters: struct kvm_sregs (in) |
| 335 | Returns: 0 on success, -1 on error |
| 336 | |
| 337 | Writes special registers into the vcpu. See KVM_GET_SREGS for the |
| 338 | data structures. |
| 339 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 340 | 4.15 KVM_TRANSLATE |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 341 | |
| 342 | Capability: basic |
| 343 | Architectures: x86 |
| 344 | Type: vcpu ioctl |
| 345 | Parameters: struct kvm_translation (in/out) |
| 346 | Returns: 0 on success, -1 on error |
| 347 | |
| 348 | Translates a virtual address according to the vcpu's current address |
| 349 | translation mode. |
| 350 | |
| 351 | struct kvm_translation { |
| 352 | /* in */ |
| 353 | __u64 linear_address; |
| 354 | |
| 355 | /* out */ |
| 356 | __u64 physical_address; |
| 357 | __u8 valid; |
| 358 | __u8 writeable; |
| 359 | __u8 usermode; |
| 360 | __u8 pad[5]; |
| 361 | }; |
| 362 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 363 | 4.16 KVM_INTERRUPT |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 364 | |
| 365 | Capability: basic |
Alexander Graf | 6f7a2bd | 2010-08-31 02:03:32 +0200 | [diff] [blame] | 366 | Architectures: x86, ppc |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 367 | Type: vcpu ioctl |
| 368 | Parameters: struct kvm_interrupt (in) |
| 369 | Returns: 0 on success, -1 on error |
| 370 | |
| 371 | Queues a hardware interrupt vector to be injected. This is only |
Alexander Graf | 6f7a2bd | 2010-08-31 02:03:32 +0200 | [diff] [blame] | 372 | useful if in-kernel local APIC or equivalent is not used. |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 373 | |
| 374 | /* for KVM_INTERRUPT */ |
| 375 | struct kvm_interrupt { |
| 376 | /* in */ |
| 377 | __u32 irq; |
| 378 | }; |
| 379 | |
Alexander Graf | 6f7a2bd | 2010-08-31 02:03:32 +0200 | [diff] [blame] | 380 | X86: |
| 381 | |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 382 | Note 'irq' is an interrupt vector, not an interrupt pin or line. |
| 383 | |
Alexander Graf | 6f7a2bd | 2010-08-31 02:03:32 +0200 | [diff] [blame] | 384 | PPC: |
| 385 | |
| 386 | Queues an external interrupt to be injected. This ioctl is overleaded |
| 387 | with 3 different irq values: |
| 388 | |
| 389 | a) KVM_INTERRUPT_SET |
| 390 | |
| 391 | This injects an edge type external interrupt into the guest once it's ready |
| 392 | to receive interrupts. When injected, the interrupt is done. |
| 393 | |
| 394 | b) KVM_INTERRUPT_UNSET |
| 395 | |
| 396 | This unsets any pending interrupt. |
| 397 | |
| 398 | Only available with KVM_CAP_PPC_UNSET_IRQ. |
| 399 | |
| 400 | c) KVM_INTERRUPT_SET_LEVEL |
| 401 | |
| 402 | This injects a level type external interrupt into the guest context. The |
| 403 | interrupt stays pending until a specific ioctl with KVM_INTERRUPT_UNSET |
| 404 | is triggered. |
| 405 | |
| 406 | Only available with KVM_CAP_PPC_IRQ_LEVEL. |
| 407 | |
| 408 | Note that any value for 'irq' other than the ones stated above is invalid |
| 409 | and incurs unexpected behavior. |
| 410 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 411 | 4.17 KVM_DEBUG_GUEST |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 412 | |
| 413 | Capability: basic |
| 414 | Architectures: none |
| 415 | Type: vcpu ioctl |
| 416 | Parameters: none) |
| 417 | Returns: -1 on error |
| 418 | |
| 419 | Support for this has been removed. Use KVM_SET_GUEST_DEBUG instead. |
| 420 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 421 | 4.18 KVM_GET_MSRS |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 422 | |
| 423 | Capability: basic |
| 424 | Architectures: x86 |
| 425 | Type: vcpu ioctl |
| 426 | Parameters: struct kvm_msrs (in/out) |
| 427 | Returns: 0 on success, -1 on error |
| 428 | |
| 429 | Reads model-specific registers from the vcpu. Supported msr indices can |
| 430 | be obtained using KVM_GET_MSR_INDEX_LIST. |
| 431 | |
| 432 | struct kvm_msrs { |
| 433 | __u32 nmsrs; /* number of msrs in entries */ |
| 434 | __u32 pad; |
| 435 | |
| 436 | struct kvm_msr_entry entries[0]; |
| 437 | }; |
| 438 | |
| 439 | struct kvm_msr_entry { |
| 440 | __u32 index; |
| 441 | __u32 reserved; |
| 442 | __u64 data; |
| 443 | }; |
| 444 | |
| 445 | Application code should set the 'nmsrs' member (which indicates the |
| 446 | size of the entries array) and the 'index' member of each array entry. |
| 447 | kvm will fill in the 'data' member. |
| 448 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 449 | 4.19 KVM_SET_MSRS |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 450 | |
| 451 | Capability: basic |
| 452 | Architectures: x86 |
| 453 | Type: vcpu ioctl |
| 454 | Parameters: struct kvm_msrs (in) |
| 455 | Returns: 0 on success, -1 on error |
| 456 | |
| 457 | Writes model-specific registers to the vcpu. See KVM_GET_MSRS for the |
| 458 | data structures. |
| 459 | |
| 460 | Application code should set the 'nmsrs' member (which indicates the |
| 461 | size of the entries array), and the 'index' and 'data' members of each |
| 462 | array entry. |
| 463 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 464 | 4.20 KVM_SET_CPUID |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 465 | |
| 466 | Capability: basic |
| 467 | Architectures: x86 |
| 468 | Type: vcpu ioctl |
| 469 | Parameters: struct kvm_cpuid (in) |
| 470 | Returns: 0 on success, -1 on error |
| 471 | |
| 472 | Defines the vcpu responses to the cpuid instruction. Applications |
| 473 | should use the KVM_SET_CPUID2 ioctl if available. |
| 474 | |
| 475 | |
| 476 | struct kvm_cpuid_entry { |
| 477 | __u32 function; |
| 478 | __u32 eax; |
| 479 | __u32 ebx; |
| 480 | __u32 ecx; |
| 481 | __u32 edx; |
| 482 | __u32 padding; |
| 483 | }; |
| 484 | |
| 485 | /* for KVM_SET_CPUID */ |
| 486 | struct kvm_cpuid { |
| 487 | __u32 nent; |
| 488 | __u32 padding; |
| 489 | struct kvm_cpuid_entry entries[0]; |
| 490 | }; |
| 491 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 492 | 4.21 KVM_SET_SIGNAL_MASK |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 493 | |
| 494 | Capability: basic |
| 495 | Architectures: x86 |
| 496 | Type: vcpu ioctl |
| 497 | Parameters: struct kvm_signal_mask (in) |
| 498 | Returns: 0 on success, -1 on error |
| 499 | |
| 500 | Defines which signals are blocked during execution of KVM_RUN. This |
| 501 | signal mask temporarily overrides the threads signal mask. Any |
| 502 | unblocked signal received (except SIGKILL and SIGSTOP, which retain |
| 503 | their traditional behaviour) will cause KVM_RUN to return with -EINTR. |
| 504 | |
| 505 | Note the signal will only be delivered if not blocked by the original |
| 506 | signal mask. |
| 507 | |
| 508 | /* for KVM_SET_SIGNAL_MASK */ |
| 509 | struct kvm_signal_mask { |
| 510 | __u32 len; |
| 511 | __u8 sigset[0]; |
| 512 | }; |
| 513 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 514 | 4.22 KVM_GET_FPU |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 515 | |
| 516 | Capability: basic |
| 517 | Architectures: x86 |
| 518 | Type: vcpu ioctl |
| 519 | Parameters: struct kvm_fpu (out) |
| 520 | Returns: 0 on success, -1 on error |
| 521 | |
| 522 | Reads the floating point state from the vcpu. |
| 523 | |
| 524 | /* for KVM_GET_FPU and KVM_SET_FPU */ |
| 525 | struct kvm_fpu { |
| 526 | __u8 fpr[8][16]; |
| 527 | __u16 fcw; |
| 528 | __u16 fsw; |
| 529 | __u8 ftwx; /* in fxsave format */ |
| 530 | __u8 pad1; |
| 531 | __u16 last_opcode; |
| 532 | __u64 last_ip; |
| 533 | __u64 last_dp; |
| 534 | __u8 xmm[16][16]; |
| 535 | __u32 mxcsr; |
| 536 | __u32 pad2; |
| 537 | }; |
| 538 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 539 | 4.23 KVM_SET_FPU |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 540 | |
| 541 | Capability: basic |
| 542 | Architectures: x86 |
| 543 | Type: vcpu ioctl |
| 544 | Parameters: struct kvm_fpu (in) |
| 545 | Returns: 0 on success, -1 on error |
| 546 | |
| 547 | Writes the floating point state to the vcpu. |
| 548 | |
| 549 | /* for KVM_GET_FPU and KVM_SET_FPU */ |
| 550 | struct kvm_fpu { |
| 551 | __u8 fpr[8][16]; |
| 552 | __u16 fcw; |
| 553 | __u16 fsw; |
| 554 | __u8 ftwx; /* in fxsave format */ |
| 555 | __u8 pad1; |
| 556 | __u16 last_opcode; |
| 557 | __u64 last_ip; |
| 558 | __u64 last_dp; |
| 559 | __u8 xmm[16][16]; |
| 560 | __u32 mxcsr; |
| 561 | __u32 pad2; |
| 562 | }; |
| 563 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 564 | 4.24 KVM_CREATE_IRQCHIP |
Avi Kivity | 5dadbfd | 2009-08-23 17:08:04 +0300 | [diff] [blame] | 565 | |
| 566 | Capability: KVM_CAP_IRQCHIP |
| 567 | Architectures: x86, ia64 |
| 568 | Type: vm ioctl |
| 569 | Parameters: none |
| 570 | Returns: 0 on success, -1 on error |
| 571 | |
| 572 | Creates an interrupt controller model in the kernel. On x86, creates a virtual |
| 573 | ioapic, a virtual PIC (two PICs, nested), and sets up future vcpus to have a |
| 574 | local APIC. IRQ routing for GSIs 0-15 is set to both PIC and IOAPIC; GSI 16-23 |
| 575 | only go to the IOAPIC. On ia64, a IOSAPIC is created. |
| 576 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 577 | 4.25 KVM_IRQ_LINE |
Avi Kivity | 5dadbfd | 2009-08-23 17:08:04 +0300 | [diff] [blame] | 578 | |
| 579 | Capability: KVM_CAP_IRQCHIP |
| 580 | Architectures: x86, ia64 |
| 581 | Type: vm ioctl |
| 582 | Parameters: struct kvm_irq_level |
| 583 | Returns: 0 on success, -1 on error |
| 584 | |
| 585 | Sets the level of a GSI input to the interrupt controller model in the kernel. |
| 586 | Requires that an interrupt controller model has been previously created with |
| 587 | KVM_CREATE_IRQCHIP. Note that edge-triggered interrupts require the level |
| 588 | to be set to 1 and then back to 0. |
| 589 | |
| 590 | struct kvm_irq_level { |
| 591 | union { |
| 592 | __u32 irq; /* GSI */ |
| 593 | __s32 status; /* not used for KVM_IRQ_LEVEL */ |
| 594 | }; |
| 595 | __u32 level; /* 0 or 1 */ |
| 596 | }; |
| 597 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 598 | 4.26 KVM_GET_IRQCHIP |
Avi Kivity | 5dadbfd | 2009-08-23 17:08:04 +0300 | [diff] [blame] | 599 | |
| 600 | Capability: KVM_CAP_IRQCHIP |
| 601 | Architectures: x86, ia64 |
| 602 | Type: vm ioctl |
| 603 | Parameters: struct kvm_irqchip (in/out) |
| 604 | Returns: 0 on success, -1 on error |
| 605 | |
| 606 | Reads the state of a kernel interrupt controller created with |
| 607 | KVM_CREATE_IRQCHIP into a buffer provided by the caller. |
| 608 | |
| 609 | struct kvm_irqchip { |
| 610 | __u32 chip_id; /* 0 = PIC1, 1 = PIC2, 2 = IOAPIC */ |
| 611 | __u32 pad; |
| 612 | union { |
| 613 | char dummy[512]; /* reserving space */ |
| 614 | struct kvm_pic_state pic; |
| 615 | struct kvm_ioapic_state ioapic; |
| 616 | } chip; |
| 617 | }; |
| 618 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 619 | 4.27 KVM_SET_IRQCHIP |
Avi Kivity | 5dadbfd | 2009-08-23 17:08:04 +0300 | [diff] [blame] | 620 | |
| 621 | Capability: KVM_CAP_IRQCHIP |
| 622 | Architectures: x86, ia64 |
| 623 | Type: vm ioctl |
| 624 | Parameters: struct kvm_irqchip (in) |
| 625 | Returns: 0 on success, -1 on error |
| 626 | |
| 627 | Sets the state of a kernel interrupt controller created with |
| 628 | KVM_CREATE_IRQCHIP from a buffer provided by the caller. |
| 629 | |
| 630 | struct kvm_irqchip { |
| 631 | __u32 chip_id; /* 0 = PIC1, 1 = PIC2, 2 = IOAPIC */ |
| 632 | __u32 pad; |
| 633 | union { |
| 634 | char dummy[512]; /* reserving space */ |
| 635 | struct kvm_pic_state pic; |
| 636 | struct kvm_ioapic_state ioapic; |
| 637 | } chip; |
| 638 | }; |
| 639 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 640 | 4.28 KVM_XEN_HVM_CONFIG |
Ed Swierk | ffde22a | 2009-10-15 15:21:43 -0700 | [diff] [blame] | 641 | |
| 642 | Capability: KVM_CAP_XEN_HVM |
| 643 | Architectures: x86 |
| 644 | Type: vm ioctl |
| 645 | Parameters: struct kvm_xen_hvm_config (in) |
| 646 | Returns: 0 on success, -1 on error |
| 647 | |
| 648 | Sets the MSR that the Xen HVM guest uses to initialize its hypercall |
| 649 | page, and provides the starting address and size of the hypercall |
| 650 | blobs in userspace. When the guest writes the MSR, kvm copies one |
| 651 | page of a blob (32- or 64-bit, depending on the vcpu mode) to guest |
| 652 | memory. |
| 653 | |
| 654 | struct kvm_xen_hvm_config { |
| 655 | __u32 flags; |
| 656 | __u32 msr; |
| 657 | __u64 blob_addr_32; |
| 658 | __u64 blob_addr_64; |
| 659 | __u8 blob_size_32; |
| 660 | __u8 blob_size_64; |
| 661 | __u8 pad2[30]; |
| 662 | }; |
| 663 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 664 | 4.29 KVM_GET_CLOCK |
Glauber Costa | afbcf7a | 2009-10-16 15:28:36 -0400 | [diff] [blame] | 665 | |
| 666 | Capability: KVM_CAP_ADJUST_CLOCK |
| 667 | Architectures: x86 |
| 668 | Type: vm ioctl |
| 669 | Parameters: struct kvm_clock_data (out) |
| 670 | Returns: 0 on success, -1 on error |
| 671 | |
| 672 | Gets the current timestamp of kvmclock as seen by the current guest. In |
| 673 | conjunction with KVM_SET_CLOCK, it is used to ensure monotonicity on scenarios |
| 674 | such as migration. |
| 675 | |
| 676 | struct kvm_clock_data { |
| 677 | __u64 clock; /* kvmclock current value */ |
| 678 | __u32 flags; |
| 679 | __u32 pad[9]; |
| 680 | }; |
| 681 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 682 | 4.30 KVM_SET_CLOCK |
Glauber Costa | afbcf7a | 2009-10-16 15:28:36 -0400 | [diff] [blame] | 683 | |
| 684 | Capability: KVM_CAP_ADJUST_CLOCK |
| 685 | Architectures: x86 |
| 686 | Type: vm ioctl |
| 687 | Parameters: struct kvm_clock_data (in) |
| 688 | Returns: 0 on success, -1 on error |
| 689 | |
Wu Fengguang | 2044892d | 2009-12-24 09:04:16 +0800 | [diff] [blame] | 690 | 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] | 691 | In conjunction with KVM_GET_CLOCK, it is used to ensure monotonicity on scenarios |
| 692 | such as migration. |
| 693 | |
| 694 | struct kvm_clock_data { |
| 695 | __u64 clock; /* kvmclock current value */ |
| 696 | __u32 flags; |
| 697 | __u32 pad[9]; |
| 698 | }; |
| 699 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 700 | 4.31 KVM_GET_VCPU_EVENTS |
Jan Kiszka | 3cfc309 | 2009-11-12 01:04:25 +0100 | [diff] [blame] | 701 | |
| 702 | Capability: KVM_CAP_VCPU_EVENTS |
Jan Kiszka | 48005f6 | 2010-02-19 19:38:07 +0100 | [diff] [blame] | 703 | Extended by: KVM_CAP_INTR_SHADOW |
Jan Kiszka | 3cfc309 | 2009-11-12 01:04:25 +0100 | [diff] [blame] | 704 | Architectures: x86 |
| 705 | Type: vm ioctl |
| 706 | Parameters: struct kvm_vcpu_event (out) |
| 707 | Returns: 0 on success, -1 on error |
| 708 | |
| 709 | Gets currently pending exceptions, interrupts, and NMIs as well as related |
| 710 | states of the vcpu. |
| 711 | |
| 712 | struct kvm_vcpu_events { |
| 713 | struct { |
| 714 | __u8 injected; |
| 715 | __u8 nr; |
| 716 | __u8 has_error_code; |
| 717 | __u8 pad; |
| 718 | __u32 error_code; |
| 719 | } exception; |
| 720 | struct { |
| 721 | __u8 injected; |
| 722 | __u8 nr; |
| 723 | __u8 soft; |
Jan Kiszka | 48005f6 | 2010-02-19 19:38:07 +0100 | [diff] [blame] | 724 | __u8 shadow; |
Jan Kiszka | 3cfc309 | 2009-11-12 01:04:25 +0100 | [diff] [blame] | 725 | } interrupt; |
| 726 | struct { |
| 727 | __u8 injected; |
| 728 | __u8 pending; |
| 729 | __u8 masked; |
| 730 | __u8 pad; |
| 731 | } nmi; |
| 732 | __u32 sipi_vector; |
Jan Kiszka | dab4b91 | 2009-12-06 18:24:15 +0100 | [diff] [blame] | 733 | __u32 flags; |
Jan Kiszka | 3cfc309 | 2009-11-12 01:04:25 +0100 | [diff] [blame] | 734 | }; |
| 735 | |
Jan Kiszka | 48005f6 | 2010-02-19 19:38:07 +0100 | [diff] [blame] | 736 | KVM_VCPUEVENT_VALID_SHADOW may be set in the flags field to signal that |
| 737 | interrupt.shadow contains a valid state. Otherwise, this field is undefined. |
| 738 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 739 | 4.32 KVM_SET_VCPU_EVENTS |
Jan Kiszka | 3cfc309 | 2009-11-12 01:04:25 +0100 | [diff] [blame] | 740 | |
| 741 | Capability: KVM_CAP_VCPU_EVENTS |
Jan Kiszka | 48005f6 | 2010-02-19 19:38:07 +0100 | [diff] [blame] | 742 | Extended by: KVM_CAP_INTR_SHADOW |
Jan Kiszka | 3cfc309 | 2009-11-12 01:04:25 +0100 | [diff] [blame] | 743 | Architectures: x86 |
| 744 | Type: vm ioctl |
| 745 | Parameters: struct kvm_vcpu_event (in) |
| 746 | Returns: 0 on success, -1 on error |
| 747 | |
| 748 | Set pending exceptions, interrupts, and NMIs as well as related states of the |
| 749 | vcpu. |
| 750 | |
| 751 | See KVM_GET_VCPU_EVENTS for the data structure. |
| 752 | |
Jan Kiszka | dab4b91 | 2009-12-06 18:24:15 +0100 | [diff] [blame] | 753 | Fields that may be modified asynchronously by running VCPUs can be excluded |
| 754 | from the update. These fields are nmi.pending and sipi_vector. Keep the |
| 755 | corresponding bits in the flags field cleared to suppress overwriting the |
| 756 | current in-kernel state. The bits are: |
| 757 | |
| 758 | KVM_VCPUEVENT_VALID_NMI_PENDING - transfer nmi.pending to the kernel |
| 759 | KVM_VCPUEVENT_VALID_SIPI_VECTOR - transfer sipi_vector |
| 760 | |
Jan Kiszka | 48005f6 | 2010-02-19 19:38:07 +0100 | [diff] [blame] | 761 | If KVM_CAP_INTR_SHADOW is available, KVM_VCPUEVENT_VALID_SHADOW can be set in |
| 762 | the flags field to signal that interrupt.shadow contains a valid state and |
| 763 | shall be written into the VCPU. |
| 764 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 765 | 4.33 KVM_GET_DEBUGREGS |
Jan Kiszka | a1efbe7 | 2010-02-15 10:45:43 +0100 | [diff] [blame] | 766 | |
| 767 | Capability: KVM_CAP_DEBUGREGS |
| 768 | Architectures: x86 |
| 769 | Type: vm ioctl |
| 770 | Parameters: struct kvm_debugregs (out) |
| 771 | Returns: 0 on success, -1 on error |
| 772 | |
| 773 | Reads debug registers from the vcpu. |
| 774 | |
| 775 | struct kvm_debugregs { |
| 776 | __u64 db[4]; |
| 777 | __u64 dr6; |
| 778 | __u64 dr7; |
| 779 | __u64 flags; |
| 780 | __u64 reserved[9]; |
| 781 | }; |
| 782 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 783 | 4.34 KVM_SET_DEBUGREGS |
Jan Kiszka | a1efbe7 | 2010-02-15 10:45:43 +0100 | [diff] [blame] | 784 | |
| 785 | Capability: KVM_CAP_DEBUGREGS |
| 786 | Architectures: x86 |
| 787 | Type: vm ioctl |
| 788 | Parameters: struct kvm_debugregs (in) |
| 789 | Returns: 0 on success, -1 on error |
| 790 | |
| 791 | Writes debug registers into the vcpu. |
| 792 | |
| 793 | See KVM_GET_DEBUGREGS for the data structure. The flags field is unused |
| 794 | yet and must be cleared on entry. |
| 795 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 796 | 4.35 KVM_SET_USER_MEMORY_REGION |
Avi Kivity | 0f2d8f4 | 2010-03-25 12:16:48 +0200 | [diff] [blame] | 797 | |
| 798 | Capability: KVM_CAP_USER_MEM |
| 799 | Architectures: all |
| 800 | Type: vm ioctl |
| 801 | Parameters: struct kvm_userspace_memory_region (in) |
| 802 | Returns: 0 on success, -1 on error |
| 803 | |
| 804 | struct kvm_userspace_memory_region { |
| 805 | __u32 slot; |
| 806 | __u32 flags; |
| 807 | __u64 guest_phys_addr; |
| 808 | __u64 memory_size; /* bytes */ |
| 809 | __u64 userspace_addr; /* start of the userspace allocated memory */ |
| 810 | }; |
| 811 | |
| 812 | /* for kvm_memory_region::flags */ |
| 813 | #define KVM_MEM_LOG_DIRTY_PAGES 1UL |
| 814 | |
| 815 | This ioctl allows the user to create or modify a guest physical memory |
| 816 | slot. When changing an existing slot, it may be moved in the guest |
| 817 | physical memory space, or its flags may be modified. It may not be |
| 818 | resized. Slots may not overlap in guest physical address space. |
| 819 | |
| 820 | Memory for the region is taken starting at the address denoted by the |
| 821 | field userspace_addr, which must point at user addressable memory for |
| 822 | the entire memory slot size. Any object may back this memory, including |
| 823 | anonymous memory, ordinary files, and hugetlbfs. |
| 824 | |
| 825 | It is recommended that the lower 21 bits of guest_phys_addr and userspace_addr |
| 826 | be identical. This allows large pages in the guest to be backed by large |
| 827 | pages in the host. |
| 828 | |
| 829 | The flags field supports just one flag, KVM_MEM_LOG_DIRTY_PAGES, which |
| 830 | instructs kvm to keep track of writes to memory within the slot. See |
| 831 | the KVM_GET_DIRTY_LOG ioctl. |
| 832 | |
| 833 | When the KVM_CAP_SYNC_MMU capability, changes in the backing of the memory |
| 834 | region are automatically reflected into the guest. For example, an mmap() |
| 835 | that affects the region will be made visible immediately. Another example |
| 836 | is madvise(MADV_DROP). |
| 837 | |
| 838 | It is recommended to use this API instead of the KVM_SET_MEMORY_REGION ioctl. |
| 839 | The KVM_SET_MEMORY_REGION does not allow fine grained control over memory |
| 840 | allocation and is deprecated. |
Jan Kiszka | 3cfc309 | 2009-11-12 01:04:25 +0100 | [diff] [blame] | 841 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 842 | 4.36 KVM_SET_TSS_ADDR |
Avi Kivity | 8a5416d | 2010-03-25 12:27:30 +0200 | [diff] [blame] | 843 | |
| 844 | Capability: KVM_CAP_SET_TSS_ADDR |
| 845 | Architectures: x86 |
| 846 | Type: vm ioctl |
| 847 | Parameters: unsigned long tss_address (in) |
| 848 | Returns: 0 on success, -1 on error |
| 849 | |
| 850 | This ioctl defines the physical address of a three-page region in the guest |
| 851 | physical address space. The region must be within the first 4GB of the |
| 852 | guest physical address space and must not conflict with any memory slot |
| 853 | or any mmio address. The guest may malfunction if it accesses this memory |
| 854 | region. |
| 855 | |
| 856 | This ioctl is required on Intel-based hosts. This is needed on Intel hardware |
| 857 | because of a quirk in the virtualization implementation (see the internals |
| 858 | documentation when it pops into existence). |
| 859 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 860 | 4.37 KVM_ENABLE_CAP |
Alexander Graf | 71fbfd5 | 2010-03-24 21:48:29 +0100 | [diff] [blame] | 861 | |
| 862 | Capability: KVM_CAP_ENABLE_CAP |
| 863 | Architectures: ppc |
| 864 | Type: vcpu ioctl |
| 865 | Parameters: struct kvm_enable_cap (in) |
| 866 | Returns: 0 on success; -1 on error |
| 867 | |
| 868 | +Not all extensions are enabled by default. Using this ioctl the application |
| 869 | can enable an extension, making it available to the guest. |
| 870 | |
| 871 | On systems that do not support this ioctl, it always fails. On systems that |
| 872 | do support it, it only works for extensions that are supported for enablement. |
| 873 | |
| 874 | To check if a capability can be enabled, the KVM_CHECK_EXTENSION ioctl should |
| 875 | be used. |
| 876 | |
| 877 | struct kvm_enable_cap { |
| 878 | /* in */ |
| 879 | __u32 cap; |
| 880 | |
| 881 | The capability that is supposed to get enabled. |
| 882 | |
| 883 | __u32 flags; |
| 884 | |
| 885 | A bitfield indicating future enhancements. Has to be 0 for now. |
| 886 | |
| 887 | __u64 args[4]; |
| 888 | |
| 889 | Arguments for enabling a feature. If a feature needs initial values to |
| 890 | function properly, this is the place to put them. |
| 891 | |
| 892 | __u8 pad[64]; |
| 893 | }; |
| 894 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 895 | 4.38 KVM_GET_MP_STATE |
Avi Kivity | b843f06 | 2010-04-25 15:51:46 +0300 | [diff] [blame] | 896 | |
| 897 | Capability: KVM_CAP_MP_STATE |
| 898 | Architectures: x86, ia64 |
| 899 | Type: vcpu ioctl |
| 900 | Parameters: struct kvm_mp_state (out) |
| 901 | Returns: 0 on success; -1 on error |
| 902 | |
| 903 | struct kvm_mp_state { |
| 904 | __u32 mp_state; |
| 905 | }; |
| 906 | |
| 907 | Returns the vcpu's current "multiprocessing state" (though also valid on |
| 908 | uniprocessor guests). |
| 909 | |
| 910 | Possible values are: |
| 911 | |
| 912 | - KVM_MP_STATE_RUNNABLE: the vcpu is currently running |
| 913 | - KVM_MP_STATE_UNINITIALIZED: the vcpu is an application processor (AP) |
| 914 | which has not yet received an INIT signal |
| 915 | - KVM_MP_STATE_INIT_RECEIVED: the vcpu has received an INIT signal, and is |
| 916 | now ready for a SIPI |
| 917 | - KVM_MP_STATE_HALTED: the vcpu has executed a HLT instruction and |
| 918 | is waiting for an interrupt |
| 919 | - 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] | 920 | accessible via KVM_GET_VCPU_EVENTS) |
Avi Kivity | b843f06 | 2010-04-25 15:51:46 +0300 | [diff] [blame] | 921 | |
| 922 | This ioctl is only useful after KVM_CREATE_IRQCHIP. Without an in-kernel |
| 923 | irqchip, the multiprocessing state must be maintained by userspace. |
| 924 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 925 | 4.39 KVM_SET_MP_STATE |
Avi Kivity | b843f06 | 2010-04-25 15:51:46 +0300 | [diff] [blame] | 926 | |
| 927 | Capability: KVM_CAP_MP_STATE |
| 928 | Architectures: x86, ia64 |
| 929 | Type: vcpu ioctl |
| 930 | Parameters: struct kvm_mp_state (in) |
| 931 | Returns: 0 on success; -1 on error |
| 932 | |
| 933 | Sets the vcpu's current "multiprocessing state"; see KVM_GET_MP_STATE for |
| 934 | arguments. |
| 935 | |
| 936 | This ioctl is only useful after KVM_CREATE_IRQCHIP. Without an in-kernel |
| 937 | irqchip, the multiprocessing state must be maintained by userspace. |
| 938 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 939 | 4.40 KVM_SET_IDENTITY_MAP_ADDR |
Avi Kivity | 47dbb84 | 2010-04-29 12:08:56 +0300 | [diff] [blame] | 940 | |
| 941 | Capability: KVM_CAP_SET_IDENTITY_MAP_ADDR |
| 942 | Architectures: x86 |
| 943 | Type: vm ioctl |
| 944 | Parameters: unsigned long identity (in) |
| 945 | Returns: 0 on success, -1 on error |
| 946 | |
| 947 | This ioctl defines the physical address of a one-page region in the guest |
| 948 | physical address space. The region must be within the first 4GB of the |
| 949 | guest physical address space and must not conflict with any memory slot |
| 950 | or any mmio address. The guest may malfunction if it accesses this memory |
| 951 | region. |
| 952 | |
| 953 | This ioctl is required on Intel-based hosts. This is needed on Intel hardware |
| 954 | because of a quirk in the virtualization implementation (see the internals |
| 955 | documentation when it pops into existence). |
| 956 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 957 | 4.41 KVM_SET_BOOT_CPU_ID |
Avi Kivity | 57bc24c | 2010-04-29 12:12:57 +0300 | [diff] [blame] | 958 | |
| 959 | Capability: KVM_CAP_SET_BOOT_CPU_ID |
| 960 | Architectures: x86, ia64 |
| 961 | Type: vm ioctl |
| 962 | Parameters: unsigned long vcpu_id |
| 963 | Returns: 0 on success, -1 on error |
| 964 | |
| 965 | Define which vcpu is the Bootstrap Processor (BSP). Values are the same |
| 966 | as the vcpu id in KVM_CREATE_VCPU. If this ioctl is not called, the default |
| 967 | is vcpu 0. |
| 968 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 969 | 4.42 KVM_GET_XSAVE |
Sheng Yang | 2d5b5a6 | 2010-06-13 17:29:39 +0800 | [diff] [blame] | 970 | |
| 971 | Capability: KVM_CAP_XSAVE |
| 972 | Architectures: x86 |
| 973 | Type: vcpu ioctl |
| 974 | Parameters: struct kvm_xsave (out) |
| 975 | Returns: 0 on success, -1 on error |
| 976 | |
| 977 | struct kvm_xsave { |
| 978 | __u32 region[1024]; |
| 979 | }; |
| 980 | |
| 981 | This ioctl would copy current vcpu's xsave struct to the userspace. |
| 982 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 983 | 4.43 KVM_SET_XSAVE |
Sheng Yang | 2d5b5a6 | 2010-06-13 17:29:39 +0800 | [diff] [blame] | 984 | |
| 985 | Capability: KVM_CAP_XSAVE |
| 986 | Architectures: x86 |
| 987 | Type: vcpu ioctl |
| 988 | Parameters: struct kvm_xsave (in) |
| 989 | Returns: 0 on success, -1 on error |
| 990 | |
| 991 | struct kvm_xsave { |
| 992 | __u32 region[1024]; |
| 993 | }; |
| 994 | |
| 995 | This ioctl would copy userspace's xsave struct to the kernel. |
| 996 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 997 | 4.44 KVM_GET_XCRS |
Sheng Yang | 2d5b5a6 | 2010-06-13 17:29:39 +0800 | [diff] [blame] | 998 | |
| 999 | Capability: KVM_CAP_XCRS |
| 1000 | Architectures: x86 |
| 1001 | Type: vcpu ioctl |
| 1002 | Parameters: struct kvm_xcrs (out) |
| 1003 | Returns: 0 on success, -1 on error |
| 1004 | |
| 1005 | struct kvm_xcr { |
| 1006 | __u32 xcr; |
| 1007 | __u32 reserved; |
| 1008 | __u64 value; |
| 1009 | }; |
| 1010 | |
| 1011 | struct kvm_xcrs { |
| 1012 | __u32 nr_xcrs; |
| 1013 | __u32 flags; |
| 1014 | struct kvm_xcr xcrs[KVM_MAX_XCRS]; |
| 1015 | __u64 padding[16]; |
| 1016 | }; |
| 1017 | |
| 1018 | This ioctl would copy current vcpu's xcrs to the userspace. |
| 1019 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1020 | 4.45 KVM_SET_XCRS |
Sheng Yang | 2d5b5a6 | 2010-06-13 17:29:39 +0800 | [diff] [blame] | 1021 | |
| 1022 | Capability: KVM_CAP_XCRS |
| 1023 | Architectures: x86 |
| 1024 | Type: vcpu ioctl |
| 1025 | Parameters: struct kvm_xcrs (in) |
| 1026 | Returns: 0 on success, -1 on error |
| 1027 | |
| 1028 | struct kvm_xcr { |
| 1029 | __u32 xcr; |
| 1030 | __u32 reserved; |
| 1031 | __u64 value; |
| 1032 | }; |
| 1033 | |
| 1034 | struct kvm_xcrs { |
| 1035 | __u32 nr_xcrs; |
| 1036 | __u32 flags; |
| 1037 | struct kvm_xcr xcrs[KVM_MAX_XCRS]; |
| 1038 | __u64 padding[16]; |
| 1039 | }; |
| 1040 | |
| 1041 | This ioctl would set vcpu's xcr to the value userspace specified. |
| 1042 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1043 | 4.46 KVM_GET_SUPPORTED_CPUID |
Avi Kivity | d153513 | 2010-07-14 09:45:21 +0300 | [diff] [blame] | 1044 | |
| 1045 | Capability: KVM_CAP_EXT_CPUID |
| 1046 | Architectures: x86 |
| 1047 | Type: system ioctl |
| 1048 | Parameters: struct kvm_cpuid2 (in/out) |
| 1049 | Returns: 0 on success, -1 on error |
| 1050 | |
| 1051 | struct kvm_cpuid2 { |
| 1052 | __u32 nent; |
| 1053 | __u32 padding; |
| 1054 | struct kvm_cpuid_entry2 entries[0]; |
| 1055 | }; |
| 1056 | |
| 1057 | #define KVM_CPUID_FLAG_SIGNIFCANT_INDEX 1 |
| 1058 | #define KVM_CPUID_FLAG_STATEFUL_FUNC 2 |
| 1059 | #define KVM_CPUID_FLAG_STATE_READ_NEXT 4 |
| 1060 | |
| 1061 | struct kvm_cpuid_entry2 { |
| 1062 | __u32 function; |
| 1063 | __u32 index; |
| 1064 | __u32 flags; |
| 1065 | __u32 eax; |
| 1066 | __u32 ebx; |
| 1067 | __u32 ecx; |
| 1068 | __u32 edx; |
| 1069 | __u32 padding[3]; |
| 1070 | }; |
| 1071 | |
| 1072 | This ioctl returns x86 cpuid features which are supported by both the hardware |
| 1073 | and kvm. Userspace can use the information returned by this ioctl to |
| 1074 | construct cpuid information (for KVM_SET_CPUID2) that is consistent with |
| 1075 | hardware, kernel, and userspace capabilities, and with user requirements (for |
| 1076 | example, the user may wish to constrain cpuid to emulate older hardware, |
| 1077 | or for feature consistency across a cluster). |
| 1078 | |
| 1079 | Userspace invokes KVM_GET_SUPPORTED_CPUID by passing a kvm_cpuid2 structure |
| 1080 | with the 'nent' field indicating the number of entries in the variable-size |
| 1081 | array 'entries'. If the number of entries is too low to describe the cpu |
| 1082 | capabilities, an error (E2BIG) is returned. If the number is too high, |
| 1083 | the 'nent' field is adjusted and an error (ENOMEM) is returned. If the |
| 1084 | number is just right, the 'nent' field is adjusted to the number of valid |
| 1085 | entries in the 'entries' array, which is then filled. |
| 1086 | |
| 1087 | 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] | 1088 | with unknown or unsupported features masked out. Some features (for example, |
| 1089 | x2apic), may not be present in the host cpu, but are exposed by kvm if it can |
| 1090 | emulate them efficiently. The fields in each entry are defined as follows: |
Avi Kivity | d153513 | 2010-07-14 09:45:21 +0300 | [diff] [blame] | 1091 | |
| 1092 | function: the eax value used to obtain the entry |
| 1093 | index: the ecx value used to obtain the entry (for entries that are |
| 1094 | affected by ecx) |
| 1095 | flags: an OR of zero or more of the following: |
| 1096 | KVM_CPUID_FLAG_SIGNIFCANT_INDEX: |
| 1097 | if the index field is valid |
| 1098 | KVM_CPUID_FLAG_STATEFUL_FUNC: |
| 1099 | if cpuid for this function returns different values for successive |
| 1100 | invocations; there will be several entries with the same function, |
| 1101 | all with this flag set |
| 1102 | KVM_CPUID_FLAG_STATE_READ_NEXT: |
| 1103 | for KVM_CPUID_FLAG_STATEFUL_FUNC entries, set if this entry is |
| 1104 | the first entry to be read by a cpu |
| 1105 | eax, ebx, ecx, edx: the values returned by the cpuid instruction for |
| 1106 | this function/index combination |
| 1107 | |
Jan Kiszka | 4d25a066 | 2011-12-21 12:28:29 +0100 | [diff] [blame] | 1108 | The TSC deadline timer feature (CPUID leaf 1, ecx[24]) is always returned |
| 1109 | as false, since the feature depends on KVM_CREATE_IRQCHIP for local APIC |
| 1110 | support. Instead it is reported via |
| 1111 | |
| 1112 | ioctl(KVM_CHECK_EXTENSION, KVM_CAP_TSC_DEADLINE_TIMER) |
| 1113 | |
| 1114 | if that returns true and you use KVM_CREATE_IRQCHIP, or if you emulate the |
| 1115 | feature in userspace, then you can enable the feature for KVM_SET_CPUID2. |
| 1116 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1117 | 4.47 KVM_PPC_GET_PVINFO |
Alexander Graf | 15711e9 | 2010-07-29 14:48:08 +0200 | [diff] [blame] | 1118 | |
| 1119 | Capability: KVM_CAP_PPC_GET_PVINFO |
| 1120 | Architectures: ppc |
| 1121 | Type: vm ioctl |
| 1122 | Parameters: struct kvm_ppc_pvinfo (out) |
| 1123 | Returns: 0 on success, !0 on error |
| 1124 | |
| 1125 | struct kvm_ppc_pvinfo { |
| 1126 | __u32 flags; |
| 1127 | __u32 hcall[4]; |
| 1128 | __u8 pad[108]; |
| 1129 | }; |
| 1130 | |
| 1131 | This ioctl fetches PV specific information that need to be passed to the guest |
| 1132 | using the device tree or other means from vm context. |
| 1133 | |
| 1134 | For now the only implemented piece of information distributed here is an array |
| 1135 | of 4 instructions that make up a hypercall. |
| 1136 | |
| 1137 | If any additional field gets added to this structure later on, a bit for that |
| 1138 | additional piece of information will be set in the flags bitmap. |
| 1139 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1140 | 4.48 KVM_ASSIGN_PCI_DEVICE |
Jan Kiszka | 49f4817 | 2010-11-16 22:30:07 +0100 | [diff] [blame] | 1141 | |
| 1142 | Capability: KVM_CAP_DEVICE_ASSIGNMENT |
| 1143 | Architectures: x86 ia64 |
| 1144 | Type: vm ioctl |
| 1145 | Parameters: struct kvm_assigned_pci_dev (in) |
| 1146 | Returns: 0 on success, -1 on error |
| 1147 | |
| 1148 | Assigns a host PCI device to the VM. |
| 1149 | |
| 1150 | struct kvm_assigned_pci_dev { |
| 1151 | __u32 assigned_dev_id; |
| 1152 | __u32 busnr; |
| 1153 | __u32 devfn; |
| 1154 | __u32 flags; |
| 1155 | __u32 segnr; |
| 1156 | union { |
| 1157 | __u32 reserved[11]; |
| 1158 | }; |
| 1159 | }; |
| 1160 | |
| 1161 | The PCI device is specified by the triple segnr, busnr, and devfn. |
| 1162 | Identification in succeeding service requests is done via assigned_dev_id. The |
| 1163 | following flags are specified: |
| 1164 | |
| 1165 | /* Depends on KVM_CAP_IOMMU */ |
| 1166 | #define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0) |
| 1167 | |
Alex Williamson | 4238737 | 2011-12-20 21:59:03 -0700 | [diff] [blame] | 1168 | The KVM_DEV_ASSIGN_ENABLE_IOMMU flag is a mandatory option to ensure |
| 1169 | isolation of the device. Usages not specifying this flag are deprecated. |
| 1170 | |
Alex Williamson | 3d27e23 | 2011-12-20 21:59:09 -0700 | [diff] [blame] | 1171 | Only PCI header type 0 devices with PCI BAR resources are supported by |
| 1172 | device assignment. The user requesting this ioctl must have read/write |
| 1173 | access to the PCI sysfs resource files associated with the device. |
| 1174 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1175 | 4.49 KVM_DEASSIGN_PCI_DEVICE |
Jan Kiszka | 49f4817 | 2010-11-16 22:30:07 +0100 | [diff] [blame] | 1176 | |
| 1177 | Capability: KVM_CAP_DEVICE_DEASSIGNMENT |
| 1178 | Architectures: x86 ia64 |
| 1179 | Type: vm ioctl |
| 1180 | Parameters: struct kvm_assigned_pci_dev (in) |
| 1181 | Returns: 0 on success, -1 on error |
| 1182 | |
| 1183 | Ends PCI device assignment, releasing all associated resources. |
| 1184 | |
| 1185 | See KVM_CAP_DEVICE_ASSIGNMENT for the data structure. Only assigned_dev_id is |
| 1186 | used in kvm_assigned_pci_dev to identify the device. |
| 1187 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1188 | 4.50 KVM_ASSIGN_DEV_IRQ |
Jan Kiszka | 49f4817 | 2010-11-16 22:30:07 +0100 | [diff] [blame] | 1189 | |
| 1190 | Capability: KVM_CAP_ASSIGN_DEV_IRQ |
| 1191 | Architectures: x86 ia64 |
| 1192 | Type: vm ioctl |
| 1193 | Parameters: struct kvm_assigned_irq (in) |
| 1194 | Returns: 0 on success, -1 on error |
| 1195 | |
| 1196 | Assigns an IRQ to a passed-through device. |
| 1197 | |
| 1198 | struct kvm_assigned_irq { |
| 1199 | __u32 assigned_dev_id; |
Jan Kiszka | 91e3d71 | 2011-06-03 08:51:05 +0200 | [diff] [blame] | 1200 | __u32 host_irq; /* ignored (legacy field) */ |
Jan Kiszka | 49f4817 | 2010-11-16 22:30:07 +0100 | [diff] [blame] | 1201 | __u32 guest_irq; |
| 1202 | __u32 flags; |
| 1203 | union { |
Jan Kiszka | 49f4817 | 2010-11-16 22:30:07 +0100 | [diff] [blame] | 1204 | __u32 reserved[12]; |
| 1205 | }; |
| 1206 | }; |
| 1207 | |
| 1208 | The following flags are defined: |
| 1209 | |
| 1210 | #define KVM_DEV_IRQ_HOST_INTX (1 << 0) |
| 1211 | #define KVM_DEV_IRQ_HOST_MSI (1 << 1) |
| 1212 | #define KVM_DEV_IRQ_HOST_MSIX (1 << 2) |
| 1213 | |
| 1214 | #define KVM_DEV_IRQ_GUEST_INTX (1 << 8) |
| 1215 | #define KVM_DEV_IRQ_GUEST_MSI (1 << 9) |
| 1216 | #define KVM_DEV_IRQ_GUEST_MSIX (1 << 10) |
| 1217 | |
| 1218 | It is not valid to specify multiple types per host or guest IRQ. However, the |
| 1219 | IRQ type of host and guest can differ or can even be null. |
| 1220 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1221 | 4.51 KVM_DEASSIGN_DEV_IRQ |
Jan Kiszka | 49f4817 | 2010-11-16 22:30:07 +0100 | [diff] [blame] | 1222 | |
| 1223 | Capability: KVM_CAP_ASSIGN_DEV_IRQ |
| 1224 | Architectures: x86 ia64 |
| 1225 | Type: vm ioctl |
| 1226 | Parameters: struct kvm_assigned_irq (in) |
| 1227 | Returns: 0 on success, -1 on error |
| 1228 | |
| 1229 | Ends an IRQ assignment to a passed-through device. |
| 1230 | |
| 1231 | See KVM_ASSIGN_DEV_IRQ for the data structure. The target device is specified |
| 1232 | by assigned_dev_id, flags must correspond to the IRQ type specified on |
| 1233 | KVM_ASSIGN_DEV_IRQ. Partial deassignment of host or guest IRQ is allowed. |
| 1234 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1235 | 4.52 KVM_SET_GSI_ROUTING |
Jan Kiszka | 49f4817 | 2010-11-16 22:30:07 +0100 | [diff] [blame] | 1236 | |
| 1237 | Capability: KVM_CAP_IRQ_ROUTING |
| 1238 | Architectures: x86 ia64 |
| 1239 | Type: vm ioctl |
| 1240 | Parameters: struct kvm_irq_routing (in) |
| 1241 | Returns: 0 on success, -1 on error |
| 1242 | |
| 1243 | Sets the GSI routing table entries, overwriting any previously set entries. |
| 1244 | |
| 1245 | struct kvm_irq_routing { |
| 1246 | __u32 nr; |
| 1247 | __u32 flags; |
| 1248 | struct kvm_irq_routing_entry entries[0]; |
| 1249 | }; |
| 1250 | |
| 1251 | No flags are specified so far, the corresponding field must be set to zero. |
| 1252 | |
| 1253 | struct kvm_irq_routing_entry { |
| 1254 | __u32 gsi; |
| 1255 | __u32 type; |
| 1256 | __u32 flags; |
| 1257 | __u32 pad; |
| 1258 | union { |
| 1259 | struct kvm_irq_routing_irqchip irqchip; |
| 1260 | struct kvm_irq_routing_msi msi; |
| 1261 | __u32 pad[8]; |
| 1262 | } u; |
| 1263 | }; |
| 1264 | |
| 1265 | /* gsi routing entry types */ |
| 1266 | #define KVM_IRQ_ROUTING_IRQCHIP 1 |
| 1267 | #define KVM_IRQ_ROUTING_MSI 2 |
| 1268 | |
| 1269 | No flags are specified so far, the corresponding field must be set to zero. |
| 1270 | |
| 1271 | struct kvm_irq_routing_irqchip { |
| 1272 | __u32 irqchip; |
| 1273 | __u32 pin; |
| 1274 | }; |
| 1275 | |
| 1276 | struct kvm_irq_routing_msi { |
| 1277 | __u32 address_lo; |
| 1278 | __u32 address_hi; |
| 1279 | __u32 data; |
| 1280 | __u32 pad; |
| 1281 | }; |
| 1282 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1283 | 4.53 KVM_ASSIGN_SET_MSIX_NR |
Jan Kiszka | 49f4817 | 2010-11-16 22:30:07 +0100 | [diff] [blame] | 1284 | |
| 1285 | Capability: KVM_CAP_DEVICE_MSIX |
| 1286 | Architectures: x86 ia64 |
| 1287 | Type: vm ioctl |
| 1288 | Parameters: struct kvm_assigned_msix_nr (in) |
| 1289 | Returns: 0 on success, -1 on error |
| 1290 | |
Jan Kiszka | 58f0964 | 2011-06-11 12:24:24 +0200 | [diff] [blame] | 1291 | Set the number of MSI-X interrupts for an assigned device. The number is |
| 1292 | reset again by terminating the MSI-X assignment of the device via |
| 1293 | KVM_DEASSIGN_DEV_IRQ. Calling this service more than once at any earlier |
| 1294 | point will fail. |
Jan Kiszka | 49f4817 | 2010-11-16 22:30:07 +0100 | [diff] [blame] | 1295 | |
| 1296 | struct kvm_assigned_msix_nr { |
| 1297 | __u32 assigned_dev_id; |
| 1298 | __u16 entry_nr; |
| 1299 | __u16 padding; |
| 1300 | }; |
| 1301 | |
| 1302 | #define KVM_MAX_MSIX_PER_DEV 256 |
| 1303 | |
Paul Bolle | 68ba697 | 2011-02-15 00:05:59 +0100 | [diff] [blame] | 1304 | 4.54 KVM_ASSIGN_SET_MSIX_ENTRY |
Jan Kiszka | 49f4817 | 2010-11-16 22:30:07 +0100 | [diff] [blame] | 1305 | |
| 1306 | Capability: KVM_CAP_DEVICE_MSIX |
| 1307 | Architectures: x86 ia64 |
| 1308 | Type: vm ioctl |
| 1309 | Parameters: struct kvm_assigned_msix_entry (in) |
| 1310 | Returns: 0 on success, -1 on error |
| 1311 | |
| 1312 | Specifies the routing of an MSI-X assigned device interrupt to a GSI. Setting |
| 1313 | the GSI vector to zero means disabling the interrupt. |
| 1314 | |
| 1315 | struct kvm_assigned_msix_entry { |
| 1316 | __u32 assigned_dev_id; |
| 1317 | __u32 gsi; |
| 1318 | __u16 entry; /* The index of entry in the MSI-X table */ |
| 1319 | __u16 padding[3]; |
| 1320 | }; |
| 1321 | |
Joerg Roedel | 92a1f12 | 2011-03-25 09:44:51 +0100 | [diff] [blame] | 1322 | 4.54 KVM_SET_TSC_KHZ |
| 1323 | |
| 1324 | Capability: KVM_CAP_TSC_CONTROL |
| 1325 | Architectures: x86 |
| 1326 | Type: vcpu ioctl |
| 1327 | Parameters: virtual tsc_khz |
| 1328 | Returns: 0 on success, -1 on error |
| 1329 | |
| 1330 | Specifies the tsc frequency for the virtual machine. The unit of the |
| 1331 | frequency is KHz. |
| 1332 | |
| 1333 | 4.55 KVM_GET_TSC_KHZ |
| 1334 | |
| 1335 | Capability: KVM_CAP_GET_TSC_KHZ |
| 1336 | Architectures: x86 |
| 1337 | Type: vcpu ioctl |
| 1338 | Parameters: none |
| 1339 | Returns: virtual tsc-khz on success, negative value on error |
| 1340 | |
| 1341 | Returns the tsc frequency of the guest. The unit of the return value is |
| 1342 | KHz. If the host has unstable tsc this ioctl returns -EIO instead as an |
| 1343 | error. |
| 1344 | |
Avi Kivity | e767793 | 2011-05-11 08:30:51 -0400 | [diff] [blame] | 1345 | 4.56 KVM_GET_LAPIC |
| 1346 | |
| 1347 | Capability: KVM_CAP_IRQCHIP |
| 1348 | Architectures: x86 |
| 1349 | Type: vcpu ioctl |
| 1350 | Parameters: struct kvm_lapic_state (out) |
| 1351 | Returns: 0 on success, -1 on error |
| 1352 | |
| 1353 | #define KVM_APIC_REG_SIZE 0x400 |
| 1354 | struct kvm_lapic_state { |
| 1355 | char regs[KVM_APIC_REG_SIZE]; |
| 1356 | }; |
| 1357 | |
| 1358 | Reads the Local APIC registers and copies them into the input argument. The |
| 1359 | data format and layout are the same as documented in the architecture manual. |
| 1360 | |
| 1361 | 4.57 KVM_SET_LAPIC |
| 1362 | |
| 1363 | Capability: KVM_CAP_IRQCHIP |
| 1364 | Architectures: x86 |
| 1365 | Type: vcpu ioctl |
| 1366 | Parameters: struct kvm_lapic_state (in) |
| 1367 | Returns: 0 on success, -1 on error |
| 1368 | |
| 1369 | #define KVM_APIC_REG_SIZE 0x400 |
| 1370 | struct kvm_lapic_state { |
| 1371 | char regs[KVM_APIC_REG_SIZE]; |
| 1372 | }; |
| 1373 | |
| 1374 | Copies the input argument into the the Local APIC registers. The data format |
| 1375 | and layout are the same as documented in the architecture manual. |
| 1376 | |
Jan Kiszka | 7f4382e | 2011-06-02 16:16:20 +0200 | [diff] [blame] | 1377 | 4.58 KVM_IOEVENTFD |
Sasha Levin | 55399a0 | 2011-05-28 14:12:30 +0300 | [diff] [blame] | 1378 | |
| 1379 | Capability: KVM_CAP_IOEVENTFD |
| 1380 | Architectures: all |
| 1381 | Type: vm ioctl |
| 1382 | Parameters: struct kvm_ioeventfd (in) |
| 1383 | Returns: 0 on success, !0 on error |
| 1384 | |
| 1385 | This ioctl attaches or detaches an ioeventfd to a legal pio/mmio address |
| 1386 | within the guest. A guest write in the registered address will signal the |
| 1387 | provided event instead of triggering an exit. |
| 1388 | |
| 1389 | struct kvm_ioeventfd { |
| 1390 | __u64 datamatch; |
| 1391 | __u64 addr; /* legal pio/mmio address */ |
| 1392 | __u32 len; /* 1, 2, 4, or 8 bytes */ |
| 1393 | __s32 fd; |
| 1394 | __u32 flags; |
| 1395 | __u8 pad[36]; |
| 1396 | }; |
| 1397 | |
| 1398 | The following flags are defined: |
| 1399 | |
| 1400 | #define KVM_IOEVENTFD_FLAG_DATAMATCH (1 << kvm_ioeventfd_flag_nr_datamatch) |
| 1401 | #define KVM_IOEVENTFD_FLAG_PIO (1 << kvm_ioeventfd_flag_nr_pio) |
| 1402 | #define KVM_IOEVENTFD_FLAG_DEASSIGN (1 << kvm_ioeventfd_flag_nr_deassign) |
| 1403 | |
| 1404 | If datamatch flag is set, the event will be signaled only if the written value |
| 1405 | to the registered address is equal to datamatch in struct kvm_ioeventfd. |
| 1406 | |
David Gibson | 54738c0 | 2011-06-29 00:22:41 +0000 | [diff] [blame] | 1407 | 4.62 KVM_CREATE_SPAPR_TCE |
| 1408 | |
| 1409 | Capability: KVM_CAP_SPAPR_TCE |
| 1410 | Architectures: powerpc |
| 1411 | Type: vm ioctl |
| 1412 | Parameters: struct kvm_create_spapr_tce (in) |
| 1413 | Returns: file descriptor for manipulating the created TCE table |
| 1414 | |
| 1415 | This creates a virtual TCE (translation control entry) table, which |
| 1416 | is an IOMMU for PAPR-style virtual I/O. It is used to translate |
| 1417 | logical addresses used in virtual I/O into guest physical addresses, |
| 1418 | and provides a scatter/gather capability for PAPR virtual I/O. |
| 1419 | |
| 1420 | /* for KVM_CAP_SPAPR_TCE */ |
| 1421 | struct kvm_create_spapr_tce { |
| 1422 | __u64 liobn; |
| 1423 | __u32 window_size; |
| 1424 | }; |
| 1425 | |
| 1426 | The liobn field gives the logical IO bus number for which to create a |
| 1427 | TCE table. The window_size field specifies the size of the DMA window |
| 1428 | which this TCE table will translate - the table will contain one 64 |
| 1429 | bit TCE entry for every 4kiB of the DMA window. |
| 1430 | |
| 1431 | When the guest issues an H_PUT_TCE hcall on a liobn for which a TCE |
| 1432 | table has been created using this ioctl(), the kernel will handle it |
| 1433 | in real mode, updating the TCE table. H_PUT_TCE calls for other |
| 1434 | liobns will cause a vm exit and must be handled by userspace. |
| 1435 | |
| 1436 | The return value is a file descriptor which can be passed to mmap(2) |
| 1437 | to map the created TCE table into userspace. This lets userspace read |
| 1438 | the entries written by kernel-handled H_PUT_TCE calls, and also lets |
| 1439 | userspace update the TCE table directly which is useful in some |
| 1440 | circumstances. |
| 1441 | |
Paul Mackerras | aa04b4c | 2011-06-29 00:25:44 +0000 | [diff] [blame] | 1442 | 4.63 KVM_ALLOCATE_RMA |
| 1443 | |
| 1444 | Capability: KVM_CAP_PPC_RMA |
| 1445 | Architectures: powerpc |
| 1446 | Type: vm ioctl |
| 1447 | Parameters: struct kvm_allocate_rma (out) |
| 1448 | Returns: file descriptor for mapping the allocated RMA |
| 1449 | |
| 1450 | This allocates a Real Mode Area (RMA) from the pool allocated at boot |
| 1451 | time by the kernel. An RMA is a physically-contiguous, aligned region |
| 1452 | of memory used on older POWER processors to provide the memory which |
| 1453 | will be accessed by real-mode (MMU off) accesses in a KVM guest. |
| 1454 | POWER processors support a set of sizes for the RMA that usually |
| 1455 | includes 64MB, 128MB, 256MB and some larger powers of two. |
| 1456 | |
| 1457 | /* for KVM_ALLOCATE_RMA */ |
| 1458 | struct kvm_allocate_rma { |
| 1459 | __u64 rma_size; |
| 1460 | }; |
| 1461 | |
| 1462 | The return value is a file descriptor which can be passed to mmap(2) |
| 1463 | to map the allocated RMA into userspace. The mapped area can then be |
| 1464 | passed to the KVM_SET_USER_MEMORY_REGION ioctl to establish it as the |
| 1465 | RMA for a virtual machine. The size of the RMA in bytes (which is |
| 1466 | fixed at host kernel boot time) is returned in the rma_size field of |
| 1467 | the argument structure. |
| 1468 | |
| 1469 | The KVM_CAP_PPC_RMA capability is 1 or 2 if the KVM_ALLOCATE_RMA ioctl |
| 1470 | is supported; 2 if the processor requires all virtual machines to have |
| 1471 | an RMA, or 1 if the processor can use an RMA but doesn't require it, |
| 1472 | because it supports the Virtual RMA (VRMA) facility. |
| 1473 | |
Avi Kivity | 3f745f1 | 2011-12-07 12:42:47 +0200 | [diff] [blame] | 1474 | 4.64 KVM_NMI |
| 1475 | |
| 1476 | Capability: KVM_CAP_USER_NMI |
| 1477 | Architectures: x86 |
| 1478 | Type: vcpu ioctl |
| 1479 | Parameters: none |
| 1480 | Returns: 0 on success, -1 on error |
| 1481 | |
| 1482 | Queues an NMI on the thread's vcpu. Note this is well defined only |
| 1483 | when KVM_CREATE_IRQCHIP has not been called, since this is an interface |
| 1484 | between the virtual cpu core and virtual local APIC. After KVM_CREATE_IRQCHIP |
| 1485 | has been called, this interface is completely emulated within the kernel. |
| 1486 | |
| 1487 | To use this to emulate the LINT1 input with KVM_CREATE_IRQCHIP, use the |
| 1488 | following algorithm: |
| 1489 | |
| 1490 | - pause the vpcu |
| 1491 | - read the local APIC's state (KVM_GET_LAPIC) |
| 1492 | - check whether changing LINT1 will queue an NMI (see the LVT entry for LINT1) |
| 1493 | - if so, issue KVM_NMI |
| 1494 | - resume the vcpu |
| 1495 | |
| 1496 | Some guests configure the LINT1 NMI input to cause a panic, aiding in |
| 1497 | debugging. |
| 1498 | |
Carsten Otte | 27e0393 | 2012-01-04 10:25:21 +0100 | [diff] [blame^] | 1499 | 4.64 KVM_S390_UCAS_MAP |
| 1500 | |
| 1501 | Capability: KVM_CAP_S390_UCONTROL |
| 1502 | Architectures: s390 |
| 1503 | Type: vcpu ioctl |
| 1504 | Parameters: struct kvm_s390_ucas_mapping (in) |
| 1505 | Returns: 0 in case of success |
| 1506 | |
| 1507 | The parameter is defined like this: |
| 1508 | struct kvm_s390_ucas_mapping { |
| 1509 | __u64 user_addr; |
| 1510 | __u64 vcpu_addr; |
| 1511 | __u64 length; |
| 1512 | }; |
| 1513 | |
| 1514 | This ioctl maps the memory at "user_addr" with the length "length" to |
| 1515 | the vcpu's address space starting at "vcpu_addr". All parameters need to |
| 1516 | be alligned by 1 megabyte. |
| 1517 | |
| 1518 | 4.65 KVM_S390_UCAS_UNMAP |
| 1519 | |
| 1520 | Capability: KVM_CAP_S390_UCONTROL |
| 1521 | Architectures: s390 |
| 1522 | Type: vcpu ioctl |
| 1523 | Parameters: struct kvm_s390_ucas_mapping (in) |
| 1524 | Returns: 0 in case of success |
| 1525 | |
| 1526 | The parameter is defined like this: |
| 1527 | struct kvm_s390_ucas_mapping { |
| 1528 | __u64 user_addr; |
| 1529 | __u64 vcpu_addr; |
| 1530 | __u64 length; |
| 1531 | }; |
| 1532 | |
| 1533 | This ioctl unmaps the memory in the vcpu's address space starting at |
| 1534 | "vcpu_addr" with the length "length". The field "user_addr" is ignored. |
| 1535 | All parameters need to be alligned by 1 megabyte. |
| 1536 | |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 1537 | 5. The kvm_run structure |
| 1538 | |
| 1539 | Application code obtains a pointer to the kvm_run structure by |
| 1540 | mmap()ing a vcpu fd. From that point, application code can control |
| 1541 | execution by changing fields in kvm_run prior to calling the KVM_RUN |
| 1542 | ioctl, and obtain information about the reason KVM_RUN returned by |
| 1543 | looking up structure members. |
| 1544 | |
| 1545 | struct kvm_run { |
| 1546 | /* in */ |
| 1547 | __u8 request_interrupt_window; |
| 1548 | |
| 1549 | Request that KVM_RUN return when it becomes possible to inject external |
| 1550 | interrupts into the guest. Useful in conjunction with KVM_INTERRUPT. |
| 1551 | |
| 1552 | __u8 padding1[7]; |
| 1553 | |
| 1554 | /* out */ |
| 1555 | __u32 exit_reason; |
| 1556 | |
| 1557 | When KVM_RUN has returned successfully (return value 0), this informs |
| 1558 | application code why KVM_RUN has returned. Allowable values for this |
| 1559 | field are detailed below. |
| 1560 | |
| 1561 | __u8 ready_for_interrupt_injection; |
| 1562 | |
| 1563 | If request_interrupt_window has been specified, this field indicates |
| 1564 | an interrupt can be injected now with KVM_INTERRUPT. |
| 1565 | |
| 1566 | __u8 if_flag; |
| 1567 | |
| 1568 | The value of the current interrupt flag. Only valid if in-kernel |
| 1569 | local APIC is not used. |
| 1570 | |
| 1571 | __u8 padding2[2]; |
| 1572 | |
| 1573 | /* in (pre_kvm_run), out (post_kvm_run) */ |
| 1574 | __u64 cr8; |
| 1575 | |
| 1576 | The value of the cr8 register. Only valid if in-kernel local APIC is |
| 1577 | not used. Both input and output. |
| 1578 | |
| 1579 | __u64 apic_base; |
| 1580 | |
| 1581 | The value of the APIC BASE msr. Only valid if in-kernel local |
| 1582 | APIC is not used. Both input and output. |
| 1583 | |
| 1584 | union { |
| 1585 | /* KVM_EXIT_UNKNOWN */ |
| 1586 | struct { |
| 1587 | __u64 hardware_exit_reason; |
| 1588 | } hw; |
| 1589 | |
| 1590 | If exit_reason is KVM_EXIT_UNKNOWN, the vcpu has exited due to unknown |
| 1591 | reasons. Further architecture-specific information is available in |
| 1592 | hardware_exit_reason. |
| 1593 | |
| 1594 | /* KVM_EXIT_FAIL_ENTRY */ |
| 1595 | struct { |
| 1596 | __u64 hardware_entry_failure_reason; |
| 1597 | } fail_entry; |
| 1598 | |
| 1599 | If exit_reason is KVM_EXIT_FAIL_ENTRY, the vcpu could not be run due |
| 1600 | to unknown reasons. Further architecture-specific information is |
| 1601 | available in hardware_entry_failure_reason. |
| 1602 | |
| 1603 | /* KVM_EXIT_EXCEPTION */ |
| 1604 | struct { |
| 1605 | __u32 exception; |
| 1606 | __u32 error_code; |
| 1607 | } ex; |
| 1608 | |
| 1609 | Unused. |
| 1610 | |
| 1611 | /* KVM_EXIT_IO */ |
| 1612 | struct { |
| 1613 | #define KVM_EXIT_IO_IN 0 |
| 1614 | #define KVM_EXIT_IO_OUT 1 |
| 1615 | __u8 direction; |
| 1616 | __u8 size; /* bytes */ |
| 1617 | __u16 port; |
| 1618 | __u32 count; |
| 1619 | __u64 data_offset; /* relative to kvm_run start */ |
| 1620 | } io; |
| 1621 | |
Wu Fengguang | 2044892d | 2009-12-24 09:04:16 +0800 | [diff] [blame] | 1622 | If exit_reason is KVM_EXIT_IO, then the vcpu has |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 1623 | executed a port I/O instruction which could not be satisfied by kvm. |
| 1624 | data_offset describes where the data is located (KVM_EXIT_IO_OUT) or |
| 1625 | where kvm expects application code to place the data for the next |
Wu Fengguang | 2044892d | 2009-12-24 09:04:16 +0800 | [diff] [blame] | 1626 | 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] | 1627 | |
| 1628 | struct { |
| 1629 | struct kvm_debug_exit_arch arch; |
| 1630 | } debug; |
| 1631 | |
| 1632 | Unused. |
| 1633 | |
| 1634 | /* KVM_EXIT_MMIO */ |
| 1635 | struct { |
| 1636 | __u64 phys_addr; |
| 1637 | __u8 data[8]; |
| 1638 | __u32 len; |
| 1639 | __u8 is_write; |
| 1640 | } mmio; |
| 1641 | |
Wu Fengguang | 2044892d | 2009-12-24 09:04:16 +0800 | [diff] [blame] | 1642 | If exit_reason is KVM_EXIT_MMIO, then the vcpu has |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 1643 | executed a memory-mapped I/O instruction which could not be satisfied |
| 1644 | by kvm. The 'data' member contains the written data if 'is_write' is |
| 1645 | true, and should be filled by application code otherwise. |
| 1646 | |
Alexander Graf | ad0a048 | 2010-03-24 21:48:30 +0100 | [diff] [blame] | 1647 | NOTE: For KVM_EXIT_IO, KVM_EXIT_MMIO and KVM_EXIT_OSI, the corresponding |
| 1648 | operations are complete (and guest state is consistent) only after userspace |
| 1649 | 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] | 1650 | incomplete operations and then check for pending signals. Userspace |
| 1651 | can re-enter the guest with an unmasked signal pending to complete |
| 1652 | pending operations. |
| 1653 | |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 1654 | /* KVM_EXIT_HYPERCALL */ |
| 1655 | struct { |
| 1656 | __u64 nr; |
| 1657 | __u64 args[6]; |
| 1658 | __u64 ret; |
| 1659 | __u32 longmode; |
| 1660 | __u32 pad; |
| 1661 | } hypercall; |
| 1662 | |
Avi Kivity | 647dc49 | 2010-04-01 14:39:21 +0300 | [diff] [blame] | 1663 | Unused. This was once used for 'hypercall to userspace'. To implement |
| 1664 | such functionality, use KVM_EXIT_IO (x86) or KVM_EXIT_MMIO (all except s390). |
| 1665 | Note KVM_EXIT_IO is significantly faster than KVM_EXIT_MMIO. |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 1666 | |
| 1667 | /* KVM_EXIT_TPR_ACCESS */ |
| 1668 | struct { |
| 1669 | __u64 rip; |
| 1670 | __u32 is_write; |
| 1671 | __u32 pad; |
| 1672 | } tpr_access; |
| 1673 | |
| 1674 | To be documented (KVM_TPR_ACCESS_REPORTING). |
| 1675 | |
| 1676 | /* KVM_EXIT_S390_SIEIC */ |
| 1677 | struct { |
| 1678 | __u8 icptcode; |
| 1679 | __u64 mask; /* psw upper half */ |
| 1680 | __u64 addr; /* psw lower half */ |
| 1681 | __u16 ipa; |
| 1682 | __u32 ipb; |
| 1683 | } s390_sieic; |
| 1684 | |
| 1685 | s390 specific. |
| 1686 | |
| 1687 | /* KVM_EXIT_S390_RESET */ |
| 1688 | #define KVM_S390_RESET_POR 1 |
| 1689 | #define KVM_S390_RESET_CLEAR 2 |
| 1690 | #define KVM_S390_RESET_SUBSYSTEM 4 |
| 1691 | #define KVM_S390_RESET_CPU_INIT 8 |
| 1692 | #define KVM_S390_RESET_IPL 16 |
| 1693 | __u64 s390_reset_flags; |
| 1694 | |
| 1695 | s390 specific. |
| 1696 | |
| 1697 | /* KVM_EXIT_DCR */ |
| 1698 | struct { |
| 1699 | __u32 dcrn; |
| 1700 | __u32 data; |
| 1701 | __u8 is_write; |
| 1702 | } dcr; |
| 1703 | |
| 1704 | powerpc specific. |
| 1705 | |
Alexander Graf | ad0a048 | 2010-03-24 21:48:30 +0100 | [diff] [blame] | 1706 | /* KVM_EXIT_OSI */ |
| 1707 | struct { |
| 1708 | __u64 gprs[32]; |
| 1709 | } osi; |
| 1710 | |
| 1711 | MOL uses a special hypercall interface it calls 'OSI'. To enable it, we catch |
| 1712 | hypercalls and exit with this exit struct that contains all the guest gprs. |
| 1713 | |
| 1714 | If exit_reason is KVM_EXIT_OSI, then the vcpu has triggered such a hypercall. |
| 1715 | Userspace can now handle the hypercall and when it's done modify the gprs as |
| 1716 | necessary. Upon guest entry all guest GPRs will then be replaced by the values |
| 1717 | in this struct. |
| 1718 | |
Paul Mackerras | de56a94 | 2011-06-29 00:21:34 +0000 | [diff] [blame] | 1719 | /* KVM_EXIT_PAPR_HCALL */ |
| 1720 | struct { |
| 1721 | __u64 nr; |
| 1722 | __u64 ret; |
| 1723 | __u64 args[9]; |
| 1724 | } papr_hcall; |
| 1725 | |
| 1726 | This is used on 64-bit PowerPC when emulating a pSeries partition, |
| 1727 | e.g. with the 'pseries' machine type in qemu. It occurs when the |
| 1728 | guest does a hypercall using the 'sc 1' instruction. The 'nr' field |
| 1729 | contains the hypercall number (from the guest R3), and 'args' contains |
| 1730 | the arguments (from the guest R4 - R12). Userspace should put the |
| 1731 | return code in 'ret' and any extra returned values in args[]. |
| 1732 | The possible hypercalls are defined in the Power Architecture Platform |
| 1733 | Requirements (PAPR) document available from www.power.org (free |
| 1734 | developer registration required to access it). |
| 1735 | |
Avi Kivity | 9c1b96e | 2009-06-09 12:37:58 +0300 | [diff] [blame] | 1736 | /* Fix the size of the union. */ |
| 1737 | char padding[256]; |
| 1738 | }; |
| 1739 | }; |
Alexander Graf | 821246a | 2011-08-31 10:58:55 +0200 | [diff] [blame] | 1740 | |
| 1741 | 6. Capabilities that can be enabled |
| 1742 | |
| 1743 | There are certain capabilities that change the behavior of the virtual CPU when |
| 1744 | enabled. To enable them, please see section 4.37. Below you can find a list of |
| 1745 | capabilities and what their effect on the vCPU is when enabling them. |
| 1746 | |
| 1747 | The following information is provided along with the description: |
| 1748 | |
| 1749 | Architectures: which instruction set architectures provide this ioctl. |
| 1750 | x86 includes both i386 and x86_64. |
| 1751 | |
| 1752 | Parameters: what parameters are accepted by the capability. |
| 1753 | |
| 1754 | Returns: the return value. General error numbers (EBADF, ENOMEM, EINVAL) |
| 1755 | are not detailed, but errors with specific meanings are. |
| 1756 | |
| 1757 | 6.1 KVM_CAP_PPC_OSI |
| 1758 | |
| 1759 | Architectures: ppc |
| 1760 | Parameters: none |
| 1761 | Returns: 0 on success; -1 on error |
| 1762 | |
| 1763 | This capability enables interception of OSI hypercalls that otherwise would |
| 1764 | be treated as normal system calls to be injected into the guest. OSI hypercalls |
| 1765 | were invented by Mac-on-Linux to have a standardized communication mechanism |
| 1766 | between the guest and the host. |
| 1767 | |
| 1768 | When this capability is enabled, KVM_EXIT_OSI can occur. |
| 1769 | |
| 1770 | 6.2 KVM_CAP_PPC_PAPR |
| 1771 | |
| 1772 | Architectures: ppc |
| 1773 | Parameters: none |
| 1774 | Returns: 0 on success; -1 on error |
| 1775 | |
| 1776 | This capability enables interception of PAPR hypercalls. PAPR hypercalls are |
| 1777 | done using the hypercall instruction "sc 1". |
| 1778 | |
| 1779 | It also sets the guest privilege level to "supervisor" mode. Usually the guest |
| 1780 | runs in "hypervisor" privilege mode with a few missing features. |
| 1781 | |
| 1782 | In addition to the above, it changes the semantics of SDR1. In this mode, the |
| 1783 | HTAB address part of SDR1 contains an HVA instead of a GPA, as PAPR keeps the |
| 1784 | HTAB invisible to the guest. |
| 1785 | |
| 1786 | When this capability is enabled, KVM_EXIT_PAPR_HCALL can occur. |