interface.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. /******************************************************************************
  2. * arch-ia64/hypervisor-if.h
  3. *
  4. * Guest OS interface to IA64 Xen.
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7. * of this software and associated documentation files (the "Software"), to
  8. * deal in the Software without restriction, including without limitation the
  9. * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  10. * sell copies of the Software, and to permit persons to whom the Software is
  11. * furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  21. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  22. * DEALINGS IN THE SOFTWARE.
  23. *
  24. * Copyright by those who contributed. (in alphabetical order)
  25. *
  26. * Anthony Xu <anthony.xu@intel.com>
  27. * Eddie Dong <eddie.dong@intel.com>
  28. * Fred Yang <fred.yang@intel.com>
  29. * Kevin Tian <kevin.tian@intel.com>
  30. * Alex Williamson <alex.williamson@hp.com>
  31. * Chris Wright <chrisw@sous-sol.org>
  32. * Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
  33. * Dietmar Hahn <dietmar.hahn@fujitsu-siemens.com>
  34. * Hollis Blanchard <hollisb@us.ibm.com>
  35. * Isaku Yamahata <yamahata@valinux.co.jp>
  36. * Jan Beulich <jbeulich@novell.com>
  37. * John Levon <john.levon@sun.com>
  38. * Kazuhiro Suzuki <kaz@jp.fujitsu.com>
  39. * Keir Fraser <keir.fraser@citrix.com>
  40. * Kouya Shimura <kouya@jp.fujitsu.com>
  41. * Masaki Kanno <kanno.masaki@jp.fujitsu.com>
  42. * Matt Chapman <matthewc@hp.com>
  43. * Matthew Chapman <matthewc@hp.com>
  44. * Samuel Thibault <samuel.thibault@eu.citrix.com>
  45. * Tomonari Horikoshi <t.horikoshi@jp.fujitsu.com>
  46. * Tristan Gingold <tgingold@free.fr>
  47. * Tsunehisa Doi <Doi.Tsunehisa@jp.fujitsu.com>
  48. * Yutaka Ezaki <yutaka.ezaki@jp.fujitsu.com>
  49. * Zhang Xin <xing.z.zhang@intel.com>
  50. * Zhang xiantao <xiantao.zhang@intel.com>
  51. * dan.magenheimer@hp.com
  52. * ian.pratt@cl.cam.ac.uk
  53. * michael.fetterman@cl.cam.ac.uk
  54. */
  55. #ifndef _ASM_IA64_XEN_INTERFACE_H
  56. #define _ASM_IA64_XEN_INTERFACE_H
  57. #define __DEFINE_GUEST_HANDLE(name, type) \
  58. typedef struct { type *p; } __guest_handle_ ## name
  59. #define DEFINE_GUEST_HANDLE_STRUCT(name) \
  60. __DEFINE_GUEST_HANDLE(name, struct name)
  61. #define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
  62. #define GUEST_HANDLE(name) __guest_handle_ ## name
  63. #define GUEST_HANDLE_64(name) GUEST_HANDLE(name)
  64. #define set_xen_guest_handle(hnd, val) do { (hnd).p = val; } while (0)
  65. #ifndef __ASSEMBLY__
  66. /* Guest handles for primitive C types. */
  67. __DEFINE_GUEST_HANDLE(uchar, unsigned char);
  68. __DEFINE_GUEST_HANDLE(uint, unsigned int);
  69. __DEFINE_GUEST_HANDLE(ulong, unsigned long);
  70. DEFINE_GUEST_HANDLE(char);
  71. DEFINE_GUEST_HANDLE(int);
  72. DEFINE_GUEST_HANDLE(long);
  73. DEFINE_GUEST_HANDLE(void);
  74. DEFINE_GUEST_HANDLE(uint64_t);
  75. DEFINE_GUEST_HANDLE(uint32_t);
  76. typedef unsigned long xen_pfn_t;
  77. DEFINE_GUEST_HANDLE(xen_pfn_t);
  78. #define PRI_xen_pfn "lx"
  79. #endif
  80. /* Arch specific VIRQs definition */
  81. #define VIRQ_ITC VIRQ_ARCH_0 /* V. Virtual itc timer */
  82. #define VIRQ_MCA_CMC VIRQ_ARCH_1 /* MCA cmc interrupt */
  83. #define VIRQ_MCA_CPE VIRQ_ARCH_2 /* MCA cpe interrupt */
  84. /* Maximum number of virtual CPUs in multi-processor guests. */
  85. /* keep sizeof(struct shared_page) <= PAGE_SIZE.
  86. * this is checked in arch/ia64/xen/hypervisor.c. */
  87. #define MAX_VIRT_CPUS 64
  88. #ifndef __ASSEMBLY__
  89. #define INVALID_MFN (~0UL)
  90. union vac {
  91. unsigned long value;
  92. struct {
  93. int a_int:1;
  94. int a_from_int_cr:1;
  95. int a_to_int_cr:1;
  96. int a_from_psr:1;
  97. int a_from_cpuid:1;
  98. int a_cover:1;
  99. int a_bsw:1;
  100. long reserved:57;
  101. };
  102. };
  103. union vdc {
  104. unsigned long value;
  105. struct {
  106. int d_vmsw:1;
  107. int d_extint:1;
  108. int d_ibr_dbr:1;
  109. int d_pmc:1;
  110. int d_to_pmd:1;
  111. int d_itm:1;
  112. long reserved:58;
  113. };
  114. };
  115. struct mapped_regs {
  116. union vac vac;
  117. union vdc vdc;
  118. unsigned long virt_env_vaddr;
  119. unsigned long reserved1[29];
  120. unsigned long vhpi;
  121. unsigned long reserved2[95];
  122. union {
  123. unsigned long vgr[16];
  124. unsigned long bank1_regs[16]; /* bank1 regs (r16-r31)
  125. when bank0 active */
  126. };
  127. union {
  128. unsigned long vbgr[16];
  129. unsigned long bank0_regs[16]; /* bank0 regs (r16-r31)
  130. when bank1 active */
  131. };
  132. unsigned long vnat;
  133. unsigned long vbnat;
  134. unsigned long vcpuid[5];
  135. unsigned long reserved3[11];
  136. unsigned long vpsr;
  137. unsigned long vpr;
  138. unsigned long reserved4[76];
  139. union {
  140. unsigned long vcr[128];
  141. struct {
  142. unsigned long dcr; /* CR0 */
  143. unsigned long itm;
  144. unsigned long iva;
  145. unsigned long rsv1[5];
  146. unsigned long pta; /* CR8 */
  147. unsigned long rsv2[7];
  148. unsigned long ipsr; /* CR16 */
  149. unsigned long isr;
  150. unsigned long rsv3;
  151. unsigned long iip;
  152. unsigned long ifa;
  153. unsigned long itir;
  154. unsigned long iipa;
  155. unsigned long ifs;
  156. unsigned long iim; /* CR24 */
  157. unsigned long iha;
  158. unsigned long rsv4[38];
  159. unsigned long lid; /* CR64 */
  160. unsigned long ivr;
  161. unsigned long tpr;
  162. unsigned long eoi;
  163. unsigned long irr[4];
  164. unsigned long itv; /* CR72 */
  165. unsigned long pmv;
  166. unsigned long cmcv;
  167. unsigned long rsv5[5];
  168. unsigned long lrr0; /* CR80 */
  169. unsigned long lrr1;
  170. unsigned long rsv6[46];
  171. };
  172. };
  173. union {
  174. unsigned long reserved5[128];
  175. struct {
  176. unsigned long precover_ifs;
  177. unsigned long unat; /* not sure if this is needed
  178. until NaT arch is done */
  179. int interrupt_collection_enabled; /* virtual psr.ic */
  180. /* virtual interrupt deliverable flag is
  181. * evtchn_upcall_mask in shared info area now.
  182. * interrupt_mask_addr is the address
  183. * of evtchn_upcall_mask for current vcpu
  184. */
  185. unsigned char *interrupt_mask_addr;
  186. int pending_interruption;
  187. unsigned char vpsr_pp;
  188. unsigned char vpsr_dfh;
  189. unsigned char hpsr_dfh;
  190. unsigned char hpsr_mfh;
  191. unsigned long reserved5_1[4];
  192. int metaphysical_mode; /* 1 = use metaphys mapping
  193. 0 = use virtual */
  194. int banknum; /* 0 or 1, which virtual
  195. register bank is active */
  196. unsigned long rrs[8]; /* region registers */
  197. unsigned long krs[8]; /* kernel registers */
  198. unsigned long tmp[16]; /* temp registers
  199. (e.g. for hyperprivops) */
  200. /* itc paravirtualization
  201. * vAR.ITC = mAR.ITC + itc_offset
  202. * itc_last is one which was lastly passed to
  203. * the guest OS in order to prevent it from
  204. * going backwords.
  205. */
  206. unsigned long itc_offset;
  207. unsigned long itc_last;
  208. };
  209. };
  210. };
  211. struct arch_vcpu_info {
  212. /* nothing */
  213. };
  214. /*
  215. * This structure is used for magic page in domain pseudo physical address
  216. * space and the result of XENMEM_machine_memory_map.
  217. * As the XENMEM_machine_memory_map result,
  218. * xen_memory_map::nr_entries indicates the size in bytes
  219. * including struct xen_ia64_memmap_info. Not the number of entries.
  220. */
  221. struct xen_ia64_memmap_info {
  222. uint64_t efi_memmap_size; /* size of EFI memory map */
  223. uint64_t efi_memdesc_size; /* size of an EFI memory map
  224. * descriptor */
  225. uint32_t efi_memdesc_version; /* memory descriptor version */
  226. void *memdesc[0]; /* array of efi_memory_desc_t */
  227. };
  228. struct arch_shared_info {
  229. /* PFN of the start_info page. */
  230. unsigned long start_info_pfn;
  231. /* Interrupt vector for event channel. */
  232. int evtchn_vector;
  233. /* PFN of memmap_info page */
  234. unsigned int memmap_info_num_pages; /* currently only = 1 case is
  235. supported. */
  236. unsigned long memmap_info_pfn;
  237. uint64_t pad[31];
  238. };
  239. struct xen_callback {
  240. unsigned long ip;
  241. };
  242. typedef struct xen_callback xen_callback_t;
  243. #endif /* !__ASSEMBLY__ */
  244. /* Size of the shared_info area (this is not related to page size). */
  245. #define XSI_SHIFT 14
  246. #define XSI_SIZE (1 << XSI_SHIFT)
  247. /* Log size of mapped_regs area (64 KB - only 4KB is used). */
  248. #define XMAPPEDREGS_SHIFT 12
  249. #define XMAPPEDREGS_SIZE (1 << XMAPPEDREGS_SHIFT)
  250. /* Offset of XASI (Xen arch shared info) wrt XSI_BASE. */
  251. #define XMAPPEDREGS_OFS XSI_SIZE
  252. /* Hyperprivops. */
  253. #define HYPERPRIVOP_START 0x1
  254. #define HYPERPRIVOP_RFI (HYPERPRIVOP_START + 0x0)
  255. #define HYPERPRIVOP_RSM_DT (HYPERPRIVOP_START + 0x1)
  256. #define HYPERPRIVOP_SSM_DT (HYPERPRIVOP_START + 0x2)
  257. #define HYPERPRIVOP_COVER (HYPERPRIVOP_START + 0x3)
  258. #define HYPERPRIVOP_ITC_D (HYPERPRIVOP_START + 0x4)
  259. #define HYPERPRIVOP_ITC_I (HYPERPRIVOP_START + 0x5)
  260. #define HYPERPRIVOP_SSM_I (HYPERPRIVOP_START + 0x6)
  261. #define HYPERPRIVOP_GET_IVR (HYPERPRIVOP_START + 0x7)
  262. #define HYPERPRIVOP_GET_TPR (HYPERPRIVOP_START + 0x8)
  263. #define HYPERPRIVOP_SET_TPR (HYPERPRIVOP_START + 0x9)
  264. #define HYPERPRIVOP_EOI (HYPERPRIVOP_START + 0xa)
  265. #define HYPERPRIVOP_SET_ITM (HYPERPRIVOP_START + 0xb)
  266. #define HYPERPRIVOP_THASH (HYPERPRIVOP_START + 0xc)
  267. #define HYPERPRIVOP_PTC_GA (HYPERPRIVOP_START + 0xd)
  268. #define HYPERPRIVOP_ITR_D (HYPERPRIVOP_START + 0xe)
  269. #define HYPERPRIVOP_GET_RR (HYPERPRIVOP_START + 0xf)
  270. #define HYPERPRIVOP_SET_RR (HYPERPRIVOP_START + 0x10)
  271. #define HYPERPRIVOP_SET_KR (HYPERPRIVOP_START + 0x11)
  272. #define HYPERPRIVOP_FC (HYPERPRIVOP_START + 0x12)
  273. #define HYPERPRIVOP_GET_CPUID (HYPERPRIVOP_START + 0x13)
  274. #define HYPERPRIVOP_GET_PMD (HYPERPRIVOP_START + 0x14)
  275. #define HYPERPRIVOP_GET_EFLAG (HYPERPRIVOP_START + 0x15)
  276. #define HYPERPRIVOP_SET_EFLAG (HYPERPRIVOP_START + 0x16)
  277. #define HYPERPRIVOP_RSM_BE (HYPERPRIVOP_START + 0x17)
  278. #define HYPERPRIVOP_GET_PSR (HYPERPRIVOP_START + 0x18)
  279. #define HYPERPRIVOP_SET_RR0_TO_RR4 (HYPERPRIVOP_START + 0x19)
  280. #define HYPERPRIVOP_MAX (0x1a)
  281. /* Fast and light hypercalls. */
  282. #define __HYPERVISOR_ia64_fast_eoi __HYPERVISOR_arch_1
  283. /* Xencomm macros. */
  284. #define XENCOMM_INLINE_MASK 0xf800000000000000UL
  285. #define XENCOMM_INLINE_FLAG 0x8000000000000000UL
  286. #ifndef __ASSEMBLY__
  287. /*
  288. * Optimization features.
  289. * The hypervisor may do some special optimizations for guests. This hypercall
  290. * can be used to switch on/of these special optimizations.
  291. */
  292. #define __HYPERVISOR_opt_feature 0x700UL
  293. #define XEN_IA64_OPTF_OFF 0x0
  294. #define XEN_IA64_OPTF_ON 0x1
  295. /*
  296. * If this feature is switched on, the hypervisor inserts the
  297. * tlb entries without calling the guests traphandler.
  298. * This is useful in guests using region 7 for identity mapping
  299. * like the linux kernel does.
  300. */
  301. #define XEN_IA64_OPTF_IDENT_MAP_REG7 1
  302. /* Identity mapping of region 4 addresses in HVM. */
  303. #define XEN_IA64_OPTF_IDENT_MAP_REG4 2
  304. /* Identity mapping of region 5 addresses in HVM. */
  305. #define XEN_IA64_OPTF_IDENT_MAP_REG5 3
  306. #define XEN_IA64_OPTF_IDENT_MAP_NOT_SET (0)
  307. struct xen_ia64_opt_feature {
  308. unsigned long cmd; /* Which feature */
  309. unsigned char on; /* Switch feature on/off */
  310. union {
  311. struct {
  312. /* The page protection bit mask of the pte.
  313. * This will be or'ed with the pte. */
  314. unsigned long pgprot;
  315. unsigned long key; /* A protection key for itir.*/
  316. };
  317. };
  318. };
  319. #endif /* __ASSEMBLY__ */
  320. #endif /* _ASM_IA64_XEN_INTERFACE_H */