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