memory.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736
  1. /******************************************************************************
  2. * memory.h
  3. *
  4. * Memory reservation and information.
  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 (c) 2005, Keir Fraser <keir@xensource.com>
  25. */
  26. #ifndef __XEN_PUBLIC_MEMORY_H__
  27. #define __XEN_PUBLIC_MEMORY_H__
  28. #include "xen.h"
  29. #include "physdev.h"
  30. /*
  31. * Increase or decrease the specified domain's memory reservation. Returns the
  32. * number of extents successfully allocated or freed.
  33. * arg == addr of struct xen_memory_reservation.
  34. */
  35. #define XENMEM_increase_reservation 0
  36. #define XENMEM_decrease_reservation 1
  37. #define XENMEM_populate_physmap 6
  38. #if __XEN_INTERFACE_VERSION__ >= 0x00030209
  39. /*
  40. * Maximum # bits addressable by the user of the allocated region (e.g., I/O
  41. * devices often have a 32-bit limitation even in 64-bit systems). If zero
  42. * then the user has no addressing restriction. This field is not used by
  43. * XENMEM_decrease_reservation.
  44. */
  45. #define XENMEMF_address_bits(x) (x)
  46. #define XENMEMF_get_address_bits(x) ((x) & 0xffu)
  47. /* NUMA node to allocate from. */
  48. #define XENMEMF_node(x) (((x) + 1) << 8)
  49. #define XENMEMF_get_node(x) ((((x) >> 8) - 1) & 0xffu)
  50. /* Flag to populate physmap with populate-on-demand entries */
  51. #define XENMEMF_populate_on_demand (1<<16)
  52. /* Flag to request allocation only from the node specified */
  53. #define XENMEMF_exact_node_request (1<<17)
  54. #define XENMEMF_exact_node(n) (XENMEMF_node(n) | XENMEMF_exact_node_request)
  55. /* Flag to indicate the node specified is virtual node */
  56. #define XENMEMF_vnode (1<<18)
  57. #endif
  58. struct xen_memory_reservation {
  59. /*
  60. * XENMEM_increase_reservation:
  61. * OUT: MFN (*not* GMFN) bases of extents that were allocated
  62. * XENMEM_decrease_reservation:
  63. * IN: GMFN bases of extents to free
  64. * XENMEM_populate_physmap:
  65. * IN: GPFN bases of extents to populate with memory
  66. * OUT: GMFN bases of extents that were allocated
  67. * (NB. This command also updates the mach_to_phys translation table)
  68. * XENMEM_claim_pages:
  69. * IN: must be zero
  70. */
  71. XEN_GUEST_HANDLE(xen_pfn_t) extent_start;
  72. /* Number of extents, and size/alignment of each (2^extent_order pages). */
  73. xen_ulong_t nr_extents;
  74. unsigned int extent_order;
  75. #if __XEN_INTERFACE_VERSION__ >= 0x00030209
  76. /* XENMEMF flags. */
  77. unsigned int mem_flags;
  78. #else
  79. unsigned int address_bits;
  80. #endif
  81. /*
  82. * Domain whose reservation is being changed.
  83. * Unprivileged domains can specify only DOMID_SELF.
  84. */
  85. domid_t domid;
  86. };
  87. typedef struct xen_memory_reservation xen_memory_reservation_t;
  88. DEFINE_XEN_GUEST_HANDLE(xen_memory_reservation_t);
  89. /*
  90. * An atomic exchange of memory pages. If return code is zero then
  91. * @out.extent_list provides GMFNs of the newly-allocated memory.
  92. * Returns zero on complete success, otherwise a negative error code.
  93. * On complete success then always @nr_exchanged == @in.nr_extents.
  94. * On partial success @nr_exchanged indicates how much work was done.
  95. *
  96. * Note that only PV guests can use this operation.
  97. */
  98. #define XENMEM_exchange 11
  99. struct xen_memory_exchange {
  100. /*
  101. * [IN] Details of memory extents to be exchanged (GMFN bases).
  102. * Note that @in.address_bits is ignored and unused.
  103. */
  104. struct xen_memory_reservation in;
  105. /*
  106. * [IN/OUT] Details of new memory extents.
  107. * We require that:
  108. * 1. @in.domid == @out.domid
  109. * 2. @in.nr_extents << @in.extent_order ==
  110. * @out.nr_extents << @out.extent_order
  111. * 3. @in.extent_start and @out.extent_start lists must not overlap
  112. * 4. @out.extent_start lists GPFN bases to be populated
  113. * 5. @out.extent_start is overwritten with allocated GMFN bases
  114. */
  115. struct xen_memory_reservation out;
  116. /*
  117. * [OUT] Number of input extents that were successfully exchanged:
  118. * 1. The first @nr_exchanged input extents were successfully
  119. * deallocated.
  120. * 2. The corresponding first entries in the output extent list correctly
  121. * indicate the GMFNs that were successfully exchanged.
  122. * 3. All other input and output extents are untouched.
  123. * 4. If not all input exents are exchanged then the return code of this
  124. * command will be non-zero.
  125. * 5. THIS FIELD MUST BE INITIALISED TO ZERO BY THE CALLER!
  126. */
  127. xen_ulong_t nr_exchanged;
  128. };
  129. typedef struct xen_memory_exchange xen_memory_exchange_t;
  130. DEFINE_XEN_GUEST_HANDLE(xen_memory_exchange_t);
  131. /*
  132. * Returns the maximum machine frame number of mapped RAM in this system.
  133. * This command always succeeds (it never returns an error code).
  134. * arg == NULL.
  135. */
  136. #define XENMEM_maximum_ram_page 2
  137. /*
  138. * Returns the current or maximum memory reservation, in pages, of the
  139. * specified domain (may be DOMID_SELF). Returns -ve errcode on failure.
  140. * arg == addr of domid_t.
  141. */
  142. #define XENMEM_current_reservation 3
  143. #define XENMEM_maximum_reservation 4
  144. /*
  145. * Returns the maximum GPFN in use by the guest, or -ve errcode on failure.
  146. */
  147. #define XENMEM_maximum_gpfn 14
  148. /*
  149. * Returns a list of MFN bases of 2MB extents comprising the machine_to_phys
  150. * mapping table. Architectures which do not have a m2p table do not implement
  151. * this command.
  152. * arg == addr of xen_machphys_mfn_list_t.
  153. */
  154. #define XENMEM_machphys_mfn_list 5
  155. struct xen_machphys_mfn_list {
  156. /*
  157. * Size of the 'extent_start' array. Fewer entries will be filled if the
  158. * machphys table is smaller than max_extents * 2MB.
  159. */
  160. unsigned int max_extents;
  161. /*
  162. * Pointer to buffer to fill with list of extent starts. If there are
  163. * any large discontiguities in the machine address space, 2MB gaps in
  164. * the machphys table will be represented by an MFN base of zero.
  165. */
  166. XEN_GUEST_HANDLE(xen_pfn_t) extent_start;
  167. /*
  168. * Number of extents written to the above array. This will be smaller
  169. * than 'max_extents' if the machphys table is smaller than max_e * 2MB.
  170. */
  171. unsigned int nr_extents;
  172. };
  173. typedef struct xen_machphys_mfn_list xen_machphys_mfn_list_t;
  174. DEFINE_XEN_GUEST_HANDLE(xen_machphys_mfn_list_t);
  175. /*
  176. * For a compat caller, this is identical to XENMEM_machphys_mfn_list.
  177. *
  178. * For a non compat caller, this functions similarly to
  179. * XENMEM_machphys_mfn_list, but returns the mfns making up the compatibility
  180. * m2p table.
  181. */
  182. #define XENMEM_machphys_compat_mfn_list 25
  183. /*
  184. * Returns the location in virtual address space of the machine_to_phys
  185. * mapping table. Architectures which do not have a m2p table, or which do not
  186. * map it by default into guest address space, do not implement this command.
  187. * arg == addr of xen_machphys_mapping_t.
  188. */
  189. #define XENMEM_machphys_mapping 12
  190. struct xen_machphys_mapping {
  191. xen_ulong_t v_start, v_end; /* Start and end virtual addresses. */
  192. xen_ulong_t max_mfn; /* Maximum MFN that can be looked up. */
  193. };
  194. typedef struct xen_machphys_mapping xen_machphys_mapping_t;
  195. DEFINE_XEN_GUEST_HANDLE(xen_machphys_mapping_t);
  196. /* Source mapping space. */
  197. /* ` enum phys_map_space { */
  198. #define XENMAPSPACE_shared_info 0 /* shared info page */
  199. #define XENMAPSPACE_grant_table 1 /* grant table page */
  200. #define XENMAPSPACE_gmfn 2 /* GMFN */
  201. #define XENMAPSPACE_gmfn_range 3 /* GMFN range, XENMEM_add_to_physmap only. */
  202. #define XENMAPSPACE_gmfn_foreign 4 /* GMFN from another dom,
  203. * XENMEM_add_to_physmap_batch only. */
  204. #define XENMAPSPACE_dev_mmio 5 /* device mmio region
  205. ARM only; the region is mapped in
  206. Stage-2 using the Normal Memory
  207. Inner/Outer Write-Back Cacheable
  208. memory attribute. */
  209. /* ` } */
  210. /*
  211. * Sets the GPFN at which a particular page appears in the specified guest's
  212. * physical address space (translated guests only).
  213. * arg == addr of xen_add_to_physmap_t.
  214. */
  215. #define XENMEM_add_to_physmap 7
  216. struct xen_add_to_physmap {
  217. /* Which domain to change the mapping for. */
  218. domid_t domid;
  219. /* Number of pages to go through for gmfn_range */
  220. uint16_t size;
  221. unsigned int space; /* => enum phys_map_space */
  222. #define XENMAPIDX_grant_table_status 0x80000000
  223. /* Index into space being mapped. */
  224. xen_ulong_t idx;
  225. /* GPFN in domid where the source mapping page should appear. */
  226. xen_pfn_t gpfn;
  227. };
  228. typedef struct xen_add_to_physmap xen_add_to_physmap_t;
  229. DEFINE_XEN_GUEST_HANDLE(xen_add_to_physmap_t);
  230. /* A batched version of add_to_physmap. */
  231. #define XENMEM_add_to_physmap_batch 23
  232. struct xen_add_to_physmap_batch {
  233. /* IN */
  234. /* Which domain to change the mapping for. */
  235. domid_t domid;
  236. uint16_t space; /* => enum phys_map_space */
  237. /* Number of pages to go through */
  238. uint16_t size;
  239. #if __XEN_INTERFACE_VERSION__ < 0x00040700
  240. domid_t foreign_domid; /* IFF gmfn_foreign. Should be 0 for other spaces. */
  241. #else
  242. union xen_add_to_physmap_batch_extra {
  243. domid_t foreign_domid; /* gmfn_foreign */
  244. uint16_t res0; /* All the other spaces. Should be 0 */
  245. } u;
  246. #endif
  247. /* Indexes into space being mapped. */
  248. XEN_GUEST_HANDLE(xen_ulong_t) idxs;
  249. /* GPFN in domid where the source mapping page should appear. */
  250. XEN_GUEST_HANDLE(xen_pfn_t) gpfns;
  251. /* OUT */
  252. /* Per index error code. */
  253. XEN_GUEST_HANDLE(int) errs;
  254. };
  255. typedef struct xen_add_to_physmap_batch xen_add_to_physmap_batch_t;
  256. DEFINE_XEN_GUEST_HANDLE(xen_add_to_physmap_batch_t);
  257. #if __XEN_INTERFACE_VERSION__ < 0x00040400
  258. #define XENMEM_add_to_physmap_range XENMEM_add_to_physmap_batch
  259. #define xen_add_to_physmap_range xen_add_to_physmap_batch
  260. typedef struct xen_add_to_physmap_batch xen_add_to_physmap_range_t;
  261. DEFINE_XEN_GUEST_HANDLE(xen_add_to_physmap_range_t);
  262. #endif
  263. /*
  264. * Unmaps the page appearing at a particular GPFN from the specified guest's
  265. * physical address space (translated guests only).
  266. * arg == addr of xen_remove_from_physmap_t.
  267. */
  268. #define XENMEM_remove_from_physmap 15
  269. struct xen_remove_from_physmap {
  270. /* Which domain to change the mapping for. */
  271. domid_t domid;
  272. /* GPFN of the current mapping of the page. */
  273. xen_pfn_t gpfn;
  274. };
  275. typedef struct xen_remove_from_physmap xen_remove_from_physmap_t;
  276. DEFINE_XEN_GUEST_HANDLE(xen_remove_from_physmap_t);
  277. /*** REMOVED ***/
  278. /*#define XENMEM_translate_gpfn_list 8*/
  279. /*
  280. * Returns the pseudo-physical memory map as it was when the domain
  281. * was started (specified by XENMEM_set_memory_map).
  282. * arg == addr of xen_memory_map_t.
  283. */
  284. #define XENMEM_memory_map 9
  285. struct xen_memory_map {
  286. /*
  287. * On call the number of entries which can be stored in buffer. On
  288. * return the number of entries which have been stored in
  289. * buffer.
  290. */
  291. unsigned int nr_entries;
  292. /*
  293. * Entries in the buffer are in the same format as returned by the
  294. * BIOS INT 0x15 EAX=0xE820 call.
  295. */
  296. XEN_GUEST_HANDLE(void) buffer;
  297. };
  298. typedef struct xen_memory_map xen_memory_map_t;
  299. DEFINE_XEN_GUEST_HANDLE(xen_memory_map_t);
  300. /*
  301. * Returns the real physical memory map. Passes the same structure as
  302. * XENMEM_memory_map.
  303. * Specifying buffer as NULL will return the number of entries required
  304. * to store the complete memory map.
  305. * arg == addr of xen_memory_map_t.
  306. */
  307. #define XENMEM_machine_memory_map 10
  308. /*
  309. * Set the pseudo-physical memory map of a domain, as returned by
  310. * XENMEM_memory_map.
  311. * arg == addr of xen_foreign_memory_map_t.
  312. */
  313. #define XENMEM_set_memory_map 13
  314. struct xen_foreign_memory_map {
  315. domid_t domid;
  316. struct xen_memory_map map;
  317. };
  318. typedef struct xen_foreign_memory_map xen_foreign_memory_map_t;
  319. DEFINE_XEN_GUEST_HANDLE(xen_foreign_memory_map_t);
  320. #define XENMEM_set_pod_target 16
  321. #define XENMEM_get_pod_target 17
  322. struct xen_pod_target {
  323. /* IN */
  324. uint64_t target_pages;
  325. /* OUT */
  326. uint64_t tot_pages;
  327. uint64_t pod_cache_pages;
  328. uint64_t pod_entries;
  329. /* IN */
  330. domid_t domid;
  331. };
  332. typedef struct xen_pod_target xen_pod_target_t;
  333. #if defined(__XEN__) || defined(__XEN_TOOLS__)
  334. #ifndef uint64_aligned_t
  335. #define uint64_aligned_t uint64_t
  336. #endif
  337. /*
  338. * Get the number of MFNs saved through memory sharing.
  339. * The call never fails.
  340. */
  341. #define XENMEM_get_sharing_freed_pages 18
  342. #define XENMEM_get_sharing_shared_pages 19
  343. #define XENMEM_paging_op 20
  344. #define XENMEM_paging_op_nominate 0
  345. #define XENMEM_paging_op_evict 1
  346. #define XENMEM_paging_op_prep 2
  347. struct xen_mem_paging_op {
  348. uint8_t op; /* XENMEM_paging_op_* */
  349. domid_t domain;
  350. /* IN: (XENMEM_paging_op_prep) buffer to immediately fill page from */
  351. XEN_GUEST_HANDLE_64(const_uint8) buffer;
  352. /* IN: gfn of page being operated on */
  353. uint64_aligned_t gfn;
  354. };
  355. typedef struct xen_mem_paging_op xen_mem_paging_op_t;
  356. DEFINE_XEN_GUEST_HANDLE(xen_mem_paging_op_t);
  357. #define XENMEM_access_op 21
  358. #define XENMEM_access_op_set_access 0
  359. #define XENMEM_access_op_get_access 1
  360. /*
  361. * XENMEM_access_op_enable_emulate and XENMEM_access_op_disable_emulate are
  362. * currently unused, but since they have been in use please do not reuse them.
  363. *
  364. * #define XENMEM_access_op_enable_emulate 2
  365. * #define XENMEM_access_op_disable_emulate 3
  366. */
  367. #define XENMEM_access_op_set_access_multi 4
  368. typedef enum {
  369. XENMEM_access_n,
  370. XENMEM_access_r,
  371. XENMEM_access_w,
  372. XENMEM_access_rw,
  373. XENMEM_access_x,
  374. XENMEM_access_rx,
  375. XENMEM_access_wx,
  376. XENMEM_access_rwx,
  377. /*
  378. * Page starts off as r-x, but automatically
  379. * change to r-w on a write
  380. */
  381. XENMEM_access_rx2rw,
  382. /*
  383. * Log access: starts off as n, automatically
  384. * goes to rwx, generating an event without
  385. * pausing the vcpu
  386. */
  387. XENMEM_access_n2rwx,
  388. /* Take the domain default */
  389. XENMEM_access_default
  390. } xenmem_access_t;
  391. struct xen_mem_access_op {
  392. /* XENMEM_access_op_* */
  393. uint8_t op;
  394. /* xenmem_access_t */
  395. uint8_t access;
  396. domid_t domid;
  397. /*
  398. * Number of pages for set op (or size of pfn_list for
  399. * XENMEM_access_op_set_access_multi)
  400. * Ignored on setting default access and other ops
  401. */
  402. uint32_t nr;
  403. /*
  404. * First pfn for set op
  405. * pfn for get op
  406. * ~0ull is used to set and get the default access for pages
  407. */
  408. uint64_aligned_t pfn;
  409. /*
  410. * List of pfns to set access for
  411. * Used only with XENMEM_access_op_set_access_multi
  412. */
  413. XEN_GUEST_HANDLE(const_uint64) pfn_list;
  414. /*
  415. * Corresponding list of access settings for pfn_list
  416. * Used only with XENMEM_access_op_set_access_multi
  417. */
  418. XEN_GUEST_HANDLE(const_uint8) access_list;
  419. };
  420. typedef struct xen_mem_access_op xen_mem_access_op_t;
  421. DEFINE_XEN_GUEST_HANDLE(xen_mem_access_op_t);
  422. #define XENMEM_sharing_op 22
  423. #define XENMEM_sharing_op_nominate_gfn 0
  424. #define XENMEM_sharing_op_nominate_gref 1
  425. #define XENMEM_sharing_op_share 2
  426. #define XENMEM_sharing_op_debug_gfn 3
  427. #define XENMEM_sharing_op_debug_mfn 4
  428. #define XENMEM_sharing_op_debug_gref 5
  429. #define XENMEM_sharing_op_add_physmap 6
  430. #define XENMEM_sharing_op_audit 7
  431. #define XENMEM_sharing_op_range_share 8
  432. #define XENMEM_sharing_op_fork 9
  433. #define XENMEM_sharing_op_fork_reset 10
  434. #define XENMEM_SHARING_OP_S_HANDLE_INVALID (-10)
  435. #define XENMEM_SHARING_OP_C_HANDLE_INVALID (-9)
  436. /* The following allows sharing of grant refs. This is useful
  437. * for sharing utilities sitting as "filters" in IO backends
  438. * (e.g. memshr + blktap(2)). The IO backend is only exposed
  439. * to grant references, and this allows sharing of the grefs */
  440. #define XENMEM_SHARING_OP_FIELD_IS_GREF_FLAG (xen_mk_ullong(1) << 62)
  441. #define XENMEM_SHARING_OP_FIELD_MAKE_GREF(field, val) \
  442. (field) = (XENMEM_SHARING_OP_FIELD_IS_GREF_FLAG | val)
  443. #define XENMEM_SHARING_OP_FIELD_IS_GREF(field) \
  444. ((field) & XENMEM_SHARING_OP_FIELD_IS_GREF_FLAG)
  445. #define XENMEM_SHARING_OP_FIELD_GET_GREF(field) \
  446. ((field) & (~XENMEM_SHARING_OP_FIELD_IS_GREF_FLAG))
  447. struct xen_mem_sharing_op {
  448. uint8_t op; /* XENMEM_sharing_op_* */
  449. domid_t domain;
  450. union {
  451. struct mem_sharing_op_nominate { /* OP_NOMINATE_xxx */
  452. union {
  453. uint64_aligned_t gfn; /* IN: gfn to nominate */
  454. uint32_t grant_ref; /* IN: grant ref to nominate */
  455. } u;
  456. uint64_aligned_t handle; /* OUT: the handle */
  457. } nominate;
  458. struct mem_sharing_op_share { /* OP_SHARE/ADD_PHYSMAP */
  459. uint64_aligned_t source_gfn; /* IN: the gfn of the source page */
  460. uint64_aligned_t source_handle; /* IN: handle to the source page */
  461. uint64_aligned_t client_gfn; /* IN: the client gfn */
  462. uint64_aligned_t client_handle; /* IN: handle to the client page */
  463. domid_t client_domain; /* IN: the client domain id */
  464. } share;
  465. struct mem_sharing_op_range { /* OP_RANGE_SHARE */
  466. uint64_aligned_t first_gfn; /* IN: the first gfn */
  467. uint64_aligned_t last_gfn; /* IN: the last gfn */
  468. uint64_aligned_t opaque; /* Must be set to 0 */
  469. domid_t client_domain; /* IN: the client domain id */
  470. uint16_t _pad[3]; /* Must be set to 0 */
  471. } range;
  472. struct mem_sharing_op_debug { /* OP_DEBUG_xxx */
  473. union {
  474. uint64_aligned_t gfn; /* IN: gfn to debug */
  475. uint64_aligned_t mfn; /* IN: mfn to debug */
  476. uint32_t gref; /* IN: gref to debug */
  477. } u;
  478. } debug;
  479. struct mem_sharing_op_fork { /* OP_FORK */
  480. domid_t parent_domain; /* IN: parent's domain id */
  481. /* Only makes sense for short-lived forks */
  482. #define XENMEM_FORK_WITH_IOMMU_ALLOWED (1u << 0)
  483. /* Only makes sense for short-lived forks */
  484. #define XENMEM_FORK_BLOCK_INTERRUPTS (1u << 1)
  485. uint16_t flags; /* IN: optional settings */
  486. uint32_t pad; /* Must be set to 0 */
  487. } fork;
  488. } u;
  489. };
  490. typedef struct xen_mem_sharing_op xen_mem_sharing_op_t;
  491. DEFINE_XEN_GUEST_HANDLE(xen_mem_sharing_op_t);
  492. /*
  493. * Attempt to stake a claim for a domain on a quantity of pages
  494. * of system RAM, but _not_ assign specific pageframes. Only
  495. * arithmetic is performed so the hypercall is very fast and need
  496. * not be preemptible, thus sidestepping time-of-check-time-of-use
  497. * races for memory allocation. Returns 0 if the hypervisor page
  498. * allocator has atomically and successfully claimed the requested
  499. * number of pages, else non-zero.
  500. *
  501. * Any domain may have only one active claim. When sufficient memory
  502. * has been allocated to resolve the claim, the claim silently expires.
  503. * Claiming zero pages effectively resets any outstanding claim and
  504. * is always successful.
  505. *
  506. * Note that a valid claim may be staked even after memory has been
  507. * allocated for a domain. In this case, the claim is not incremental,
  508. * i.e. if the domain's total page count is 3, and a claim is staked
  509. * for 10, only 7 additional pages are claimed.
  510. *
  511. * Caller must be privileged or the hypercall fails.
  512. */
  513. #define XENMEM_claim_pages 24
  514. /*
  515. * XENMEM_claim_pages flags - the are no flags at this time.
  516. * The zero value is appropriate.
  517. */
  518. /*
  519. * With some legacy devices, certain guest-physical addresses cannot safely
  520. * be used for other purposes, e.g. to map guest RAM. This hypercall
  521. * enumerates those regions so the toolstack can avoid using them.
  522. */
  523. #define XENMEM_reserved_device_memory_map 27
  524. struct xen_reserved_device_memory {
  525. xen_pfn_t start_pfn;
  526. xen_ulong_t nr_pages;
  527. };
  528. typedef struct xen_reserved_device_memory xen_reserved_device_memory_t;
  529. DEFINE_XEN_GUEST_HANDLE(xen_reserved_device_memory_t);
  530. struct xen_reserved_device_memory_map {
  531. #define XENMEM_RDM_ALL 1 /* Request all regions (ignore dev union). */
  532. /* IN */
  533. uint32_t flags;
  534. /*
  535. * IN/OUT
  536. *
  537. * Gets set to the required number of entries when too low,
  538. * signaled by error code -ERANGE.
  539. */
  540. unsigned int nr_entries;
  541. /* OUT */
  542. XEN_GUEST_HANDLE(xen_reserved_device_memory_t) buffer;
  543. /* IN */
  544. union {
  545. struct physdev_pci_device pci;
  546. } dev;
  547. };
  548. typedef struct xen_reserved_device_memory_map xen_reserved_device_memory_map_t;
  549. DEFINE_XEN_GUEST_HANDLE(xen_reserved_device_memory_map_t);
  550. #endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */
  551. /*
  552. * Get the pages for a particular guest resource, so that they can be
  553. * mapped directly by a tools domain.
  554. */
  555. #define XENMEM_acquire_resource 28
  556. struct xen_mem_acquire_resource {
  557. /* IN - The domain whose resource is to be mapped */
  558. domid_t domid;
  559. /* IN - the type of resource */
  560. uint16_t type;
  561. #define XENMEM_resource_ioreq_server 0
  562. #define XENMEM_resource_grant_table 1
  563. /*
  564. * IN - a type-specific resource identifier, which must be zero
  565. * unless stated otherwise.
  566. *
  567. * type == XENMEM_resource_ioreq_server -> id == ioreq server id
  568. * type == XENMEM_resource_grant_table -> id defined below
  569. */
  570. uint32_t id;
  571. #define XENMEM_resource_grant_table_id_shared 0
  572. #define XENMEM_resource_grant_table_id_status 1
  573. /*
  574. * IN/OUT - As an IN parameter number of frames of the resource
  575. * to be mapped. However, if the specified value is 0 and
  576. * frame_list is NULL then this field will be set to the
  577. * maximum value supported by the implementation on return.
  578. */
  579. uint32_t nr_frames;
  580. uint32_t pad;
  581. /*
  582. * IN - the index of the initial frame to be mapped. This parameter
  583. * is ignored if nr_frames is 0.
  584. */
  585. uint64_t frame;
  586. #define XENMEM_resource_ioreq_server_frame_bufioreq 0
  587. #define XENMEM_resource_ioreq_server_frame_ioreq(n) (1 + (n))
  588. /*
  589. * IN/OUT - If the tools domain is PV then, upon return, frame_list
  590. * will be populated with the MFNs of the resource.
  591. * If the tools domain is HVM then it is expected that, on
  592. * entry, frame_list will be populated with a list of GFNs
  593. * that will be mapped to the MFNs of the resource.
  594. * If -EIO is returned then the frame_list has only been
  595. * partially mapped and it is up to the caller to unmap all
  596. * the GFNs.
  597. * This parameter may be NULL if nr_frames is 0.
  598. */
  599. XEN_GUEST_HANDLE(xen_pfn_t) frame_list;
  600. };
  601. typedef struct xen_mem_acquire_resource xen_mem_acquire_resource_t;
  602. DEFINE_XEN_GUEST_HANDLE(xen_mem_acquire_resource_t);
  603. /*
  604. * XENMEM_get_vnumainfo used by guest to get
  605. * vNUMA topology from hypervisor.
  606. */
  607. #define XENMEM_get_vnumainfo 26
  608. /* vNUMA node memory ranges */
  609. struct xen_vmemrange {
  610. uint64_t start, end;
  611. unsigned int flags;
  612. unsigned int nid;
  613. };
  614. typedef struct xen_vmemrange xen_vmemrange_t;
  615. DEFINE_XEN_GUEST_HANDLE(xen_vmemrange_t);
  616. /*
  617. * vNUMA topology specifies vNUMA node number, distance table,
  618. * memory ranges and vcpu mapping provided for guests.
  619. * XENMEM_get_vnumainfo hypercall expects to see from guest
  620. * nr_vnodes, nr_vmemranges and nr_vcpus to indicate available memory.
  621. * After filling guests structures, nr_vnodes, nr_vmemranges and nr_vcpus
  622. * copied back to guest. Domain returns expected values of nr_vnodes,
  623. * nr_vmemranges and nr_vcpus to guest if the values where incorrect.
  624. */
  625. struct xen_vnuma_topology_info {
  626. /* IN */
  627. domid_t domid;
  628. uint16_t pad;
  629. /* IN/OUT */
  630. unsigned int nr_vnodes;
  631. unsigned int nr_vcpus;
  632. unsigned int nr_vmemranges;
  633. /* OUT */
  634. union {
  635. XEN_GUEST_HANDLE(uint) h;
  636. uint64_t pad;
  637. } vdistance;
  638. union {
  639. XEN_GUEST_HANDLE(uint) h;
  640. uint64_t pad;
  641. } vcpu_to_vnode;
  642. union {
  643. XEN_GUEST_HANDLE(xen_vmemrange_t) h;
  644. uint64_t pad;
  645. } vmemrange;
  646. };
  647. typedef struct xen_vnuma_topology_info xen_vnuma_topology_info_t;
  648. DEFINE_XEN_GUEST_HANDLE(xen_vnuma_topology_info_t);
  649. /* Next available subop number is 29 */
  650. #endif /* __XEN_PUBLIC_MEMORY_H__ */
  651. /*
  652. * Local variables:
  653. * mode: C
  654. * c-file-style: "BSD"
  655. * c-basic-offset: 4
  656. * tab-width: 4
  657. * indent-tabs-mode: nil
  658. * End:
  659. */