vm.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. .. SPDX-License-Identifier: GPL-2.0
  2. ====================
  3. Generic vm interface
  4. ====================
  5. The virtual machine "device" also accepts the ioctls KVM_SET_DEVICE_ATTR,
  6. KVM_GET_DEVICE_ATTR, and KVM_HAS_DEVICE_ATTR. The interface uses the same
  7. struct kvm_device_attr as other devices, but targets VM-wide settings
  8. and controls.
  9. The groups and attributes per virtual machine, if any, are architecture
  10. specific.
  11. 1. GROUP: KVM_S390_VM_MEM_CTRL
  12. ==============================
  13. :Architectures: s390
  14. 1.1. ATTRIBUTE: KVM_S390_VM_MEM_ENABLE_CMMA
  15. -------------------------------------------
  16. :Parameters: none
  17. :Returns: -EBUSY if a vcpu is already defined, otherwise 0
  18. Enables Collaborative Memory Management Assist (CMMA) for the virtual machine.
  19. 1.2. ATTRIBUTE: KVM_S390_VM_MEM_CLR_CMMA
  20. ----------------------------------------
  21. :Parameters: none
  22. :Returns: -EINVAL if CMMA was not enabled;
  23. 0 otherwise
  24. Clear the CMMA status for all guest pages, so any pages the guest marked
  25. as unused are again used any may not be reclaimed by the host.
  26. 1.3. ATTRIBUTE KVM_S390_VM_MEM_LIMIT_SIZE
  27. -----------------------------------------
  28. :Parameters: in attr->addr the address for the new limit of guest memory
  29. :Returns: -EFAULT if the given address is not accessible;
  30. -EINVAL if the virtual machine is of type UCONTROL;
  31. -E2BIG if the given guest memory is to big for that machine;
  32. -EBUSY if a vcpu is already defined;
  33. -ENOMEM if not enough memory is available for a new shadow guest mapping;
  34. 0 otherwise.
  35. Allows userspace to query the actual limit and set a new limit for
  36. the maximum guest memory size. The limit will be rounded up to
  37. 2048 MB, 4096 GB, 8192 TB respectively, as this limit is governed by
  38. the number of page table levels. In the case that there is no limit we will set
  39. the limit to KVM_S390_NO_MEM_LIMIT (U64_MAX).
  40. 2. GROUP: KVM_S390_VM_CPU_MODEL
  41. ===============================
  42. :Architectures: s390
  43. 2.1. ATTRIBUTE: KVM_S390_VM_CPU_MACHINE (r/o)
  44. ---------------------------------------------
  45. Allows user space to retrieve machine and kvm specific cpu related information::
  46. struct kvm_s390_vm_cpu_machine {
  47. __u64 cpuid; # CPUID of host
  48. __u32 ibc; # IBC level range offered by host
  49. __u8 pad[4];
  50. __u64 fac_mask[256]; # set of cpu facilities enabled by KVM
  51. __u64 fac_list[256]; # set of cpu facilities offered by host
  52. }
  53. :Parameters: address of buffer to store the machine related cpu data
  54. of type struct kvm_s390_vm_cpu_machine*
  55. :Returns: -EFAULT if the given address is not accessible from kernel space;
  56. -ENOMEM if not enough memory is available to process the ioctl;
  57. 0 in case of success.
  58. 2.2. ATTRIBUTE: KVM_S390_VM_CPU_PROCESSOR (r/w)
  59. ===============================================
  60. Allows user space to retrieve or request to change cpu related information for a vcpu::
  61. struct kvm_s390_vm_cpu_processor {
  62. __u64 cpuid; # CPUID currently (to be) used by this vcpu
  63. __u16 ibc; # IBC level currently (to be) used by this vcpu
  64. __u8 pad[6];
  65. __u64 fac_list[256]; # set of cpu facilities currently (to be) used
  66. # by this vcpu
  67. }
  68. KVM does not enforce or limit the cpu model data in any form. Take the information
  69. retrieved by means of KVM_S390_VM_CPU_MACHINE as hint for reasonable configuration
  70. setups. Instruction interceptions triggered by additionally set facility bits that
  71. are not handled by KVM need to by imlemented in the VM driver code.
  72. :Parameters: address of buffer to store/set the processor related cpu
  73. data of type struct kvm_s390_vm_cpu_processor*.
  74. :Returns: -EBUSY in case 1 or more vcpus are already activated (only in write case);
  75. -EFAULT if the given address is not accessible from kernel space;
  76. -ENOMEM if not enough memory is available to process the ioctl;
  77. 0 in case of success.
  78. .. _KVM_S390_VM_CPU_MACHINE_FEAT:
  79. 2.3. ATTRIBUTE: KVM_S390_VM_CPU_MACHINE_FEAT (r/o)
  80. --------------------------------------------------
  81. Allows user space to retrieve available cpu features. A feature is available if
  82. provided by the hardware and supported by kvm. In theory, cpu features could
  83. even be completely emulated by kvm.
  84. ::
  85. struct kvm_s390_vm_cpu_feat {
  86. __u64 feat[16]; # Bitmap (1 = feature available), MSB 0 bit numbering
  87. };
  88. :Parameters: address of a buffer to load the feature list from.
  89. :Returns: -EFAULT if the given address is not accessible from kernel space;
  90. 0 in case of success.
  91. 2.4. ATTRIBUTE: KVM_S390_VM_CPU_PROCESSOR_FEAT (r/w)
  92. ----------------------------------------------------
  93. Allows user space to retrieve or change enabled cpu features for all VCPUs of a
  94. VM. Features that are not available cannot be enabled.
  95. See :ref:`KVM_S390_VM_CPU_MACHINE_FEAT` for
  96. a description of the parameter struct.
  97. :Parameters: address of a buffer to store/load the feature list from.
  98. :Returns: -EFAULT if the given address is not accessible from kernel space;
  99. -EINVAL if a cpu feature that is not available is to be enabled;
  100. -EBUSY if at least one VCPU has already been defined;
  101. 0 in case of success.
  102. .. _KVM_S390_VM_CPU_MACHINE_SUBFUNC:
  103. 2.5. ATTRIBUTE: KVM_S390_VM_CPU_MACHINE_SUBFUNC (r/o)
  104. -----------------------------------------------------
  105. Allows user space to retrieve available cpu subfunctions without any filtering
  106. done by a set IBC. These subfunctions are indicated to the guest VCPU via
  107. query or "test bit" subfunctions and used e.g. by cpacf functions, plo and ptff.
  108. A subfunction block is only valid if KVM_S390_VM_CPU_MACHINE contains the
  109. STFL(E) bit introducing the affected instruction. If the affected instruction
  110. indicates subfunctions via a "query subfunction", the response block is
  111. contained in the returned struct. If the affected instruction
  112. indicates subfunctions via a "test bit" mechanism, the subfunction codes are
  113. contained in the returned struct in MSB 0 bit numbering.
  114. ::
  115. struct kvm_s390_vm_cpu_subfunc {
  116. u8 plo[32]; # always valid (ESA/390 feature)
  117. u8 ptff[16]; # valid with TOD-clock steering
  118. u8 kmac[16]; # valid with Message-Security-Assist
  119. u8 kmc[16]; # valid with Message-Security-Assist
  120. u8 km[16]; # valid with Message-Security-Assist
  121. u8 kimd[16]; # valid with Message-Security-Assist
  122. u8 klmd[16]; # valid with Message-Security-Assist
  123. u8 pckmo[16]; # valid with Message-Security-Assist-Extension 3
  124. u8 kmctr[16]; # valid with Message-Security-Assist-Extension 4
  125. u8 kmf[16]; # valid with Message-Security-Assist-Extension 4
  126. u8 kmo[16]; # valid with Message-Security-Assist-Extension 4
  127. u8 pcc[16]; # valid with Message-Security-Assist-Extension 4
  128. u8 ppno[16]; # valid with Message-Security-Assist-Extension 5
  129. u8 kma[16]; # valid with Message-Security-Assist-Extension 8
  130. u8 kdsa[16]; # valid with Message-Security-Assist-Extension 9
  131. u8 reserved[1792]; # reserved for future instructions
  132. };
  133. :Parameters: address of a buffer to load the subfunction blocks from.
  134. :Returns: -EFAULT if the given address is not accessible from kernel space;
  135. 0 in case of success.
  136. 2.6. ATTRIBUTE: KVM_S390_VM_CPU_PROCESSOR_SUBFUNC (r/w)
  137. -------------------------------------------------------
  138. Allows user space to retrieve or change cpu subfunctions to be indicated for
  139. all VCPUs of a VM. This attribute will only be available if kernel and
  140. hardware support are in place.
  141. The kernel uses the configured subfunction blocks for indication to
  142. the guest. A subfunction block will only be used if the associated STFL(E) bit
  143. has not been disabled by user space (so the instruction to be queried is
  144. actually available for the guest).
  145. As long as no data has been written, a read will fail. The IBC will be used
  146. to determine available subfunctions in this case, this will guarantee backward
  147. compatibility.
  148. See :ref:`KVM_S390_VM_CPU_MACHINE_SUBFUNC` for a
  149. description of the parameter struct.
  150. :Parameters: address of a buffer to store/load the subfunction blocks from.
  151. :Returns: -EFAULT if the given address is not accessible from kernel space;
  152. -EINVAL when reading, if there was no write yet;
  153. -EBUSY if at least one VCPU has already been defined;
  154. 0 in case of success.
  155. 3. GROUP: KVM_S390_VM_TOD
  156. =========================
  157. :Architectures: s390
  158. 3.1. ATTRIBUTE: KVM_S390_VM_TOD_HIGH
  159. ------------------------------------
  160. Allows user space to set/get the TOD clock extension (u8) (superseded by
  161. KVM_S390_VM_TOD_EXT).
  162. :Parameters: address of a buffer in user space to store the data (u8) to
  163. :Returns: -EFAULT if the given address is not accessible from kernel space;
  164. -EINVAL if setting the TOD clock extension to != 0 is not supported
  165. -EOPNOTSUPP for a PV guest (TOD managed by the ultravisor)
  166. 3.2. ATTRIBUTE: KVM_S390_VM_TOD_LOW
  167. -----------------------------------
  168. Allows user space to set/get bits 0-63 of the TOD clock register as defined in
  169. the POP (u64).
  170. :Parameters: address of a buffer in user space to store the data (u64) to
  171. :Returns: -EFAULT if the given address is not accessible from kernel space
  172. -EOPNOTSUPP for a PV guest (TOD managed by the ultravisor)
  173. 3.3. ATTRIBUTE: KVM_S390_VM_TOD_EXT
  174. -----------------------------------
  175. Allows user space to set/get bits 0-63 of the TOD clock register as defined in
  176. the POP (u64). If the guest CPU model supports the TOD clock extension (u8), it
  177. also allows user space to get/set it. If the guest CPU model does not support
  178. it, it is stored as 0 and not allowed to be set to a value != 0.
  179. :Parameters: address of a buffer in user space to store the data
  180. (kvm_s390_vm_tod_clock) to
  181. :Returns: -EFAULT if the given address is not accessible from kernel space;
  182. -EINVAL if setting the TOD clock extension to != 0 is not supported
  183. -EOPNOTSUPP for a PV guest (TOD managed by the ultravisor)
  184. 4. GROUP: KVM_S390_VM_CRYPTO
  185. ============================
  186. :Architectures: s390
  187. 4.1. ATTRIBUTE: KVM_S390_VM_CRYPTO_ENABLE_AES_KW (w/o)
  188. ------------------------------------------------------
  189. Allows user space to enable aes key wrapping, including generating a new
  190. wrapping key.
  191. :Parameters: none
  192. :Returns: 0
  193. 4.2. ATTRIBUTE: KVM_S390_VM_CRYPTO_ENABLE_DEA_KW (w/o)
  194. ------------------------------------------------------
  195. Allows user space to enable dea key wrapping, including generating a new
  196. wrapping key.
  197. :Parameters: none
  198. :Returns: 0
  199. 4.3. ATTRIBUTE: KVM_S390_VM_CRYPTO_DISABLE_AES_KW (w/o)
  200. -------------------------------------------------------
  201. Allows user space to disable aes key wrapping, clearing the wrapping key.
  202. :Parameters: none
  203. :Returns: 0
  204. 4.4. ATTRIBUTE: KVM_S390_VM_CRYPTO_DISABLE_DEA_KW (w/o)
  205. -------------------------------------------------------
  206. Allows user space to disable dea key wrapping, clearing the wrapping key.
  207. :Parameters: none
  208. :Returns: 0
  209. 5. GROUP: KVM_S390_VM_MIGRATION
  210. ===============================
  211. :Architectures: s390
  212. 5.1. ATTRIBUTE: KVM_S390_VM_MIGRATION_STOP (w/o)
  213. ------------------------------------------------
  214. Allows userspace to stop migration mode, needed for PGSTE migration.
  215. Setting this attribute when migration mode is not active will have no
  216. effects.
  217. :Parameters: none
  218. :Returns: 0
  219. 5.2. ATTRIBUTE: KVM_S390_VM_MIGRATION_START (w/o)
  220. -------------------------------------------------
  221. Allows userspace to start migration mode, needed for PGSTE migration.
  222. Setting this attribute when migration mode is already active will have
  223. no effects.
  224. Dirty tracking must be enabled on all memslots, else -EINVAL is returned. When
  225. dirty tracking is disabled on any memslot, migration mode is automatically
  226. stopped.
  227. :Parameters: none
  228. :Returns: -ENOMEM if there is not enough free memory to start migration mode;
  229. -EINVAL if the state of the VM is invalid (e.g. no memory defined);
  230. 0 in case of success.
  231. 5.3. ATTRIBUTE: KVM_S390_VM_MIGRATION_STATUS (r/o)
  232. --------------------------------------------------
  233. Allows userspace to query the status of migration mode.
  234. :Parameters: address of a buffer in user space to store the data (u64) to;
  235. the data itself is either 0 if migration mode is disabled or 1
  236. if it is enabled
  237. :Returns: -EFAULT if the given address is not accessible from kernel space;
  238. 0 in case of success.