2
0

xen.h 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032
  1. /* SPDX-License-Identifier: MIT */
  2. /******************************************************************************
  3. * xen.h
  4. *
  5. * Guest OS interface to Xen.
  6. *
  7. * Copyright (c) 2004, K A Fraser
  8. */
  9. #ifndef __XEN_PUBLIC_XEN_H__
  10. #define __XEN_PUBLIC_XEN_H__
  11. #include "xen-compat.h"
  12. #if defined(__i386__) || defined(__x86_64__)
  13. #include "arch-x86/xen.h"
  14. #elif defined(__arm__) || defined (__aarch64__)
  15. #include "arch-arm.h"
  16. #else
  17. #error "Unsupported architecture"
  18. #endif
  19. #ifndef __ASSEMBLY__
  20. /* Guest handles for primitive C types. */
  21. DEFINE_XEN_GUEST_HANDLE(char);
  22. __DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char);
  23. DEFINE_XEN_GUEST_HANDLE(int);
  24. __DEFINE_XEN_GUEST_HANDLE(uint, unsigned int);
  25. #if __XEN_INTERFACE_VERSION__ < 0x00040300
  26. DEFINE_XEN_GUEST_HANDLE(long);
  27. __DEFINE_XEN_GUEST_HANDLE(ulong, unsigned long);
  28. #endif
  29. DEFINE_XEN_GUEST_HANDLE(void);
  30. DEFINE_XEN_GUEST_HANDLE(uint64_t);
  31. DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);
  32. DEFINE_XEN_GUEST_HANDLE(xen_ulong_t);
  33. /* Define a variable length array (depends on compiler). */
  34. #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  35. #define XEN_FLEX_ARRAY_DIM
  36. #elif defined(__GNUC__)
  37. #define XEN_FLEX_ARRAY_DIM 0
  38. #else
  39. #define XEN_FLEX_ARRAY_DIM 1 /* variable size */
  40. #endif
  41. /* Turn a plain number into a C unsigned (long (long)) constant. */
  42. #define __xen_mk_uint(x) x ## U
  43. #define __xen_mk_ulong(x) x ## UL
  44. #ifndef __xen_mk_ullong
  45. # define __xen_mk_ullong(x) x ## ULL
  46. #endif
  47. #define xen_mk_uint(x) __xen_mk_uint(x)
  48. #define xen_mk_ulong(x) __xen_mk_ulong(x)
  49. #define xen_mk_ullong(x) __xen_mk_ullong(x)
  50. #else
  51. /* In assembly code we cannot use C numeric constant suffixes. */
  52. #define xen_mk_uint(x) x
  53. #define xen_mk_ulong(x) x
  54. #define xen_mk_ullong(x) x
  55. #endif
  56. /*
  57. * HYPERCALLS
  58. */
  59. /* `incontents 100 hcalls List of hypercalls
  60. * ` enum hypercall_num { // __HYPERVISOR_* => HYPERVISOR_*()
  61. */
  62. #define __HYPERVISOR_set_trap_table 0
  63. #define __HYPERVISOR_mmu_update 1
  64. #define __HYPERVISOR_set_gdt 2
  65. #define __HYPERVISOR_stack_switch 3
  66. #define __HYPERVISOR_set_callbacks 4
  67. #define __HYPERVISOR_fpu_taskswitch 5
  68. #define __HYPERVISOR_sched_op_compat 6 /* compat since 0x00030101 */
  69. #define __HYPERVISOR_platform_op 7
  70. #define __HYPERVISOR_set_debugreg 8
  71. #define __HYPERVISOR_get_debugreg 9
  72. #define __HYPERVISOR_update_descriptor 10
  73. #define __HYPERVISOR_memory_op 12
  74. #define __HYPERVISOR_multicall 13
  75. #define __HYPERVISOR_update_va_mapping 14
  76. #define __HYPERVISOR_set_timer_op 15
  77. #define __HYPERVISOR_event_channel_op_compat 16 /* compat since 0x00030202 */
  78. #define __HYPERVISOR_xen_version 17
  79. #define __HYPERVISOR_console_io 18
  80. #define __HYPERVISOR_physdev_op_compat 19 /* compat since 0x00030202 */
  81. #define __HYPERVISOR_grant_table_op 20
  82. #define __HYPERVISOR_vm_assist 21
  83. #define __HYPERVISOR_update_va_mapping_otherdomain 22
  84. #define __HYPERVISOR_iret 23 /* x86 only */
  85. #define __HYPERVISOR_vcpu_op 24
  86. #define __HYPERVISOR_set_segment_base 25 /* x86/64 only */
  87. #define __HYPERVISOR_mmuext_op 26
  88. #define __HYPERVISOR_xsm_op 27
  89. #define __HYPERVISOR_nmi_op 28
  90. #define __HYPERVISOR_sched_op 29
  91. #define __HYPERVISOR_callback_op 30
  92. #define __HYPERVISOR_xenoprof_op 31
  93. #define __HYPERVISOR_event_channel_op 32
  94. #define __HYPERVISOR_physdev_op 33
  95. #define __HYPERVISOR_hvm_op 34
  96. #define __HYPERVISOR_sysctl 35
  97. #define __HYPERVISOR_domctl 36
  98. #define __HYPERVISOR_kexec_op 37
  99. #define __HYPERVISOR_tmem_op 38
  100. #define __HYPERVISOR_argo_op 39
  101. #define __HYPERVISOR_xenpmu_op 40
  102. #define __HYPERVISOR_dm_op 41
  103. #define __HYPERVISOR_hypfs_op 42
  104. /* Architecture-specific hypercall definitions. */
  105. #define __HYPERVISOR_arch_0 48
  106. #define __HYPERVISOR_arch_1 49
  107. #define __HYPERVISOR_arch_2 50
  108. #define __HYPERVISOR_arch_3 51
  109. #define __HYPERVISOR_arch_4 52
  110. #define __HYPERVISOR_arch_5 53
  111. #define __HYPERVISOR_arch_6 54
  112. #define __HYPERVISOR_arch_7 55
  113. /* ` } */
  114. /*
  115. * HYPERCALL COMPATIBILITY.
  116. */
  117. /* New sched_op hypercall introduced in 0x00030101. */
  118. #if __XEN_INTERFACE_VERSION__ < 0x00030101
  119. #undef __HYPERVISOR_sched_op
  120. #define __HYPERVISOR_sched_op __HYPERVISOR_sched_op_compat
  121. #endif
  122. /* New event-channel and physdev hypercalls introduced in 0x00030202. */
  123. #if __XEN_INTERFACE_VERSION__ < 0x00030202
  124. #undef __HYPERVISOR_event_channel_op
  125. #define __HYPERVISOR_event_channel_op __HYPERVISOR_event_channel_op_compat
  126. #undef __HYPERVISOR_physdev_op
  127. #define __HYPERVISOR_physdev_op __HYPERVISOR_physdev_op_compat
  128. #endif
  129. /* New platform_op hypercall introduced in 0x00030204. */
  130. #if __XEN_INTERFACE_VERSION__ < 0x00030204
  131. #define __HYPERVISOR_dom0_op __HYPERVISOR_platform_op
  132. #endif
  133. /*
  134. * VIRTUAL INTERRUPTS
  135. *
  136. * Virtual interrupts that a guest OS may receive from Xen.
  137. *
  138. * In the side comments, 'V.' denotes a per-VCPU VIRQ while 'G.' denotes a
  139. * global VIRQ. The former can be bound once per VCPU and cannot be re-bound.
  140. * The latter can be allocated only once per guest: they must initially be
  141. * allocated to VCPU0 but can subsequently be re-bound.
  142. */
  143. /* ` enum virq { */
  144. #define VIRQ_TIMER 0 /* V. Timebase update, and/or requested timeout. */
  145. #define VIRQ_DEBUG 1 /* V. Request guest to dump debug info. */
  146. #define VIRQ_CONSOLE 2 /* G. (DOM0) Bytes received on emergency console. */
  147. #define VIRQ_DOM_EXC 3 /* G. (DOM0) Exceptional event for some domain. */
  148. #define VIRQ_TBUF 4 /* G. (DOM0) Trace buffer has records available. */
  149. #define VIRQ_DEBUGGER 6 /* G. (DOM0) A domain has paused for debugging. */
  150. #define VIRQ_XENOPROF 7 /* V. XenOprofile interrupt: new sample available */
  151. #define VIRQ_CON_RING 8 /* G. (DOM0) Bytes received on console */
  152. #define VIRQ_PCPU_STATE 9 /* G. (DOM0) PCPU state changed */
  153. #define VIRQ_MEM_EVENT 10 /* G. (DOM0) A memory event has occurred */
  154. #define VIRQ_ARGO 11 /* G. Argo interdomain message notification */
  155. #define VIRQ_ENOMEM 12 /* G. (DOM0) Low on heap memory */
  156. #define VIRQ_XENPMU 13 /* V. PMC interrupt */
  157. /* Architecture-specific VIRQ definitions. */
  158. #define VIRQ_ARCH_0 16
  159. #define VIRQ_ARCH_1 17
  160. #define VIRQ_ARCH_2 18
  161. #define VIRQ_ARCH_3 19
  162. #define VIRQ_ARCH_4 20
  163. #define VIRQ_ARCH_5 21
  164. #define VIRQ_ARCH_6 22
  165. #define VIRQ_ARCH_7 23
  166. /* ` } */
  167. #define NR_VIRQS 24
  168. /*
  169. * ` enum neg_errnoval
  170. * ` HYPERVISOR_mmu_update(const struct mmu_update reqs[],
  171. * ` unsigned count, unsigned *done_out,
  172. * ` unsigned foreigndom)
  173. * `
  174. * @reqs is an array of mmu_update_t structures ((ptr, val) pairs).
  175. * @count is the length of the above array.
  176. * @pdone is an output parameter indicating number of completed operations
  177. * @foreigndom[15:0]: FD, the expected owner of data pages referenced in this
  178. * hypercall invocation. Can be DOMID_SELF.
  179. * @foreigndom[31:16]: PFD, the expected owner of pagetable pages referenced
  180. * in this hypercall invocation. The value of this field
  181. * (x) encodes the PFD as follows:
  182. * x == 0 => PFD == DOMID_SELF
  183. * x != 0 => PFD == x - 1
  184. *
  185. * Sub-commands: ptr[1:0] specifies the appropriate MMU_* command.
  186. * -------------
  187. * ptr[1:0] == MMU_NORMAL_PT_UPDATE:
  188. * Updates an entry in a page table belonging to PFD. If updating an L1 table,
  189. * and the new table entry is valid/present, the mapped frame must belong to
  190. * FD. If attempting to map an I/O page then the caller assumes the privilege
  191. * of the FD.
  192. * FD == DOMID_IO: Permit /only/ I/O mappings, at the priv level of the caller.
  193. * FD == DOMID_XEN: Map restricted areas of Xen's heap space.
  194. * ptr[:2] -- Machine address of the page-table entry to modify.
  195. * val -- Value to write.
  196. *
  197. * There also certain implicit requirements when using this hypercall. The
  198. * pages that make up a pagetable must be mapped read-only in the guest.
  199. * This prevents uncontrolled guest updates to the pagetable. Xen strictly
  200. * enforces this, and will disallow any pagetable update which will end up
  201. * mapping pagetable page RW, and will disallow using any writable page as a
  202. * pagetable. In practice it means that when constructing a page table for a
  203. * process, thread, etc, we MUST be very dilligient in following these rules:
  204. * 1). Start with top-level page (PGD or in Xen language: L4). Fill out
  205. * the entries.
  206. * 2). Keep on going, filling out the upper (PUD or L3), and middle (PMD
  207. * or L2).
  208. * 3). Start filling out the PTE table (L1) with the PTE entries. Once
  209. * done, make sure to set each of those entries to RO (so writeable bit
  210. * is unset). Once that has been completed, set the PMD (L2) for this
  211. * PTE table as RO.
  212. * 4). When completed with all of the PMD (L2) entries, and all of them have
  213. * been set to RO, make sure to set RO the PUD (L3). Do the same
  214. * operation on PGD (L4) pagetable entries that have a PUD (L3) entry.
  215. * 5). Now before you can use those pages (so setting the cr3), you MUST also
  216. * pin them so that the hypervisor can verify the entries. This is done
  217. * via the HYPERVISOR_mmuext_op(MMUEXT_PIN_L4_TABLE, guest physical frame
  218. * number of the PGD (L4)). And this point the HYPERVISOR_mmuext_op(
  219. * MMUEXT_NEW_BASEPTR, guest physical frame number of the PGD (L4)) can be
  220. * issued.
  221. * For 32-bit guests, the L4 is not used (as there is less pagetables), so
  222. * instead use L3.
  223. * At this point the pagetables can be modified using the MMU_NORMAL_PT_UPDATE
  224. * hypercall. Also if so desired the OS can also try to write to the PTE
  225. * and be trapped by the hypervisor (as the PTE entry is RO).
  226. *
  227. * To deallocate the pages, the operations are the reverse of the steps
  228. * mentioned above. The argument is MMUEXT_UNPIN_TABLE for all levels and the
  229. * pagetable MUST not be in use (meaning that the cr3 is not set to it).
  230. *
  231. * ptr[1:0] == MMU_MACHPHYS_UPDATE:
  232. * Updates an entry in the machine->pseudo-physical mapping table.
  233. * ptr[:2] -- Machine address within the frame whose mapping to modify.
  234. * The frame must belong to the FD, if one is specified.
  235. * val -- Value to write into the mapping entry.
  236. *
  237. * ptr[1:0] == MMU_PT_UPDATE_PRESERVE_AD:
  238. * As MMU_NORMAL_PT_UPDATE above, but A/D bits currently in the PTE are ORed
  239. * with those in @val.
  240. *
  241. * ptr[1:0] == MMU_PT_UPDATE_NO_TRANSLATE:
  242. * As MMU_NORMAL_PT_UPDATE above, but @val is not translated though FD
  243. * page tables.
  244. *
  245. * @val is usually the machine frame number along with some attributes.
  246. * The attributes by default follow the architecture defined bits. Meaning that
  247. * if this is a X86_64 machine and four page table layout is used, the layout
  248. * of val is:
  249. * - 63 if set means No execute (NX)
  250. * - 46-13 the machine frame number
  251. * - 12 available for guest
  252. * - 11 available for guest
  253. * - 10 available for guest
  254. * - 9 available for guest
  255. * - 8 global
  256. * - 7 PAT (PSE is disabled, must use hypercall to make 4MB or 2MB pages)
  257. * - 6 dirty
  258. * - 5 accessed
  259. * - 4 page cached disabled
  260. * - 3 page write through
  261. * - 2 userspace accessible
  262. * - 1 writeable
  263. * - 0 present
  264. *
  265. * The one bits that does not fit with the default layout is the PAGE_PSE
  266. * also called PAGE_PAT). The MMUEXT_[UN]MARK_SUPER arguments to the
  267. * HYPERVISOR_mmuext_op serve as mechanism to set a pagetable to be 4MB
  268. * (or 2MB) instead of using the PAGE_PSE bit.
  269. *
  270. * The reason that the PAGE_PSE (bit 7) is not being utilized is due to Xen
  271. * using it as the Page Attribute Table (PAT) bit - for details on it please
  272. * refer to Intel SDM 10.12. The PAT allows to set the caching attributes of
  273. * pages instead of using MTRRs.
  274. *
  275. * The PAT MSR is as follows (it is a 64-bit value, each entry is 8 bits):
  276. * PAT4 PAT0
  277. * +-----+-----+----+----+----+-----+----+----+
  278. * | UC | UC- | WC | WB | UC | UC- | WC | WB | <= Linux
  279. * +-----+-----+----+----+----+-----+----+----+
  280. * | UC | UC- | WT | WB | UC | UC- | WT | WB | <= BIOS (default when machine boots)
  281. * +-----+-----+----+----+----+-----+----+----+
  282. * | rsv | rsv | WP | WC | UC | UC- | WT | WB | <= Xen
  283. * +-----+-----+----+----+----+-----+----+----+
  284. *
  285. * The lookup of this index table translates to looking up
  286. * Bit 7, Bit 4, and Bit 3 of val entry:
  287. *
  288. * PAT/PSE (bit 7) ... PCD (bit 4) .. PWT (bit 3).
  289. *
  290. * If all bits are off, then we are using PAT0. If bit 3 turned on,
  291. * then we are using PAT1, if bit 3 and bit 4, then PAT2..
  292. *
  293. * As you can see, the Linux PAT1 translates to PAT4 under Xen. Which means
  294. * that if a guest that follows Linux's PAT setup and would like to set Write
  295. * Combined on pages it MUST use PAT4 entry. Meaning that Bit 7 (PAGE_PAT) is
  296. * set. For example, under Linux it only uses PAT0, PAT1, and PAT2 for the
  297. * caching as:
  298. *
  299. * WB = none (so PAT0)
  300. * WC = PWT (bit 3 on)
  301. * UC = PWT | PCD (bit 3 and 4 are on).
  302. *
  303. * To make it work with Xen, it needs to translate the WC bit as so:
  304. *
  305. * PWT (so bit 3 on) --> PAT (so bit 7 is on) and clear bit 3
  306. *
  307. * And to translate back it would:
  308. *
  309. * PAT (bit 7 on) --> PWT (bit 3 on) and clear bit 7.
  310. */
  311. #define MMU_NORMAL_PT_UPDATE 0 /* checked '*ptr = val'. ptr is MA. */
  312. #define MMU_MACHPHYS_UPDATE 1 /* ptr = MA of frame to modify entry for */
  313. #define MMU_PT_UPDATE_PRESERVE_AD 2 /* atomically: *ptr = val | (*ptr&(A|D)) */
  314. #define MMU_PT_UPDATE_NO_TRANSLATE 3 /* checked '*ptr = val'. ptr is MA. */
  315. /* val never translated. */
  316. /*
  317. * MMU EXTENDED OPERATIONS
  318. *
  319. * ` enum neg_errnoval
  320. * ` HYPERVISOR_mmuext_op(mmuext_op_t uops[],
  321. * ` unsigned int count,
  322. * ` unsigned int *pdone,
  323. * ` unsigned int foreigndom)
  324. */
  325. /* HYPERVISOR_mmuext_op() accepts a list of mmuext_op structures.
  326. * A foreigndom (FD) can be specified (or DOMID_SELF for none).
  327. * Where the FD has some effect, it is described below.
  328. *
  329. * cmd: MMUEXT_(UN)PIN_*_TABLE
  330. * mfn: Machine frame number to be (un)pinned as a p.t. page.
  331. * The frame must belong to the FD, if one is specified.
  332. *
  333. * cmd: MMUEXT_NEW_BASEPTR
  334. * mfn: Machine frame number of new page-table base to install in MMU.
  335. *
  336. * cmd: MMUEXT_NEW_USER_BASEPTR [x86/64 only]
  337. * mfn: Machine frame number of new page-table base to install in MMU
  338. * when in user space.
  339. *
  340. * cmd: MMUEXT_TLB_FLUSH_LOCAL
  341. * No additional arguments. Flushes local TLB.
  342. *
  343. * cmd: MMUEXT_INVLPG_LOCAL
  344. * linear_addr: Linear address to be flushed from the local TLB.
  345. *
  346. * cmd: MMUEXT_TLB_FLUSH_MULTI
  347. * vcpumask: Pointer to bitmap of VCPUs to be flushed.
  348. *
  349. * cmd: MMUEXT_INVLPG_MULTI
  350. * linear_addr: Linear address to be flushed.
  351. * vcpumask: Pointer to bitmap of VCPUs to be flushed.
  352. *
  353. * cmd: MMUEXT_TLB_FLUSH_ALL
  354. * No additional arguments. Flushes all VCPUs' TLBs.
  355. *
  356. * cmd: MMUEXT_INVLPG_ALL
  357. * linear_addr: Linear address to be flushed from all VCPUs' TLBs.
  358. *
  359. * cmd: MMUEXT_FLUSH_CACHE
  360. * No additional arguments. Writes back and flushes cache contents.
  361. *
  362. * cmd: MMUEXT_FLUSH_CACHE_GLOBAL
  363. * No additional arguments. Writes back and flushes cache contents
  364. * on all CPUs in the system.
  365. *
  366. * cmd: MMUEXT_SET_LDT
  367. * linear_addr: Linear address of LDT base (NB. must be page-aligned).
  368. * nr_ents: Number of entries in LDT.
  369. *
  370. * cmd: MMUEXT_CLEAR_PAGE
  371. * mfn: Machine frame number to be cleared.
  372. *
  373. * cmd: MMUEXT_COPY_PAGE
  374. * mfn: Machine frame number of the destination page.
  375. * src_mfn: Machine frame number of the source page.
  376. *
  377. * cmd: MMUEXT_[UN]MARK_SUPER
  378. * mfn: Machine frame number of head of superpage to be [un]marked.
  379. */
  380. /* ` enum mmuext_cmd { */
  381. #define MMUEXT_PIN_L1_TABLE 0
  382. #define MMUEXT_PIN_L2_TABLE 1
  383. #define MMUEXT_PIN_L3_TABLE 2
  384. #define MMUEXT_PIN_L4_TABLE 3
  385. #define MMUEXT_UNPIN_TABLE 4
  386. #define MMUEXT_NEW_BASEPTR 5
  387. #define MMUEXT_TLB_FLUSH_LOCAL 6
  388. #define MMUEXT_INVLPG_LOCAL 7
  389. #define MMUEXT_TLB_FLUSH_MULTI 8
  390. #define MMUEXT_INVLPG_MULTI 9
  391. #define MMUEXT_TLB_FLUSH_ALL 10
  392. #define MMUEXT_INVLPG_ALL 11
  393. #define MMUEXT_FLUSH_CACHE 12
  394. #define MMUEXT_SET_LDT 13
  395. #define MMUEXT_NEW_USER_BASEPTR 15
  396. #define MMUEXT_CLEAR_PAGE 16
  397. #define MMUEXT_COPY_PAGE 17
  398. #define MMUEXT_FLUSH_CACHE_GLOBAL 18
  399. #define MMUEXT_MARK_SUPER 19
  400. #define MMUEXT_UNMARK_SUPER 20
  401. /* ` } */
  402. #ifndef __ASSEMBLY__
  403. struct mmuext_op {
  404. unsigned int cmd; /* => enum mmuext_cmd */
  405. union {
  406. /* [UN]PIN_TABLE, NEW_BASEPTR, NEW_USER_BASEPTR
  407. * CLEAR_PAGE, COPY_PAGE, [UN]MARK_SUPER */
  408. xen_pfn_t mfn;
  409. /* INVLPG_LOCAL, INVLPG_ALL, SET_LDT */
  410. unsigned long linear_addr;
  411. } arg1;
  412. union {
  413. /* SET_LDT */
  414. unsigned int nr_ents;
  415. /* TLB_FLUSH_MULTI, INVLPG_MULTI */
  416. #if __XEN_INTERFACE_VERSION__ >= 0x00030205
  417. XEN_GUEST_HANDLE(const_void) vcpumask;
  418. #else
  419. const void *vcpumask;
  420. #endif
  421. /* COPY_PAGE */
  422. xen_pfn_t src_mfn;
  423. } arg2;
  424. };
  425. typedef struct mmuext_op mmuext_op_t;
  426. DEFINE_XEN_GUEST_HANDLE(mmuext_op_t);
  427. #endif
  428. /*
  429. * ` enum neg_errnoval
  430. * ` HYPERVISOR_update_va_mapping(unsigned long va, u64 val,
  431. * ` enum uvm_flags flags)
  432. * `
  433. * ` enum neg_errnoval
  434. * ` HYPERVISOR_update_va_mapping_otherdomain(unsigned long va, u64 val,
  435. * ` enum uvm_flags flags,
  436. * ` domid_t domid)
  437. * `
  438. * ` @va: The virtual address whose mapping we want to change
  439. * ` @val: The new page table entry, must contain a machine address
  440. * ` @flags: Control TLB flushes
  441. */
  442. /* These are passed as 'flags' to update_va_mapping. They can be ORed. */
  443. /* When specifying UVMF_MULTI, also OR in a pointer to a CPU bitmap. */
  444. /* UVMF_LOCAL is merely UVMF_MULTI with a NULL bitmap pointer. */
  445. /* ` enum uvm_flags { */
  446. #define UVMF_NONE (xen_mk_ulong(0)<<0) /* No flushing at all. */
  447. #define UVMF_TLB_FLUSH (xen_mk_ulong(1)<<0) /* Flush entire TLB(s). */
  448. #define UVMF_INVLPG (xen_mk_ulong(2)<<0) /* Flush only one entry. */
  449. #define UVMF_FLUSHTYPE_MASK (xen_mk_ulong(3)<<0)
  450. #define UVMF_MULTI (xen_mk_ulong(0)<<2) /* Flush subset of TLBs. */
  451. #define UVMF_LOCAL (xen_mk_ulong(0)<<2) /* Flush local TLB. */
  452. #define UVMF_ALL (xen_mk_ulong(1)<<2) /* Flush all TLBs. */
  453. /* ` } */
  454. /*
  455. * ` int
  456. * ` HYPERVISOR_console_io(unsigned int cmd,
  457. * ` unsigned int count,
  458. * ` char buffer[]);
  459. *
  460. * @cmd: Command (see below)
  461. * @count: Size of the buffer to read/write
  462. * @buffer: Pointer in the guest memory
  463. *
  464. * List of commands:
  465. *
  466. * * CONSOLEIO_write: Write the buffer to Xen console.
  467. * For the hardware domain, all the characters in the buffer will
  468. * be written. Characters will be printed directly to the console.
  469. * For all the other domains, only the printable characters will be
  470. * written. Characters may be buffered until a newline (i.e '\n') is
  471. * found.
  472. * @return 0 on success, otherwise return an error code.
  473. * * CONSOLEIO_read: Attempts to read up to @count characters from Xen
  474. * console. The maximum buffer size (i.e. @count) supported is 2GB.
  475. * @return the number of characters read on success, otherwise return
  476. * an error code.
  477. */
  478. #define CONSOLEIO_write 0
  479. #define CONSOLEIO_read 1
  480. /*
  481. * Commands to HYPERVISOR_vm_assist().
  482. */
  483. #define VMASST_CMD_enable 0
  484. #define VMASST_CMD_disable 1
  485. /* x86/32 guests: simulate full 4GB segment limits. */
  486. #define VMASST_TYPE_4gb_segments 0
  487. /* x86/32 guests: trap (vector 15) whenever above vmassist is used. */
  488. #define VMASST_TYPE_4gb_segments_notify 1
  489. /*
  490. * x86 guests: support writes to bottom-level PTEs.
  491. * NB1. Page-directory entries cannot be written.
  492. * NB2. Guest must continue to remove all writable mappings of PTEs.
  493. */
  494. #define VMASST_TYPE_writable_pagetables 2
  495. /* x86/PAE guests: support PDPTs above 4GB. */
  496. #define VMASST_TYPE_pae_extended_cr3 3
  497. /*
  498. * x86 guests: Sane behaviour for virtual iopl
  499. * - virtual iopl updated from do_iret() hypercalls.
  500. * - virtual iopl reported in bounce frames.
  501. * - guest kernels assumed to be level 0 for the purpose of iopl checks.
  502. */
  503. #define VMASST_TYPE_architectural_iopl 4
  504. /*
  505. * All guests: activate update indicator in vcpu_runstate_info
  506. * Enable setting the XEN_RUNSTATE_UPDATE flag in guest memory mapped
  507. * vcpu_runstate_info during updates of the runstate information.
  508. */
  509. #define VMASST_TYPE_runstate_update_flag 5
  510. /*
  511. * x86/64 guests: strictly hide M2P from user mode.
  512. * This allows the guest to control respective hypervisor behavior:
  513. * - when not set, L4 tables get created with the respective slot blank,
  514. * and whenever the L4 table gets used as a kernel one the missing
  515. * mapping gets inserted,
  516. * - when set, L4 tables get created with the respective slot initialized
  517. * as before, and whenever the L4 table gets used as a user one the
  518. * mapping gets zapped.
  519. */
  520. #define VMASST_TYPE_m2p_strict 32
  521. #if __XEN_INTERFACE_VERSION__ < 0x00040600
  522. #define MAX_VMASST_TYPE 3
  523. #endif
  524. /* Domain ids >= DOMID_FIRST_RESERVED cannot be used for ordinary domains. */
  525. #define DOMID_FIRST_RESERVED xen_mk_uint(0x7FF0)
  526. /* DOMID_SELF is used in certain contexts to refer to oneself. */
  527. #define DOMID_SELF xen_mk_uint(0x7FF0)
  528. /*
  529. * DOMID_IO is used to restrict page-table updates to mapping I/O memory.
  530. * Although no Foreign Domain need be specified to map I/O pages, DOMID_IO
  531. * is useful to ensure that no mappings to the OS's own heap are accidentally
  532. * installed. (e.g., in Linux this could cause havoc as reference counts
  533. * aren't adjusted on the I/O-mapping code path).
  534. * This only makes sense as HYPERVISOR_mmu_update()'s and
  535. * HYPERVISOR_update_va_mapping_otherdomain()'s "foreigndom" argument. For
  536. * HYPERVISOR_mmu_update() context it can be specified by any calling domain,
  537. * otherwise it's only permitted if the caller is privileged.
  538. */
  539. #define DOMID_IO xen_mk_uint(0x7FF1)
  540. /*
  541. * DOMID_XEN is used to allow privileged domains to map restricted parts of
  542. * Xen's heap space (e.g., the machine_to_phys table).
  543. * This only makes sense as
  544. * - HYPERVISOR_mmu_update()'s, HYPERVISOR_mmuext_op()'s, or
  545. * HYPERVISOR_update_va_mapping_otherdomain()'s "foreigndom" argument,
  546. * - with XENMAPSPACE_gmfn_foreign,
  547. * and is only permitted if the caller is privileged.
  548. */
  549. #define DOMID_XEN xen_mk_uint(0x7FF2)
  550. /*
  551. * DOMID_COW is used as the owner of sharable pages */
  552. #define DOMID_COW xen_mk_uint(0x7FF3)
  553. /* DOMID_INVALID is used to identify pages with unknown owner. */
  554. #define DOMID_INVALID xen_mk_uint(0x7FF4)
  555. /* Idle domain. */
  556. #define DOMID_IDLE xen_mk_uint(0x7FFF)
  557. /* Mask for valid domain id values */
  558. #define DOMID_MASK xen_mk_uint(0x7FFF)
  559. #ifndef __ASSEMBLY__
  560. typedef uint16_t domid_t;
  561. /*
  562. * Send an array of these to HYPERVISOR_mmu_update().
  563. * NB. The fields are natural pointer/address size for this architecture.
  564. */
  565. struct mmu_update {
  566. uint64_t ptr; /* Machine address of PTE. */
  567. uint64_t val; /* New contents of PTE. */
  568. };
  569. typedef struct mmu_update mmu_update_t;
  570. DEFINE_XEN_GUEST_HANDLE(mmu_update_t);
  571. /*
  572. * ` enum neg_errnoval
  573. * ` HYPERVISOR_multicall(multicall_entry_t call_list[],
  574. * ` uint32_t nr_calls);
  575. *
  576. * NB. The fields are logically the natural register size for this
  577. * architecture. In cases where xen_ulong_t is larger than this then
  578. * any unused bits in the upper portion must be zero.
  579. */
  580. struct multicall_entry {
  581. xen_ulong_t op, result;
  582. xen_ulong_t args[6];
  583. };
  584. typedef struct multicall_entry multicall_entry_t;
  585. DEFINE_XEN_GUEST_HANDLE(multicall_entry_t);
  586. #if __XEN_INTERFACE_VERSION__ < 0x00040400
  587. /*
  588. * Event channel endpoints per domain (when using the 2-level ABI):
  589. * 1024 if a long is 32 bits; 4096 if a long is 64 bits.
  590. */
  591. #define NR_EVENT_CHANNELS EVTCHN_2L_NR_CHANNELS
  592. #endif
  593. struct vcpu_time_info {
  594. /*
  595. * Updates to the following values are preceded and followed by an
  596. * increment of 'version'. The guest can therefore detect updates by
  597. * looking for changes to 'version'. If the least-significant bit of
  598. * the version number is set then an update is in progress and the guest
  599. * must wait to read a consistent set of values.
  600. * The correct way to interact with the version number is similar to
  601. * Linux's seqlock: see the implementations of read_seqbegin/read_seqretry.
  602. */
  603. uint32_t version;
  604. uint32_t pad0;
  605. uint64_t tsc_timestamp; /* TSC at last update of time vals. */
  606. uint64_t system_time; /* Time, in nanosecs, since boot. */
  607. /*
  608. * Current system time:
  609. * system_time +
  610. * ((((tsc - tsc_timestamp) << tsc_shift) * tsc_to_system_mul) >> 32)
  611. * CPU frequency (Hz):
  612. * ((10^9 << 32) / tsc_to_system_mul) >> tsc_shift
  613. */
  614. uint32_t tsc_to_system_mul;
  615. int8_t tsc_shift;
  616. #if __XEN_INTERFACE_VERSION__ > 0x040600
  617. uint8_t flags;
  618. uint8_t pad1[2];
  619. #else
  620. int8_t pad1[3];
  621. #endif
  622. }; /* 32 bytes */
  623. typedef struct vcpu_time_info vcpu_time_info_t;
  624. #define XEN_PVCLOCK_TSC_STABLE_BIT (1 << 0)
  625. #define XEN_PVCLOCK_GUEST_STOPPED (1 << 1)
  626. struct vcpu_info {
  627. /*
  628. * 'evtchn_upcall_pending' is written non-zero by Xen to indicate
  629. * a pending notification for a particular VCPU. It is then cleared
  630. * by the guest OS /before/ checking for pending work, thus avoiding
  631. * a set-and-check race. Note that the mask is only accessed by Xen
  632. * on the CPU that is currently hosting the VCPU. This means that the
  633. * pending and mask flags can be updated by the guest without special
  634. * synchronisation (i.e., no need for the x86 LOCK prefix).
  635. * This may seem suboptimal because if the pending flag is set by
  636. * a different CPU then an IPI may be scheduled even when the mask
  637. * is set. However, note:
  638. * 1. The task of 'interrupt holdoff' is covered by the per-event-
  639. * channel mask bits. A 'noisy' event that is continually being
  640. * triggered can be masked at source at this very precise
  641. * granularity.
  642. * 2. The main purpose of the per-VCPU mask is therefore to restrict
  643. * reentrant execution: whether for concurrency control, or to
  644. * prevent unbounded stack usage. Whatever the purpose, we expect
  645. * that the mask will be asserted only for short periods at a time,
  646. * and so the likelihood of a 'spurious' IPI is suitably small.
  647. * The mask is read before making an event upcall to the guest: a
  648. * non-zero mask therefore guarantees that the VCPU will not receive
  649. * an upcall activation. The mask is cleared when the VCPU requests
  650. * to block: this avoids wakeup-waiting races.
  651. */
  652. uint8_t evtchn_upcall_pending;
  653. #ifdef XEN_HAVE_PV_UPCALL_MASK
  654. uint8_t evtchn_upcall_mask;
  655. #else /* XEN_HAVE_PV_UPCALL_MASK */
  656. uint8_t pad0;
  657. #endif /* XEN_HAVE_PV_UPCALL_MASK */
  658. xen_ulong_t evtchn_pending_sel;
  659. struct arch_vcpu_info arch;
  660. vcpu_time_info_t time;
  661. }; /* 64 bytes (x86) */
  662. #ifndef __XEN__
  663. typedef struct vcpu_info vcpu_info_t;
  664. #endif
  665. /*
  666. * `incontents 200 startofday_shared Start-of-day shared data structure
  667. * Xen/kernel shared data -- pointer provided in start_info.
  668. *
  669. * This structure is defined to be both smaller than a page, and the
  670. * only data on the shared page, but may vary in actual size even within
  671. * compatible Xen versions; guests should not rely on the size
  672. * of this structure remaining constant.
  673. */
  674. struct shared_info {
  675. struct vcpu_info vcpu_info[XEN_LEGACY_MAX_VCPUS];
  676. /*
  677. * A domain can create "event channels" on which it can send and receive
  678. * asynchronous event notifications. There are three classes of event that
  679. * are delivered by this mechanism:
  680. * 1. Bi-directional inter- and intra-domain connections. Domains must
  681. * arrange out-of-band to set up a connection (usually by allocating
  682. * an unbound 'listener' port and avertising that via a storage service
  683. * such as xenstore).
  684. * 2. Physical interrupts. A domain with suitable hardware-access
  685. * privileges can bind an event-channel port to a physical interrupt
  686. * source.
  687. * 3. Virtual interrupts ('events'). A domain can bind an event-channel
  688. * port to a virtual interrupt source, such as the virtual-timer
  689. * device or the emergency console.
  690. *
  691. * Event channels are addressed by a "port index". Each channel is
  692. * associated with two bits of information:
  693. * 1. PENDING -- notifies the domain that there is a pending notification
  694. * to be processed. This bit is cleared by the guest.
  695. * 2. MASK -- if this bit is clear then a 0->1 transition of PENDING
  696. * will cause an asynchronous upcall to be scheduled. This bit is only
  697. * updated by the guest. It is read-only within Xen. If a channel
  698. * becomes pending while the channel is masked then the 'edge' is lost
  699. * (i.e., when the channel is unmasked, the guest must manually handle
  700. * pending notifications as no upcall will be scheduled by Xen).
  701. *
  702. * To expedite scanning of pending notifications, any 0->1 pending
  703. * transition on an unmasked channel causes a corresponding bit in a
  704. * per-vcpu selector word to be set. Each bit in the selector covers a
  705. * 'C long' in the PENDING bitfield array.
  706. */
  707. xen_ulong_t evtchn_pending[sizeof(xen_ulong_t) * 8];
  708. xen_ulong_t evtchn_mask[sizeof(xen_ulong_t) * 8];
  709. /*
  710. * Wallclock time: updated by control software or RTC emulation.
  711. * Guests should base their gettimeofday() syscall on this
  712. * wallclock-base value.
  713. * The values of wc_sec and wc_nsec are offsets from the Unix epoch
  714. * adjusted by the domain's 'time offset' (in seconds) as set either
  715. * by XEN_DOMCTL_settimeoffset, or adjusted via a guest write to the
  716. * emulated RTC.
  717. */
  718. uint32_t wc_version; /* Version counter: see vcpu_time_info_t. */
  719. uint32_t wc_sec;
  720. uint32_t wc_nsec;
  721. #if !defined(__i386__)
  722. uint32_t wc_sec_hi;
  723. # define xen_wc_sec_hi wc_sec_hi
  724. #elif !defined(__XEN__) && !defined(__XEN_TOOLS__)
  725. # define xen_wc_sec_hi arch.wc_sec_hi
  726. #endif
  727. struct arch_shared_info arch;
  728. };
  729. #ifndef __XEN__
  730. typedef struct shared_info shared_info_t;
  731. #endif
  732. /*
  733. * `incontents 200 startofday Start-of-day memory layout
  734. *
  735. * 1. The domain is started within contiguous virtual-memory region.
  736. * 2. The contiguous region ends on an aligned 4MB boundary.
  737. * 3. This the order of bootstrap elements in the initial virtual region:
  738. * a. relocated kernel image
  739. * b. initial ram disk [mod_start, mod_len]
  740. * (may be omitted)
  741. * c. list of allocated page frames [mfn_list, nr_pages]
  742. * (unless relocated due to XEN_ELFNOTE_INIT_P2M)
  743. * d. start_info_t structure [register rSI (x86)]
  744. * in case of dom0 this page contains the console info, too
  745. * e. unless dom0: xenstore ring page
  746. * f. unless dom0: console ring page
  747. * g. bootstrap page tables [pt_base and CR3 (x86)]
  748. * h. bootstrap stack [register ESP (x86)]
  749. * 4. Bootstrap elements are packed together, but each is 4kB-aligned.
  750. * 5. The list of page frames forms a contiguous 'pseudo-physical' memory
  751. * layout for the domain. In particular, the bootstrap virtual-memory
  752. * region is a 1:1 mapping to the first section of the pseudo-physical map.
  753. * 6. All bootstrap elements are mapped read-writable for the guest OS. The
  754. * only exception is the bootstrap page table, which is mapped read-only.
  755. * 7. There is guaranteed to be at least 512kB padding after the final
  756. * bootstrap element. If necessary, the bootstrap virtual region is
  757. * extended by an extra 4MB to ensure this.
  758. *
  759. * Note: Prior to 25833:bb85bbccb1c9. ("x86/32-on-64 adjust Dom0 initial page
  760. * table layout") a bug caused the pt_base (3.g above) and cr3 to not point
  761. * to the start of the guest page tables (it was offset by two pages).
  762. * This only manifested itself on 32-on-64 dom0 kernels and not 32-on-64 domU
  763. * or 64-bit kernels of any colour. The page tables for a 32-on-64 dom0 got
  764. * allocated in the order: 'first L1','first L2', 'first L3', so the offset
  765. * to the page table base is by two pages back. The initial domain if it is
  766. * 32-bit and runs under a 64-bit hypervisor should _NOT_ use two of the
  767. * pages preceding pt_base and mark them as reserved/unused.
  768. */
  769. #ifdef XEN_HAVE_PV_GUEST_ENTRY
  770. struct start_info {
  771. /* THE FOLLOWING ARE FILLED IN BOTH ON INITIAL BOOT AND ON RESUME. */
  772. char magic[32]; /* "xen-<version>-<platform>". */
  773. unsigned long nr_pages; /* Total pages allocated to this domain. */
  774. unsigned long shared_info; /* MACHINE address of shared info struct. */
  775. uint32_t flags; /* SIF_xxx flags. */
  776. xen_pfn_t store_mfn; /* MACHINE page number of shared page. */
  777. uint32_t store_evtchn; /* Event channel for store communication. */
  778. union {
  779. struct {
  780. xen_pfn_t mfn; /* MACHINE page number of console page. */
  781. uint32_t evtchn; /* Event channel for console page. */
  782. } domU;
  783. struct {
  784. uint32_t info_off; /* Offset of console_info struct. */
  785. uint32_t info_size; /* Size of console_info struct from start.*/
  786. } dom0;
  787. } console;
  788. /* THE FOLLOWING ARE ONLY FILLED IN ON INITIAL BOOT (NOT RESUME). */
  789. unsigned long pt_base; /* VIRTUAL address of page directory. */
  790. unsigned long nr_pt_frames; /* Number of bootstrap p.t. frames. */
  791. unsigned long mfn_list; /* VIRTUAL address of page-frame list. */
  792. unsigned long mod_start; /* VIRTUAL address of pre-loaded module */
  793. /* (PFN of pre-loaded module if */
  794. /* SIF_MOD_START_PFN set in flags). */
  795. unsigned long mod_len; /* Size (bytes) of pre-loaded module. */
  796. #define MAX_GUEST_CMDLINE 1024
  797. int8_t cmd_line[MAX_GUEST_CMDLINE];
  798. /* The pfn range here covers both page table and p->m table frames. */
  799. unsigned long first_p2m_pfn;/* 1st pfn forming initial P->M table. */
  800. unsigned long nr_p2m_frames;/* # of pfns forming initial P->M table. */
  801. };
  802. typedef struct start_info start_info_t;
  803. /* New console union for dom0 introduced in 0x00030203. */
  804. #if __XEN_INTERFACE_VERSION__ < 0x00030203
  805. #define console_mfn console.domU.mfn
  806. #define console_evtchn console.domU.evtchn
  807. #endif
  808. #endif /* XEN_HAVE_PV_GUEST_ENTRY */
  809. /* These flags are passed in the 'flags' field of start_info_t. */
  810. #define SIF_PRIVILEGED (1<<0) /* Is the domain privileged? */
  811. #define SIF_INITDOMAIN (1<<1) /* Is this the initial control domain? */
  812. #define SIF_MULTIBOOT_MOD (1<<2) /* Is mod_start a multiboot module? */
  813. #define SIF_MOD_START_PFN (1<<3) /* Is mod_start a PFN? */
  814. #define SIF_VIRT_P2M_4TOOLS (1<<4) /* Do Xen tools understand a virt. mapped */
  815. /* P->M making the 3 level tree obsolete? */
  816. #define SIF_PM_MASK (0xFF<<8) /* reserve 1 byte for xen-pm options */
  817. /*
  818. * A multiboot module is a package containing modules very similar to a
  819. * multiboot module array. The only differences are:
  820. * - the array of module descriptors is by convention simply at the beginning
  821. * of the multiboot module,
  822. * - addresses in the module descriptors are based on the beginning of the
  823. * multiboot module,
  824. * - the number of modules is determined by a termination descriptor that has
  825. * mod_start == 0.
  826. *
  827. * This permits to both build it statically and reference it in a configuration
  828. * file, and let the PV guest easily rebase the addresses to virtual addresses
  829. * and at the same time count the number of modules.
  830. */
  831. struct xen_multiboot_mod_list
  832. {
  833. /* Address of first byte of the module */
  834. uint32_t mod_start;
  835. /* Address of last byte of the module (inclusive) */
  836. uint32_t mod_end;
  837. /* Address of zero-terminated command line */
  838. uint32_t cmdline;
  839. /* Unused, must be zero */
  840. uint32_t pad;
  841. };
  842. /*
  843. * `incontents 200 startofday_dom0_console Dom0_console
  844. *
  845. * The console structure in start_info.console.dom0
  846. *
  847. * This structure includes a variety of information required to
  848. * have a working VGA/VESA console.
  849. */
  850. typedef struct dom0_vga_console_info {
  851. uint8_t video_type; /* DOM0_VGA_CONSOLE_??? */
  852. #define XEN_VGATYPE_TEXT_MODE_3 0x03
  853. #define XEN_VGATYPE_VESA_LFB 0x23
  854. #define XEN_VGATYPE_EFI_LFB 0x70
  855. union {
  856. struct {
  857. /* Font height, in pixels. */
  858. uint16_t font_height;
  859. /* Cursor location (column, row). */
  860. uint16_t cursor_x, cursor_y;
  861. /* Number of rows and columns (dimensions in characters). */
  862. uint16_t rows, columns;
  863. } text_mode_3;
  864. struct {
  865. /* Width and height, in pixels. */
  866. uint16_t width, height;
  867. /* Bytes per scan line. */
  868. uint16_t bytes_per_line;
  869. /* Bits per pixel. */
  870. uint16_t bits_per_pixel;
  871. /* LFB physical address, and size (in units of 64kB). */
  872. uint32_t lfb_base;
  873. uint32_t lfb_size;
  874. /* RGB mask offsets and sizes, as defined by VBE 1.2+ */
  875. uint8_t red_pos, red_size;
  876. uint8_t green_pos, green_size;
  877. uint8_t blue_pos, blue_size;
  878. uint8_t rsvd_pos, rsvd_size;
  879. #if __XEN_INTERFACE_VERSION__ >= 0x00030206
  880. /* VESA capabilities (offset 0xa, VESA command 0x4f00). */
  881. uint32_t gbl_caps;
  882. /* Mode attributes (offset 0x0, VESA command 0x4f01). */
  883. uint16_t mode_attrs;
  884. uint16_t pad;
  885. #endif
  886. #if __XEN_INTERFACE_VERSION__ >= 0x00040d00
  887. /* high 32 bits of lfb_base */
  888. uint32_t ext_lfb_base;
  889. #endif
  890. } vesa_lfb;
  891. } u;
  892. } dom0_vga_console_info_t;
  893. #define xen_vga_console_info dom0_vga_console_info
  894. #define xen_vga_console_info_t dom0_vga_console_info_t
  895. typedef uint8_t xen_domain_handle_t[16];
  896. __DEFINE_XEN_GUEST_HANDLE(uint8, uint8_t);
  897. __DEFINE_XEN_GUEST_HANDLE(uint16, uint16_t);
  898. __DEFINE_XEN_GUEST_HANDLE(uint32, uint32_t);
  899. __DEFINE_XEN_GUEST_HANDLE(uint64, uint64_t);
  900. typedef struct {
  901. uint8_t a[16];
  902. } xen_uuid_t;
  903. /*
  904. * XEN_DEFINE_UUID(0x00112233, 0x4455, 0x6677, 0x8899,
  905. * 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff)
  906. * will construct UUID 00112233-4455-6677-8899-aabbccddeeff presented as
  907. * {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88,
  908. * 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff};
  909. *
  910. * NB: This is compatible with Linux kernel and with libuuid, but it is not
  911. * compatible with Microsoft, as they use mixed-endian encoding (some
  912. * components are little-endian, some are big-endian).
  913. */
  914. #define XEN_DEFINE_UUID_(a, b, c, d, e1, e2, e3, e4, e5, e6) \
  915. {{((a) >> 24) & 0xFF, ((a) >> 16) & 0xFF, \
  916. ((a) >> 8) & 0xFF, ((a) >> 0) & 0xFF, \
  917. ((b) >> 8) & 0xFF, ((b) >> 0) & 0xFF, \
  918. ((c) >> 8) & 0xFF, ((c) >> 0) & 0xFF, \
  919. ((d) >> 8) & 0xFF, ((d) >> 0) & 0xFF, \
  920. e1, e2, e3, e4, e5, e6}}
  921. #if defined(__STDC_VERSION__) ? __STDC_VERSION__ >= 199901L : defined(__GNUC__)
  922. #define XEN_DEFINE_UUID(a, b, c, d, e1, e2, e3, e4, e5, e6) \
  923. ((xen_uuid_t)XEN_DEFINE_UUID_(a, b, c, d, e1, e2, e3, e4, e5, e6))
  924. #else
  925. #define XEN_DEFINE_UUID(a, b, c, d, e1, e2, e3, e4, e5, e6) \
  926. XEN_DEFINE_UUID_(a, b, c, d, e1, e2, e3, e4, e5, e6)
  927. #endif /* __STDC_VERSION__ / __GNUC__ */
  928. #endif /* !__ASSEMBLY__ */
  929. /* Default definitions for macros used by domctl/sysctl. */
  930. #if defined(__XEN__) || defined(__XEN_TOOLS__)
  931. #ifndef int64_aligned_t
  932. #define int64_aligned_t int64_t
  933. #endif
  934. #ifndef uint64_aligned_t
  935. #define uint64_aligned_t uint64_t
  936. #endif
  937. #ifndef XEN_GUEST_HANDLE_64
  938. #define XEN_GUEST_HANDLE_64(name) XEN_GUEST_HANDLE(name)
  939. #endif
  940. #ifndef __ASSEMBLY__
  941. struct xenctl_bitmap {
  942. XEN_GUEST_HANDLE_64(uint8) bitmap;
  943. uint32_t nr_bits;
  944. };
  945. typedef struct xenctl_bitmap xenctl_bitmap_t;
  946. #endif
  947. #endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */
  948. #endif /* __XEN_PUBLIC_XEN_H__ */
  949. /*
  950. * Local variables:
  951. * mode: C
  952. * c-file-style: "BSD"
  953. * c-basic-offset: 4
  954. * tab-width: 4
  955. * indent-tabs-mode: nil
  956. * End:
  957. */