aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/virtual/kvm/api.txt
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation/virtual/kvm/api.txt')
-rw-r--r--Documentation/virtual/kvm/api.txt172
1 files changed, 164 insertions, 8 deletions
diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt
index 42542eb802ca..b0e4b9cd6a66 100644
--- a/Documentation/virtual/kvm/api.txt
+++ b/Documentation/virtual/kvm/api.txt
@@ -180,6 +180,19 @@ KVM_CHECK_EXTENSION ioctl() to determine the value for max_vcpus at run-time.
180If the KVM_CAP_NR_VCPUS does not exist, you should assume that max_vcpus is 4 180If the KVM_CAP_NR_VCPUS does not exist, you should assume that max_vcpus is 4
181cpus max. 181cpus max.
182 182
183On powerpc using book3s_hv mode, the vcpus are mapped onto virtual
184threads in one or more virtual CPU cores. (This is because the
185hardware requires all the hardware threads in a CPU core to be in the
186same partition.) The KVM_CAP_PPC_SMT capability indicates the number
187of vcpus per virtual core (vcore). The vcore id is obtained by
188dividing the vcpu id by the number of vcpus per vcore. The vcpus in a
189given vcore will always be in the same physical core as each other
190(though that might be a different physical core from time to time).
191Userspace can control the threading (SMT) mode of the guest by its
192allocation of vcpu ids. For example, if userspace wants
193single-threaded guest vcpus, it should make all vcpu ids be a multiple
194of the number of vcpus per vcore.
195
1834.8 KVM_GET_DIRTY_LOG (vm ioctl) 1964.8 KVM_GET_DIRTY_LOG (vm ioctl)
184 197
185Capability: basic 198Capability: basic
@@ -1143,15 +1156,10 @@ Assigns an IRQ to a passed-through device.
1143 1156
1144struct kvm_assigned_irq { 1157struct kvm_assigned_irq {
1145 __u32 assigned_dev_id; 1158 __u32 assigned_dev_id;
1146 __u32 host_irq; 1159 __u32 host_irq; /* ignored (legacy field) */
1147 __u32 guest_irq; 1160 __u32 guest_irq;
1148 __u32 flags; 1161 __u32 flags;
1149 union { 1162 union {
1150 struct {
1151 __u32 addr_lo;
1152 __u32 addr_hi;
1153 __u32 data;
1154 } guest_msi;
1155 __u32 reserved[12]; 1163 __u32 reserved[12];
1156 }; 1164 };
1157}; 1165};
@@ -1239,8 +1247,10 @@ Type: vm ioctl
1239Parameters: struct kvm_assigned_msix_nr (in) 1247Parameters: struct kvm_assigned_msix_nr (in)
1240Returns: 0 on success, -1 on error 1248Returns: 0 on success, -1 on error
1241 1249
1242Set the number of MSI-X interrupts for an assigned device. This service can 1250Set the number of MSI-X interrupts for an assigned device. The number is
1243only be called once in the lifetime of an assigned device. 1251reset again by terminating the MSI-X assignment of the device via
1252KVM_DEASSIGN_DEV_IRQ. Calling this service more than once at any earlier
1253point will fail.
1244 1254
1245struct kvm_assigned_msix_nr { 1255struct kvm_assigned_msix_nr {
1246 __u32 assigned_dev_id; 1256 __u32 assigned_dev_id;
@@ -1291,6 +1301,135 @@ Returns the tsc frequency of the guest. The unit of the return value is
1291KHz. If the host has unstable tsc this ioctl returns -EIO instead as an 1301KHz. If the host has unstable tsc this ioctl returns -EIO instead as an
1292error. 1302error.
1293 1303
13044.56 KVM_GET_LAPIC
1305
1306Capability: KVM_CAP_IRQCHIP
1307Architectures: x86
1308Type: vcpu ioctl
1309Parameters: struct kvm_lapic_state (out)
1310Returns: 0 on success, -1 on error
1311
1312#define KVM_APIC_REG_SIZE 0x400
1313struct kvm_lapic_state {
1314 char regs[KVM_APIC_REG_SIZE];
1315};
1316
1317Reads the Local APIC registers and copies them into the input argument. The
1318data format and layout are the same as documented in the architecture manual.
1319
13204.57 KVM_SET_LAPIC
1321
1322Capability: KVM_CAP_IRQCHIP
1323Architectures: x86
1324Type: vcpu ioctl
1325Parameters: struct kvm_lapic_state (in)
1326Returns: 0 on success, -1 on error
1327
1328#define KVM_APIC_REG_SIZE 0x400
1329struct kvm_lapic_state {
1330 char regs[KVM_APIC_REG_SIZE];
1331};
1332
1333Copies the input argument into the the Local APIC registers. The data format
1334and layout are the same as documented in the architecture manual.
1335
13364.58 KVM_IOEVENTFD
1337
1338Capability: KVM_CAP_IOEVENTFD
1339Architectures: all
1340Type: vm ioctl
1341Parameters: struct kvm_ioeventfd (in)
1342Returns: 0 on success, !0 on error
1343
1344This ioctl attaches or detaches an ioeventfd to a legal pio/mmio address
1345within the guest. A guest write in the registered address will signal the
1346provided event instead of triggering an exit.
1347
1348struct kvm_ioeventfd {
1349 __u64 datamatch;
1350 __u64 addr; /* legal pio/mmio address */
1351 __u32 len; /* 1, 2, 4, or 8 bytes */
1352 __s32 fd;
1353 __u32 flags;
1354 __u8 pad[36];
1355};
1356
1357The following flags are defined:
1358
1359#define KVM_IOEVENTFD_FLAG_DATAMATCH (1 << kvm_ioeventfd_flag_nr_datamatch)
1360#define KVM_IOEVENTFD_FLAG_PIO (1 << kvm_ioeventfd_flag_nr_pio)
1361#define KVM_IOEVENTFD_FLAG_DEASSIGN (1 << kvm_ioeventfd_flag_nr_deassign)
1362
1363If datamatch flag is set, the event will be signaled only if the written value
1364to the registered address is equal to datamatch in struct kvm_ioeventfd.
1365
13664.62 KVM_CREATE_SPAPR_TCE
1367
1368Capability: KVM_CAP_SPAPR_TCE
1369Architectures: powerpc
1370Type: vm ioctl
1371Parameters: struct kvm_create_spapr_tce (in)
1372Returns: file descriptor for manipulating the created TCE table
1373
1374This creates a virtual TCE (translation control entry) table, which
1375is an IOMMU for PAPR-style virtual I/O. It is used to translate
1376logical addresses used in virtual I/O into guest physical addresses,
1377and provides a scatter/gather capability for PAPR virtual I/O.
1378
1379/* for KVM_CAP_SPAPR_TCE */
1380struct kvm_create_spapr_tce {
1381 __u64 liobn;
1382 __u32 window_size;
1383};
1384
1385The liobn field gives the logical IO bus number for which to create a
1386TCE table. The window_size field specifies the size of the DMA window
1387which this TCE table will translate - the table will contain one 64
1388bit TCE entry for every 4kiB of the DMA window.
1389
1390When the guest issues an H_PUT_TCE hcall on a liobn for which a TCE
1391table has been created using this ioctl(), the kernel will handle it
1392in real mode, updating the TCE table. H_PUT_TCE calls for other
1393liobns will cause a vm exit and must be handled by userspace.
1394
1395The return value is a file descriptor which can be passed to mmap(2)
1396to map the created TCE table into userspace. This lets userspace read
1397the entries written by kernel-handled H_PUT_TCE calls, and also lets
1398userspace update the TCE table directly which is useful in some
1399circumstances.
1400
14014.63 KVM_ALLOCATE_RMA
1402
1403Capability: KVM_CAP_PPC_RMA
1404Architectures: powerpc
1405Type: vm ioctl
1406Parameters: struct kvm_allocate_rma (out)
1407Returns: file descriptor for mapping the allocated RMA
1408
1409This allocates a Real Mode Area (RMA) from the pool allocated at boot
1410time by the kernel. An RMA is a physically-contiguous, aligned region
1411of memory used on older POWER processors to provide the memory which
1412will be accessed by real-mode (MMU off) accesses in a KVM guest.
1413POWER processors support a set of sizes for the RMA that usually
1414includes 64MB, 128MB, 256MB and some larger powers of two.
1415
1416/* for KVM_ALLOCATE_RMA */
1417struct kvm_allocate_rma {
1418 __u64 rma_size;
1419};
1420
1421The return value is a file descriptor which can be passed to mmap(2)
1422to map the allocated RMA into userspace. The mapped area can then be
1423passed to the KVM_SET_USER_MEMORY_REGION ioctl to establish it as the
1424RMA for a virtual machine. The size of the RMA in bytes (which is
1425fixed at host kernel boot time) is returned in the rma_size field of
1426the argument structure.
1427
1428The KVM_CAP_PPC_RMA capability is 1 or 2 if the KVM_ALLOCATE_RMA ioctl
1429is supported; 2 if the processor requires all virtual machines to have
1430an RMA, or 1 if the processor can use an RMA but doesn't require it,
1431because it supports the Virtual RMA (VRMA) facility.
1432
12945. The kvm_run structure 14335. The kvm_run structure
1295 1434
1296Application code obtains a pointer to the kvm_run structure by 1435Application code obtains a pointer to the kvm_run structure by
@@ -1473,6 +1612,23 @@ Userspace can now handle the hypercall and when it's done modify the gprs as
1473necessary. Upon guest entry all guest GPRs will then be replaced by the values 1612necessary. Upon guest entry all guest GPRs will then be replaced by the values
1474in this struct. 1613in this struct.
1475 1614
1615 /* KVM_EXIT_PAPR_HCALL */
1616 struct {
1617 __u64 nr;
1618 __u64 ret;
1619 __u64 args[9];
1620 } papr_hcall;
1621
1622This is used on 64-bit PowerPC when emulating a pSeries partition,
1623e.g. with the 'pseries' machine type in qemu. It occurs when the
1624guest does a hypercall using the 'sc 1' instruction. The 'nr' field
1625contains the hypercall number (from the guest R3), and 'args' contains
1626the arguments (from the guest R4 - R12). Userspace should put the
1627return code in 'ret' and any extra returned values in args[].
1628The possible hypercalls are defined in the Power Architecture Platform
1629Requirements (PAPR) document available from www.power.org (free
1630developer registration required to access it).
1631
1476 /* Fix the size of the union. */ 1632 /* Fix the size of the union. */
1477 char padding[256]; 1633 char padding[256];
1478 }; 1634 };