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