kvm.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. #ifndef __LINUX_KVM_S390_H
  2. #define __LINUX_KVM_S390_H
  3. /*
  4. * KVM s390 specific structures and definitions
  5. *
  6. * Copyright IBM Corp. 2008
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License (version 2 only)
  10. * as published by the Free Software Foundation.
  11. *
  12. * Author(s): Carsten Otte <cotte@de.ibm.com>
  13. * Christian Borntraeger <borntraeger@de.ibm.com>
  14. */
  15. #include <linux/types.h>
  16. #define __KVM_S390
  17. #define __KVM_HAVE_GUEST_DEBUG
  18. /* Device control API: s390-specific devices */
  19. #define KVM_DEV_FLIC_GET_ALL_IRQS 1
  20. #define KVM_DEV_FLIC_ENQUEUE 2
  21. #define KVM_DEV_FLIC_CLEAR_IRQS 3
  22. #define KVM_DEV_FLIC_APF_ENABLE 4
  23. #define KVM_DEV_FLIC_APF_DISABLE_WAIT 5
  24. #define KVM_DEV_FLIC_ADAPTER_REGISTER 6
  25. #define KVM_DEV_FLIC_ADAPTER_MODIFY 7
  26. #define KVM_DEV_FLIC_CLEAR_IO_IRQ 8
  27. /*
  28. * We can have up to 4*64k pending subchannels + 8 adapter interrupts,
  29. * as well as up to ASYNC_PF_PER_VCPU*KVM_MAX_VCPUS pfault done interrupts.
  30. * There are also sclp and machine checks. This gives us
  31. * sizeof(kvm_s390_irq)*(4*65536+8+64*64+1+1) = 72 * 266250 = 19170000
  32. * Lets round up to 8192 pages.
  33. */
  34. #define KVM_S390_MAX_FLOAT_IRQS 266250
  35. #define KVM_S390_FLIC_MAX_BUFFER 0x2000000
  36. struct kvm_s390_io_adapter {
  37. __u32 id;
  38. __u8 isc;
  39. __u8 maskable;
  40. __u8 swap;
  41. __u8 pad;
  42. };
  43. #define KVM_S390_IO_ADAPTER_MASK 1
  44. #define KVM_S390_IO_ADAPTER_MAP 2
  45. #define KVM_S390_IO_ADAPTER_UNMAP 3
  46. struct kvm_s390_io_adapter_req {
  47. __u32 id;
  48. __u8 type;
  49. __u8 mask;
  50. __u16 pad0;
  51. __u64 addr;
  52. };
  53. /* kvm attr_group on vm fd */
  54. #define KVM_S390_VM_MEM_CTRL 0
  55. #define KVM_S390_VM_TOD 1
  56. #define KVM_S390_VM_CRYPTO 2
  57. #define KVM_S390_VM_CPU_MODEL 3
  58. /* kvm attributes for mem_ctrl */
  59. #define KVM_S390_VM_MEM_ENABLE_CMMA 0
  60. #define KVM_S390_VM_MEM_CLR_CMMA 1
  61. #define KVM_S390_VM_MEM_LIMIT_SIZE 2
  62. #define KVM_S390_NO_MEM_LIMIT U64_MAX
  63. /* kvm attributes for KVM_S390_VM_TOD */
  64. #define KVM_S390_VM_TOD_LOW 0
  65. #define KVM_S390_VM_TOD_HIGH 1
  66. /* kvm attributes for KVM_S390_VM_CPU_MODEL */
  67. /* processor related attributes are r/w */
  68. #define KVM_S390_VM_CPU_PROCESSOR 0
  69. struct kvm_s390_vm_cpu_processor {
  70. __u64 cpuid;
  71. __u16 ibc;
  72. __u8 pad[6];
  73. __u64 fac_list[256];
  74. };
  75. /* machine related attributes are r/o */
  76. #define KVM_S390_VM_CPU_MACHINE 1
  77. struct kvm_s390_vm_cpu_machine {
  78. __u64 cpuid;
  79. __u32 ibc;
  80. __u8 pad[4];
  81. __u64 fac_mask[256];
  82. __u64 fac_list[256];
  83. };
  84. #define KVM_S390_VM_CPU_PROCESSOR_FEAT 2
  85. #define KVM_S390_VM_CPU_MACHINE_FEAT 3
  86. #define KVM_S390_VM_CPU_FEAT_NR_BITS 1024
  87. #define KVM_S390_VM_CPU_FEAT_ESOP 0
  88. #define KVM_S390_VM_CPU_FEAT_SIEF2 1
  89. #define KVM_S390_VM_CPU_FEAT_64BSCAO 2
  90. #define KVM_S390_VM_CPU_FEAT_SIIF 3
  91. #define KVM_S390_VM_CPU_FEAT_GPERE 4
  92. #define KVM_S390_VM_CPU_FEAT_GSLS 5
  93. #define KVM_S390_VM_CPU_FEAT_IB 6
  94. #define KVM_S390_VM_CPU_FEAT_CEI 7
  95. #define KVM_S390_VM_CPU_FEAT_IBS 8
  96. #define KVM_S390_VM_CPU_FEAT_SKEY 9
  97. #define KVM_S390_VM_CPU_FEAT_CMMA 10
  98. #define KVM_S390_VM_CPU_FEAT_PFMFI 11
  99. #define KVM_S390_VM_CPU_FEAT_SIGPIF 12
  100. struct kvm_s390_vm_cpu_feat {
  101. __u64 feat[16];
  102. };
  103. #define KVM_S390_VM_CPU_PROCESSOR_SUBFUNC 4
  104. #define KVM_S390_VM_CPU_MACHINE_SUBFUNC 5
  105. /* for "test bit" instructions MSB 0 bit ordering, for "query" raw blocks */
  106. struct kvm_s390_vm_cpu_subfunc {
  107. __u8 plo[32]; /* always */
  108. __u8 ptff[16]; /* with TOD-clock steering */
  109. __u8 kmac[16]; /* with MSA */
  110. __u8 kmc[16]; /* with MSA */
  111. __u8 km[16]; /* with MSA */
  112. __u8 kimd[16]; /* with MSA */
  113. __u8 klmd[16]; /* with MSA */
  114. __u8 pckmo[16]; /* with MSA3 */
  115. __u8 kmctr[16]; /* with MSA4 */
  116. __u8 kmf[16]; /* with MSA4 */
  117. __u8 kmo[16]; /* with MSA4 */
  118. __u8 pcc[16]; /* with MSA4 */
  119. __u8 ppno[16]; /* with MSA5 */
  120. __u8 reserved[1824];
  121. };
  122. /* kvm attributes for crypto */
  123. #define KVM_S390_VM_CRYPTO_ENABLE_AES_KW 0
  124. #define KVM_S390_VM_CRYPTO_ENABLE_DEA_KW 1
  125. #define KVM_S390_VM_CRYPTO_DISABLE_AES_KW 2
  126. #define KVM_S390_VM_CRYPTO_DISABLE_DEA_KW 3
  127. /* for KVM_GET_REGS and KVM_SET_REGS */
  128. struct kvm_regs {
  129. /* general purpose regs for s390 */
  130. __u64 gprs[16];
  131. };
  132. /* for KVM_GET_SREGS and KVM_SET_SREGS */
  133. struct kvm_sregs {
  134. __u32 acrs[16];
  135. __u64 crs[16];
  136. };
  137. /* for KVM_GET_FPU and KVM_SET_FPU */
  138. struct kvm_fpu {
  139. __u32 fpc;
  140. __u64 fprs[16];
  141. };
  142. #define KVM_GUESTDBG_USE_HW_BP 0x00010000
  143. #define KVM_HW_BP 1
  144. #define KVM_HW_WP_WRITE 2
  145. #define KVM_SINGLESTEP 4
  146. struct kvm_debug_exit_arch {
  147. __u64 addr;
  148. __u8 type;
  149. __u8 pad[7]; /* Should be set to 0 */
  150. };
  151. struct kvm_hw_breakpoint {
  152. __u64 addr;
  153. __u64 phys_addr;
  154. __u64 len;
  155. __u8 type;
  156. __u8 pad[7]; /* Should be set to 0 */
  157. };
  158. /* for KVM_SET_GUEST_DEBUG */
  159. struct kvm_guest_debug_arch {
  160. __u32 nr_hw_bp;
  161. __u32 pad; /* Should be set to 0 */
  162. struct kvm_hw_breakpoint __user *hw_bp;
  163. };
  164. /* for KVM_SYNC_PFAULT and KVM_REG_S390_PFTOKEN */
  165. #define KVM_S390_PFAULT_TOKEN_INVALID 0xffffffffffffffffULL
  166. #define KVM_SYNC_PREFIX (1UL << 0)
  167. #define KVM_SYNC_GPRS (1UL << 1)
  168. #define KVM_SYNC_ACRS (1UL << 2)
  169. #define KVM_SYNC_CRS (1UL << 3)
  170. #define KVM_SYNC_ARCH0 (1UL << 4)
  171. #define KVM_SYNC_PFAULT (1UL << 5)
  172. #define KVM_SYNC_VRS (1UL << 6)
  173. #define KVM_SYNC_RICCB (1UL << 7)
  174. #define KVM_SYNC_FPRS (1UL << 8)
  175. #define KVM_SYNC_BPBC (1UL << 10)
  176. /* definition of registers in kvm_run */
  177. struct kvm_sync_regs {
  178. __u64 prefix; /* prefix register */
  179. __u64 gprs[16]; /* general purpose registers */
  180. __u32 acrs[16]; /* access registers */
  181. __u64 crs[16]; /* control registers */
  182. __u64 todpr; /* tod programmable register [ARCH0] */
  183. __u64 cputm; /* cpu timer [ARCH0] */
  184. __u64 ckc; /* clock comparator [ARCH0] */
  185. __u64 pp; /* program parameter [ARCH0] */
  186. __u64 gbea; /* guest breaking-event address [ARCH0] */
  187. __u64 pft; /* pfault token [PFAULT] */
  188. __u64 pfs; /* pfault select [PFAULT] */
  189. __u64 pfc; /* pfault compare [PFAULT] */
  190. union {
  191. __u64 vrs[32][2]; /* vector registers (KVM_SYNC_VRS) */
  192. __u64 fprs[16]; /* fp registers (KVM_SYNC_FPRS) */
  193. };
  194. __u8 reserved[512]; /* for future vector expansion */
  195. __u32 fpc; /* valid on KVM_SYNC_VRS or KVM_SYNC_FPRS */
  196. __u8 bpbc : 1; /* bp mode */
  197. __u8 reserved2 : 7;
  198. __u8 padding1[51]; /* riccb needs to be 64byte aligned */
  199. __u8 riccb[64]; /* runtime instrumentation controls block */
  200. };
  201. #define KVM_REG_S390_TODPR (KVM_REG_S390 | KVM_REG_SIZE_U32 | 0x1)
  202. #define KVM_REG_S390_EPOCHDIFF (KVM_REG_S390 | KVM_REG_SIZE_U64 | 0x2)
  203. #define KVM_REG_S390_CPU_TIMER (KVM_REG_S390 | KVM_REG_SIZE_U64 | 0x3)
  204. #define KVM_REG_S390_CLOCK_COMP (KVM_REG_S390 | KVM_REG_SIZE_U64 | 0x4)
  205. #define KVM_REG_S390_PFTOKEN (KVM_REG_S390 | KVM_REG_SIZE_U64 | 0x5)
  206. #define KVM_REG_S390_PFCOMPARE (KVM_REG_S390 | KVM_REG_SIZE_U64 | 0x6)
  207. #define KVM_REG_S390_PFSELECT (KVM_REG_S390 | KVM_REG_SIZE_U64 | 0x7)
  208. #define KVM_REG_S390_PP (KVM_REG_S390 | KVM_REG_SIZE_U64 | 0x8)
  209. #define KVM_REG_S390_GBEA (KVM_REG_S390 | KVM_REG_SIZE_U64 | 0x9)
  210. #endif