kvm.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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. struct kvm_regs {
  23. __u64 pc;
  24. __u64 cr;
  25. __u64 ctr;
  26. __u64 lr;
  27. __u64 xer;
  28. __u64 msr;
  29. __u64 srr0;
  30. __u64 srr1;
  31. __u64 pid;
  32. __u64 sprg0;
  33. __u64 sprg1;
  34. __u64 sprg2;
  35. __u64 sprg3;
  36. __u64 sprg4;
  37. __u64 sprg5;
  38. __u64 sprg6;
  39. __u64 sprg7;
  40. __u64 gpr[32];
  41. };
  42. #define KVM_SREGS_E_IMPL_NONE 0
  43. #define KVM_SREGS_E_IMPL_FSL 1
  44. #define KVM_SREGS_E_FSL_PIDn (1 << 0) /* PID1/PID2 */
  45. /*
  46. * Feature bits indicate which sections of the sregs struct are valid,
  47. * both in KVM_GET_SREGS and KVM_SET_SREGS. On KVM_SET_SREGS, registers
  48. * corresponding to unset feature bits will not be modified. This allows
  49. * restoring a checkpoint made without that feature, while keeping the
  50. * default values of the new registers.
  51. *
  52. * KVM_SREGS_E_BASE contains:
  53. * CSRR0/1 (refers to SRR2/3 on 40x)
  54. * ESR
  55. * DEAR
  56. * MCSR
  57. * TSR
  58. * TCR
  59. * DEC
  60. * TB
  61. * VRSAVE (USPRG0)
  62. */
  63. #define KVM_SREGS_E_BASE (1 << 0)
  64. /*
  65. * KVM_SREGS_E_ARCH206 contains:
  66. *
  67. * PIR
  68. * MCSRR0/1
  69. * DECAR
  70. * IVPR
  71. */
  72. #define KVM_SREGS_E_ARCH206 (1 << 1)
  73. /*
  74. * Contains EPCR, plus the upper half of 64-bit registers
  75. * that are 32-bit on 32-bit implementations.
  76. */
  77. #define KVM_SREGS_E_64 (1 << 2)
  78. #define KVM_SREGS_E_SPRG8 (1 << 3)
  79. #define KVM_SREGS_E_MCIVPR (1 << 4)
  80. /*
  81. * IVORs are used -- contains IVOR0-15, plus additional IVORs
  82. * in combination with an appropriate feature bit.
  83. */
  84. #define KVM_SREGS_E_IVOR (1 << 5)
  85. /*
  86. * Contains MAS0-4, MAS6-7, TLBnCFG, MMUCFG.
  87. * Also TLBnPS if MMUCFG[MAVN] = 1.
  88. */
  89. #define KVM_SREGS_E_ARCH206_MMU (1 << 6)
  90. /* DBSR, DBCR, IAC, DAC, DVC */
  91. #define KVM_SREGS_E_DEBUG (1 << 7)
  92. /* Enhanced debug -- DSRR0/1, SPRG9 */
  93. #define KVM_SREGS_E_ED (1 << 8)
  94. /* Embedded Floating Point (SPE) -- IVOR32-34 if KVM_SREGS_E_IVOR */
  95. #define KVM_SREGS_E_SPE (1 << 9)
  96. /* External Proxy (EXP) -- EPR */
  97. #define KVM_SREGS_EXP (1 << 10)
  98. /* External PID (E.PD) -- EPSC/EPLC */
  99. #define KVM_SREGS_E_PD (1 << 11)
  100. /* Processor Control (E.PC) -- IVOR36-37 if KVM_SREGS_E_IVOR */
  101. #define KVM_SREGS_E_PC (1 << 12)
  102. /* Page table (E.PT) -- EPTCFG */
  103. #define KVM_SREGS_E_PT (1 << 13)
  104. /* Embedded Performance Monitor (E.PM) -- IVOR35 if KVM_SREGS_E_IVOR */
  105. #define KVM_SREGS_E_PM (1 << 14)
  106. /*
  107. * Special updates:
  108. *
  109. * Some registers may change even while a vcpu is not running.
  110. * To avoid losing these changes, by default these registers are
  111. * not updated by KVM_SET_SREGS. To force an update, set the bit
  112. * in u.e.update_special corresponding to the register to be updated.
  113. *
  114. * The update_special field is zero on return from KVM_GET_SREGS.
  115. *
  116. * When restoring a checkpoint, the caller can set update_special
  117. * to 0xffffffff to ensure that everything is restored, even new features
  118. * that the caller doesn't know about.
  119. */
  120. #define KVM_SREGS_E_UPDATE_MCSR (1 << 0)
  121. #define KVM_SREGS_E_UPDATE_TSR (1 << 1)
  122. #define KVM_SREGS_E_UPDATE_DEC (1 << 2)
  123. #define KVM_SREGS_E_UPDATE_DBSR (1 << 3)
  124. /*
  125. * In KVM_SET_SREGS, reserved/pad fields must be left untouched from a
  126. * previous KVM_GET_REGS.
  127. *
  128. * Unless otherwise indicated, setting any register with KVM_SET_SREGS
  129. * directly sets its value. It does not trigger any special semantics such
  130. * as write-one-to-clear. Calling KVM_SET_SREGS on an unmodified struct
  131. * just received from KVM_GET_SREGS is always a no-op.
  132. */
  133. struct kvm_sregs {
  134. __u32 pvr;
  135. union {
  136. struct {
  137. __u64 sdr1;
  138. struct {
  139. struct {
  140. __u64 slbe;
  141. __u64 slbv;
  142. } slb[64];
  143. } ppc64;
  144. struct {
  145. __u32 sr[16];
  146. __u64 ibat[8];
  147. __u64 dbat[8];
  148. } ppc32;
  149. } s;
  150. struct {
  151. union {
  152. struct { /* KVM_SREGS_E_IMPL_FSL */
  153. __u32 features; /* KVM_SREGS_E_FSL_ */
  154. __u32 svr;
  155. __u64 mcar;
  156. __u32 hid0;
  157. /* KVM_SREGS_E_FSL_PIDn */
  158. __u32 pid1, pid2;
  159. } fsl;
  160. __u8 pad[256];
  161. } impl;
  162. __u32 features; /* KVM_SREGS_E_ */
  163. __u32 impl_id; /* KVM_SREGS_E_IMPL_ */
  164. __u32 update_special; /* KVM_SREGS_E_UPDATE_ */
  165. __u32 pir; /* read-only */
  166. __u64 sprg8;
  167. __u64 sprg9; /* E.ED */
  168. __u64 csrr0;
  169. __u64 dsrr0; /* E.ED */
  170. __u64 mcsrr0;
  171. __u32 csrr1;
  172. __u32 dsrr1; /* E.ED */
  173. __u32 mcsrr1;
  174. __u32 esr;
  175. __u64 dear;
  176. __u64 ivpr;
  177. __u64 mcivpr;
  178. __u64 mcsr; /* KVM_SREGS_E_UPDATE_MCSR */
  179. __u32 tsr; /* KVM_SREGS_E_UPDATE_TSR */
  180. __u32 tcr;
  181. __u32 decar;
  182. __u32 dec; /* KVM_SREGS_E_UPDATE_DEC */
  183. /*
  184. * Userspace can read TB directly, but the
  185. * value reported here is consistent with "dec".
  186. *
  187. * Read-only.
  188. */
  189. __u64 tb;
  190. __u32 dbsr; /* KVM_SREGS_E_UPDATE_DBSR */
  191. __u32 dbcr[3];
  192. __u32 iac[4];
  193. __u32 dac[2];
  194. __u32 dvc[2];
  195. __u8 num_iac; /* read-only */
  196. __u8 num_dac; /* read-only */
  197. __u8 num_dvc; /* read-only */
  198. __u8 pad;
  199. __u32 epr; /* EXP */
  200. __u32 vrsave; /* a.k.a. USPRG0 */
  201. __u32 epcr; /* KVM_SREGS_E_64 */
  202. __u32 mas0;
  203. __u32 mas1;
  204. __u64 mas2;
  205. __u64 mas7_3;
  206. __u32 mas4;
  207. __u32 mas6;
  208. __u32 ivor_low[16]; /* IVOR0-15 */
  209. __u32 ivor_high[18]; /* IVOR32+, plus room to expand */
  210. __u32 mmucfg; /* read-only */
  211. __u32 eptcfg; /* E.PT, read-only */
  212. __u32 tlbcfg[4];/* read-only */
  213. __u32 tlbps[4]; /* read-only */
  214. __u32 eplc, epsc; /* E.PD */
  215. } e;
  216. __u8 pad[1020];
  217. } u;
  218. };
  219. struct kvm_fpu {
  220. __u64 fpr[32];
  221. };
  222. struct kvm_debug_exit_arch {
  223. };
  224. /* for KVM_SET_GUEST_DEBUG */
  225. struct kvm_guest_debug_arch {
  226. };
  227. #define KVM_REG_MASK 0x001f
  228. #define KVM_REG_EXT_MASK 0xffe0
  229. #define KVM_REG_GPR 0x0000
  230. #define KVM_REG_FPR 0x0020
  231. #define KVM_REG_QPR 0x0040
  232. #define KVM_REG_FQPR 0x0060
  233. #define KVM_INTERRUPT_SET -1U
  234. #define KVM_INTERRUPT_UNSET -2U
  235. #define KVM_INTERRUPT_SET_LEVEL -3U
  236. #endif /* __LINUX_KVM_POWERPC_H */