vm.txt 10 KB

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