kvm.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. /*
  2. * This program is free software; you can redistribute it and/or modify
  3. * it under the terms of the GNU General Public License, version 2, as
  4. * published by the Free Software Foundation.
  5. *
  6. * This program is distributed in the hope that it will be useful,
  7. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. * GNU General Public License for more details.
  10. *
  11. * You should have received a copy of the GNU General Public License
  12. * along with this program; if not, write to the Free Software
  13. * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  14. *
  15. * Copyright IBM Corp. 2007
  16. *
  17. * Authors: Hollis Blanchard <hollisb@us.ibm.com>
  18. */
  19. #ifndef __LINUX_KVM_POWERPC_H
  20. #define __LINUX_KVM_POWERPC_H
  21. #include <linux/types.h>
  22. /* Select powerpc specific features in <linux/kvm.h> */
  23. #define __KVM_HAVE_SPAPR_TCE
  24. #define __KVM_HAVE_PPC_SMT
  25. struct kvm_regs {
  26. __u64 pc;
  27. __u64 cr;
  28. __u64 ctr;
  29. __u64 lr;
  30. __u64 xer;
  31. __u64 msr;
  32. __u64 srr0;
  33. __u64 srr1;
  34. __u64 pid;
  35. __u64 sprg0;
  36. __u64 sprg1;
  37. __u64 sprg2;
  38. __u64 sprg3;
  39. __u64 sprg4;
  40. __u64 sprg5;
  41. __u64 sprg6;
  42. __u64 sprg7;
  43. __u64 gpr[32];
  44. };
  45. #define KVM_SREGS_E_IMPL_NONE 0
  46. #define KVM_SREGS_E_IMPL_FSL 1
  47. #define KVM_SREGS_E_FSL_PIDn (1 << 0) /* PID1/PID2 */
  48. /*
  49. * Feature bits indicate which sections of the sregs struct are valid,
  50. * both in KVM_GET_SREGS and KVM_SET_SREGS. On KVM_SET_SREGS, registers
  51. * corresponding to unset feature bits will not be modified. This allows
  52. * restoring a checkpoint made without that feature, while keeping the
  53. * default values of the new registers.
  54. *
  55. * KVM_SREGS_E_BASE contains:
  56. * CSRR0/1 (refers to SRR2/3 on 40x)
  57. * ESR
  58. * DEAR
  59. * MCSR
  60. * TSR
  61. * TCR
  62. * DEC
  63. * TB
  64. * VRSAVE (USPRG0)
  65. */
  66. #define KVM_SREGS_E_BASE (1 << 0)
  67. /*
  68. * KVM_SREGS_E_ARCH206 contains:
  69. *
  70. * PIR
  71. * MCSRR0/1
  72. * DECAR
  73. * IVPR
  74. */
  75. #define KVM_SREGS_E_ARCH206 (1 << 1)
  76. /*
  77. * Contains EPCR, plus the upper half of 64-bit registers
  78. * that are 32-bit on 32-bit implementations.
  79. */
  80. #define KVM_SREGS_E_64 (1 << 2)
  81. #define KVM_SREGS_E_SPRG8 (1 << 3)
  82. #define KVM_SREGS_E_MCIVPR (1 << 4)
  83. /*
  84. * IVORs are used -- contains IVOR0-15, plus additional IVORs
  85. * in combination with an appropriate feature bit.
  86. */
  87. #define KVM_SREGS_E_IVOR (1 << 5)
  88. /*
  89. * Contains MAS0-4, MAS6-7, TLBnCFG, MMUCFG.
  90. * Also TLBnPS if MMUCFG[MAVN] = 1.
  91. */
  92. #define KVM_SREGS_E_ARCH206_MMU (1 << 6)
  93. /* DBSR, DBCR, IAC, DAC, DVC */
  94. #define KVM_SREGS_E_DEBUG (1 << 7)
  95. /* Enhanced debug -- DSRR0/1, SPRG9 */
  96. #define KVM_SREGS_E_ED (1 << 8)
  97. /* Embedded Floating Point (SPE) -- IVOR32-34 if KVM_SREGS_E_IVOR */
  98. #define KVM_SREGS_E_SPE (1 << 9)
  99. /* External Proxy (EXP) -- EPR */
  100. #define KVM_SREGS_EXP (1 << 10)
  101. /* External PID (E.PD) -- EPSC/EPLC */
  102. #define KVM_SREGS_E_PD (1 << 11)
  103. /* Processor Control (E.PC) -- IVOR36-37 if KVM_SREGS_E_IVOR */
  104. #define KVM_SREGS_E_PC (1 << 12)
  105. /* Page table (E.PT) -- EPTCFG */
  106. #define KVM_SREGS_E_PT (1 << 13)
  107. /* Embedded Performance Monitor (E.PM) -- IVOR35 if KVM_SREGS_E_IVOR */
  108. #define KVM_SREGS_E_PM (1 << 14)
  109. /*
  110. * Special updates:
  111. *
  112. * Some registers may change even while a vcpu is not running.
  113. * To avoid losing these changes, by default these registers are
  114. * not updated by KVM_SET_SREGS. To force an update, set the bit
  115. * in u.e.update_special corresponding to the register to be updated.
  116. *
  117. * The update_special field is zero on return from KVM_GET_SREGS.
  118. *
  119. * When restoring a checkpoint, the caller can set update_special
  120. * to 0xffffffff to ensure that everything is restored, even new features
  121. * that the caller doesn't know about.
  122. */
  123. #define KVM_SREGS_E_UPDATE_MCSR (1 << 0)
  124. #define KVM_SREGS_E_UPDATE_TSR (1 << 1)
  125. #define KVM_SREGS_E_UPDATE_DEC (1 << 2)
  126. #define KVM_SREGS_E_UPDATE_DBSR (1 << 3)
  127. /*
  128. * In KVM_SET_SREGS, reserved/pad fields must be left untouched from a
  129. * previous KVM_GET_REGS.
  130. *
  131. * Unless otherwise indicated, setting any register with KVM_SET_SREGS
  132. * directly sets its value. It does not trigger any special semantics such
  133. * as write-one-to-clear. Calling KVM_SET_SREGS on an unmodified struct
  134. * just received from KVM_GET_SREGS is always a no-op.
  135. */
  136. struct kvm_sregs {
  137. __u32 pvr;
  138. union {
  139. struct {
  140. __u64 sdr1;
  141. struct {
  142. struct {
  143. __u64 slbe;
  144. __u64 slbv;
  145. } slb[64];
  146. } ppc64;
  147. struct {
  148. __u32 sr[16];
  149. __u64 ibat[8];
  150. __u64 dbat[8];
  151. } ppc32;
  152. } s;
  153. struct {
  154. union {
  155. struct { /* KVM_SREGS_E_IMPL_FSL */
  156. __u32 features; /* KVM_SREGS_E_FSL_ */
  157. __u32 svr;
  158. __u64 mcar;
  159. __u32 hid0;
  160. /* KVM_SREGS_E_FSL_PIDn */
  161. __u32 pid1, pid2;
  162. } fsl;
  163. __u8 pad[256];
  164. } impl;
  165. __u32 features; /* KVM_SREGS_E_ */
  166. __u32 impl_id; /* KVM_SREGS_E_IMPL_ */
  167. __u32 update_special; /* KVM_SREGS_E_UPDATE_ */
  168. __u32 pir; /* read-only */
  169. __u64 sprg8;
  170. __u64 sprg9; /* E.ED */
  171. __u64 csrr0;
  172. __u64 dsrr0; /* E.ED */
  173. __u64 mcsrr0;
  174. __u32 csrr1;
  175. __u32 dsrr1; /* E.ED */
  176. __u32 mcsrr1;
  177. __u32 esr;
  178. __u64 dear;
  179. __u64 ivpr;
  180. __u64 mcivpr;
  181. __u64 mcsr; /* KVM_SREGS_E_UPDATE_MCSR */
  182. __u32 tsr; /* KVM_SREGS_E_UPDATE_TSR */
  183. __u32 tcr;
  184. __u32 decar;
  185. __u32 dec; /* KVM_SREGS_E_UPDATE_DEC */
  186. /*
  187. * Userspace can read TB directly, but the
  188. * value reported here is consistent with "dec".
  189. *
  190. * Read-only.
  191. */
  192. __u64 tb;
  193. __u32 dbsr; /* KVM_SREGS_E_UPDATE_DBSR */
  194. __u32 dbcr[3];
  195. __u32 iac[4];
  196. __u32 dac[2];
  197. __u32 dvc[2];
  198. __u8 num_iac; /* read-only */
  199. __u8 num_dac; /* read-only */
  200. __u8 num_dvc; /* read-only */
  201. __u8 pad;
  202. __u32 epr; /* EXP */
  203. __u32 vrsave; /* a.k.a. USPRG0 */
  204. __u32 epcr; /* KVM_SREGS_E_64 */
  205. __u32 mas0;
  206. __u32 mas1;
  207. __u64 mas2;
  208. __u64 mas7_3;
  209. __u32 mas4;
  210. __u32 mas6;
  211. __u32 ivor_low[16]; /* IVOR0-15 */
  212. __u32 ivor_high[18]; /* IVOR32+, plus room to expand */
  213. __u32 mmucfg; /* read-only */
  214. __u32 eptcfg; /* E.PT, read-only */
  215. __u32 tlbcfg[4];/* read-only */
  216. __u32 tlbps[4]; /* read-only */
  217. __u32 eplc, epsc; /* E.PD */
  218. } e;
  219. __u8 pad[1020];
  220. } u;
  221. };
  222. struct kvm_fpu {
  223. __u64 fpr[32];
  224. };
  225. struct kvm_debug_exit_arch {
  226. };
  227. /* for KVM_SET_GUEST_DEBUG */
  228. struct kvm_guest_debug_arch {
  229. };
  230. /* definition of registers in kvm_run */
  231. struct kvm_sync_regs {
  232. };
  233. #define KVM_INTERRUPT_SET -1U
  234. #define KVM_INTERRUPT_UNSET -2U
  235. #define KVM_INTERRUPT_SET_LEVEL -3U
  236. #define KVM_CPU_440 1
  237. #define KVM_CPU_E500V2 2
  238. #define KVM_CPU_3S_32 3
  239. #define KVM_CPU_3S_64 4
  240. /* for KVM_CAP_SPAPR_TCE */
  241. struct kvm_create_spapr_tce {
  242. __u64 liobn;
  243. __u32 window_size;
  244. };
  245. /* for KVM_ALLOCATE_RMA */
  246. struct kvm_allocate_rma {
  247. __u64 rma_size;
  248. };
  249. struct kvm_book3e_206_tlb_entry {
  250. __u32 mas8;
  251. __u32 mas1;
  252. __u64 mas2;
  253. __u64 mas7_3;
  254. };
  255. struct kvm_book3e_206_tlb_params {
  256. /*
  257. * For mmu types KVM_MMU_FSL_BOOKE_NOHV and KVM_MMU_FSL_BOOKE_HV:
  258. *
  259. * - The number of ways of TLB0 must be a power of two between 2 and
  260. * 16.
  261. * - TLB1 must be fully associative.
  262. * - The size of TLB0 must be a multiple of the number of ways, and
  263. * the number of sets must be a power of two.
  264. * - The size of TLB1 may not exceed 64 entries.
  265. * - TLB0 supports 4 KiB pages.
  266. * - The page sizes supported by TLB1 are as indicated by
  267. * TLB1CFG (if MMUCFG[MAVN] = 0) or TLB1PS (if MMUCFG[MAVN] = 1)
  268. * as returned by KVM_GET_SREGS.
  269. * - TLB2 and TLB3 are reserved, and their entries in tlb_sizes[]
  270. * and tlb_ways[] must be zero.
  271. *
  272. * tlb_ways[n] = tlb_sizes[n] means the array is fully associative.
  273. *
  274. * KVM will adjust TLBnCFG based on the sizes configured here,
  275. * though arrays greater than 2048 entries will have TLBnCFG[NENTRY]
  276. * set to zero.
  277. */
  278. __u32 tlb_sizes[4];
  279. __u32 tlb_ways[4];
  280. __u32 reserved[8];
  281. };
  282. #define KVM_REG_PPC_HIOR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x1)
  283. #endif /* __LINUX_KVM_POWERPC_H */