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