vti.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. /*
  2. * vti.h: prototype for generial vt related interface
  3. * Copyright (c) 2004, Intel Corporation.
  4. *
  5. * Xuefei Xu (Anthony Xu) (anthony.xu@intel.com)
  6. * Fred Yang (fred.yang@intel.com)
  7. * Kun Tian (Kevin Tian) (kevin.tian@intel.com)
  8. *
  9. * Copyright (c) 2007, Intel Corporation.
  10. * Zhang xiantao <xiantao.zhang@intel.com>
  11. *
  12. * This program is free software; you can redistribute it and/or modify it
  13. * under the terms and conditions of the GNU General Public License,
  14. * version 2, as published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope it will be useful, but WITHOUT
  17. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  18. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  19. * more details.
  20. *
  21. * You should have received a copy of the GNU General Public License along with
  22. * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
  23. * Place - Suite 330, Boston, MA 02111-1307 USA.
  24. */
  25. #ifndef _KVM_VT_I_H
  26. #define _KVM_VT_I_H
  27. #ifndef __ASSEMBLY__
  28. #include <asm/page.h>
  29. #include <linux/kvm_host.h>
  30. /* define itr.i and itr.d in ia64_itr function */
  31. #define ITR 0x01
  32. #define DTR 0x02
  33. #define IaDTR 0x03
  34. #define IA64_TR_VMM 6 /*itr6, dtr6 : maps vmm code, vmbuffer*/
  35. #define IA64_TR_VM_DATA 7 /*dtr7 : maps current vm data*/
  36. #define RR6 (6UL<<61)
  37. #define RR7 (7UL<<61)
  38. /* config_options in pal_vp_init_env */
  39. #define VP_INITIALIZE 1UL
  40. #define VP_FR_PMC 1UL<<1
  41. #define VP_OPCODE 1UL<<8
  42. #define VP_CAUSE 1UL<<9
  43. #define VP_FW_ACC 1UL<<63
  44. /* init vp env with initializing vm_buffer */
  45. #define VP_INIT_ENV_INITALIZE (VP_INITIALIZE | VP_FR_PMC |\
  46. VP_OPCODE | VP_CAUSE | VP_FW_ACC)
  47. /* init vp env without initializing vm_buffer */
  48. #define VP_INIT_ENV VP_FR_PMC | VP_OPCODE | VP_CAUSE | VP_FW_ACC
  49. #define PAL_VP_CREATE 265
  50. /* Stacked Virt. Initializes a new VPD for the operation of
  51. * a new virtual processor in the virtual environment.
  52. */
  53. #define PAL_VP_ENV_INFO 266
  54. /*Stacked Virt. Returns the parameters needed to enter a virtual environment.*/
  55. #define PAL_VP_EXIT_ENV 267
  56. /*Stacked Virt. Allows a logical processor to exit a virtual environment.*/
  57. #define PAL_VP_INIT_ENV 268
  58. /*Stacked Virt. Allows a logical processor to enter a virtual environment.*/
  59. #define PAL_VP_REGISTER 269
  60. /*Stacked Virt. Register a different host IVT for the virtual processor.*/
  61. #define PAL_VP_RESUME 270
  62. /* Renamed from PAL_VP_RESUME */
  63. #define PAL_VP_RESTORE 270
  64. /*Stacked Virt. Resumes virtual processor operation on the logical processor.*/
  65. #define PAL_VP_SUSPEND 271
  66. /* Renamed from PAL_VP_SUSPEND */
  67. #define PAL_VP_SAVE 271
  68. /* Stacked Virt. Suspends operation for the specified virtual processor on
  69. * the logical processor.
  70. */
  71. #define PAL_VP_TERMINATE 272
  72. /* Stacked Virt. Terminates operation for the specified virtual processor.*/
  73. union vac {
  74. unsigned long value;
  75. struct {
  76. int a_int:1;
  77. int a_from_int_cr:1;
  78. int a_to_int_cr:1;
  79. int a_from_psr:1;
  80. int a_from_cpuid:1;
  81. int a_cover:1;
  82. int a_bsw:1;
  83. long reserved:57;
  84. };
  85. };
  86. union vdc {
  87. unsigned long value;
  88. struct {
  89. int d_vmsw:1;
  90. int d_extint:1;
  91. int d_ibr_dbr:1;
  92. int d_pmc:1;
  93. int d_to_pmd:1;
  94. int d_itm:1;
  95. long reserved:58;
  96. };
  97. };
  98. struct vpd {
  99. union vac vac;
  100. union vdc vdc;
  101. unsigned long virt_env_vaddr;
  102. unsigned long reserved1[29];
  103. unsigned long vhpi;
  104. unsigned long reserved2[95];
  105. unsigned long vgr[16];
  106. unsigned long vbgr[16];
  107. unsigned long vnat;
  108. unsigned long vbnat;
  109. unsigned long vcpuid[5];
  110. unsigned long reserved3[11];
  111. unsigned long vpsr;
  112. unsigned long vpr;
  113. unsigned long reserved4[76];
  114. union {
  115. unsigned long vcr[128];
  116. struct {
  117. unsigned long dcr;
  118. unsigned long itm;
  119. unsigned long iva;
  120. unsigned long rsv1[5];
  121. unsigned long pta;
  122. unsigned long rsv2[7];
  123. unsigned long ipsr;
  124. unsigned long isr;
  125. unsigned long rsv3;
  126. unsigned long iip;
  127. unsigned long ifa;
  128. unsigned long itir;
  129. unsigned long iipa;
  130. unsigned long ifs;
  131. unsigned long iim;
  132. unsigned long iha;
  133. unsigned long rsv4[38];
  134. unsigned long lid;
  135. unsigned long ivr;
  136. unsigned long tpr;
  137. unsigned long eoi;
  138. unsigned long irr[4];
  139. unsigned long itv;
  140. unsigned long pmv;
  141. unsigned long cmcv;
  142. unsigned long rsv5[5];
  143. unsigned long lrr0;
  144. unsigned long lrr1;
  145. unsigned long rsv6[46];
  146. };
  147. };
  148. unsigned long reserved5[128];
  149. unsigned long reserved6[3456];
  150. unsigned long vmm_avail[128];
  151. unsigned long reserved7[4096];
  152. };
  153. #define PAL_PROC_VM_BIT (1UL << 40)
  154. #define PAL_PROC_VMSW_BIT (1UL << 54)
  155. static inline s64 ia64_pal_vp_env_info(u64 *buffer_size,
  156. u64 *vp_env_info)
  157. {
  158. struct ia64_pal_retval iprv;
  159. PAL_CALL_STK(iprv, PAL_VP_ENV_INFO, 0, 0, 0);
  160. *buffer_size = iprv.v0;
  161. *vp_env_info = iprv.v1;
  162. return iprv.status;
  163. }
  164. static inline s64 ia64_pal_vp_exit_env(u64 iva)
  165. {
  166. struct ia64_pal_retval iprv;
  167. PAL_CALL_STK(iprv, PAL_VP_EXIT_ENV, (u64)iva, 0, 0);
  168. return iprv.status;
  169. }
  170. static inline s64 ia64_pal_vp_init_env(u64 config_options, u64 pbase_addr,
  171. u64 vbase_addr, u64 *vsa_base)
  172. {
  173. struct ia64_pal_retval iprv;
  174. PAL_CALL_STK(iprv, PAL_VP_INIT_ENV, config_options, pbase_addr,
  175. vbase_addr);
  176. *vsa_base = iprv.v0;
  177. return iprv.status;
  178. }
  179. static inline s64 ia64_pal_vp_restore(u64 *vpd, u64 pal_proc_vector)
  180. {
  181. struct ia64_pal_retval iprv;
  182. PAL_CALL_STK(iprv, PAL_VP_RESTORE, (u64)vpd, pal_proc_vector, 0);
  183. return iprv.status;
  184. }
  185. static inline s64 ia64_pal_vp_save(u64 *vpd, u64 pal_proc_vector)
  186. {
  187. struct ia64_pal_retval iprv;
  188. PAL_CALL_STK(iprv, PAL_VP_SAVE, (u64)vpd, pal_proc_vector, 0);
  189. return iprv.status;
  190. }
  191. #endif
  192. /*VPD field offset*/
  193. #define VPD_VAC_START_OFFSET 0
  194. #define VPD_VDC_START_OFFSET 8
  195. #define VPD_VHPI_START_OFFSET 256
  196. #define VPD_VGR_START_OFFSET 1024
  197. #define VPD_VBGR_START_OFFSET 1152
  198. #define VPD_VNAT_START_OFFSET 1280
  199. #define VPD_VBNAT_START_OFFSET 1288
  200. #define VPD_VCPUID_START_OFFSET 1296
  201. #define VPD_VPSR_START_OFFSET 1424
  202. #define VPD_VPR_START_OFFSET 1432
  203. #define VPD_VRSE_CFLE_START_OFFSET 1440
  204. #define VPD_VCR_START_OFFSET 2048
  205. #define VPD_VTPR_START_OFFSET 2576
  206. #define VPD_VRR_START_OFFSET 3072
  207. #define VPD_VMM_VAIL_START_OFFSET 31744
  208. /*Virtualization faults*/
  209. #define EVENT_MOV_TO_AR 1
  210. #define EVENT_MOV_TO_AR_IMM 2
  211. #define EVENT_MOV_FROM_AR 3
  212. #define EVENT_MOV_TO_CR 4
  213. #define EVENT_MOV_FROM_CR 5
  214. #define EVENT_MOV_TO_PSR 6
  215. #define EVENT_MOV_FROM_PSR 7
  216. #define EVENT_ITC_D 8
  217. #define EVENT_ITC_I 9
  218. #define EVENT_MOV_TO_RR 10
  219. #define EVENT_MOV_TO_DBR 11
  220. #define EVENT_MOV_TO_IBR 12
  221. #define EVENT_MOV_TO_PKR 13
  222. #define EVENT_MOV_TO_PMC 14
  223. #define EVENT_MOV_TO_PMD 15
  224. #define EVENT_ITR_D 16
  225. #define EVENT_ITR_I 17
  226. #define EVENT_MOV_FROM_RR 18
  227. #define EVENT_MOV_FROM_DBR 19
  228. #define EVENT_MOV_FROM_IBR 20
  229. #define EVENT_MOV_FROM_PKR 21
  230. #define EVENT_MOV_FROM_PMC 22
  231. #define EVENT_MOV_FROM_CPUID 23
  232. #define EVENT_SSM 24
  233. #define EVENT_RSM 25
  234. #define EVENT_PTC_L 26
  235. #define EVENT_PTC_G 27
  236. #define EVENT_PTC_GA 28
  237. #define EVENT_PTR_D 29
  238. #define EVENT_PTR_I 30
  239. #define EVENT_THASH 31
  240. #define EVENT_TTAG 32
  241. #define EVENT_TPA 33
  242. #define EVENT_TAK 34
  243. #define EVENT_PTC_E 35
  244. #define EVENT_COVER 36
  245. #define EVENT_RFI 37
  246. #define EVENT_BSW_0 38
  247. #define EVENT_BSW_1 39
  248. #define EVENT_VMSW 40
  249. /**PAL virtual services offsets */
  250. #define PAL_VPS_RESUME_NORMAL 0x0000
  251. #define PAL_VPS_RESUME_HANDLER 0x0400
  252. #define PAL_VPS_SYNC_READ 0x0800
  253. #define PAL_VPS_SYNC_WRITE 0x0c00
  254. #define PAL_VPS_SET_PENDING_INTERRUPT 0x1000
  255. #define PAL_VPS_THASH 0x1400
  256. #define PAL_VPS_TTAG 0x1800
  257. #define PAL_VPS_RESTORE 0x1c00
  258. #define PAL_VPS_SAVE 0x2000
  259. #endif/* _VT_I_H*/