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