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