memory.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  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. * pseudophysical address space.
  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. * pseudophysical address space.
  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. /* PAGING_PREP IN: buffer to immediately fill page in */
  351. uint64_aligned_t buffer;
  352. /* Other OPs */
  353. uint64_aligned_t gfn; /* IN: gfn of page being operated on */
  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_S_HANDLE_INVALID (-10)
  433. #define XENMEM_SHARING_OP_C_HANDLE_INVALID (-9)
  434. /* The following allows sharing of grant refs. This is useful
  435. * for sharing utilities sitting as "filters" in IO backends
  436. * (e.g. memshr + blktap(2)). The IO backend is only exposed
  437. * to grant references, and this allows sharing of the grefs */
  438. #define XENMEM_SHARING_OP_FIELD_IS_GREF_FLAG (xen_mk_ullong(1) << 62)
  439. #define XENMEM_SHARING_OP_FIELD_MAKE_GREF(field, val) \
  440. (field) = (XENMEM_SHARING_OP_FIELD_IS_GREF_FLAG | val)
  441. #define XENMEM_SHARING_OP_FIELD_IS_GREF(field) \
  442. ((field) & XENMEM_SHARING_OP_FIELD_IS_GREF_FLAG)
  443. #define XENMEM_SHARING_OP_FIELD_GET_GREF(field) \
  444. ((field) & (~XENMEM_SHARING_OP_FIELD_IS_GREF_FLAG))
  445. struct xen_mem_sharing_op {
  446. uint8_t op; /* XENMEM_sharing_op_* */
  447. domid_t domain;
  448. union {
  449. struct mem_sharing_op_nominate { /* OP_NOMINATE_xxx */
  450. union {
  451. uint64_aligned_t gfn; /* IN: gfn to nominate */
  452. uint32_t grant_ref; /* IN: grant ref to nominate */
  453. } u;
  454. uint64_aligned_t handle; /* OUT: the handle */
  455. } nominate;
  456. struct mem_sharing_op_share { /* OP_SHARE/ADD_PHYSMAP */
  457. uint64_aligned_t source_gfn; /* IN: the gfn of the source page */
  458. uint64_aligned_t source_handle; /* IN: handle to the source page */
  459. uint64_aligned_t client_gfn; /* IN: the client gfn */
  460. uint64_aligned_t client_handle; /* IN: handle to the client page */
  461. domid_t client_domain; /* IN: the client domain id */
  462. } share;
  463. struct mem_sharing_op_range { /* OP_RANGE_SHARE */
  464. uint64_aligned_t first_gfn; /* IN: the first gfn */
  465. uint64_aligned_t last_gfn; /* IN: the last gfn */
  466. uint64_aligned_t opaque; /* Must be set to 0 */
  467. domid_t client_domain; /* IN: the client domain id */
  468. uint16_t _pad[3]; /* Must be set to 0 */
  469. } range;
  470. struct mem_sharing_op_debug { /* OP_DEBUG_xxx */
  471. union {
  472. uint64_aligned_t gfn; /* IN: gfn to debug */
  473. uint64_aligned_t mfn; /* IN: mfn to debug */
  474. uint32_t gref; /* IN: gref to debug */
  475. } u;
  476. } debug;
  477. } u;
  478. };
  479. typedef struct xen_mem_sharing_op xen_mem_sharing_op_t;
  480. DEFINE_XEN_GUEST_HANDLE(xen_mem_sharing_op_t);
  481. /*
  482. * Attempt to stake a claim for a domain on a quantity of pages
  483. * of system RAM, but _not_ assign specific pageframes. Only
  484. * arithmetic is performed so the hypercall is very fast and need
  485. * not be preemptible, thus sidestepping time-of-check-time-of-use
  486. * races for memory allocation. Returns 0 if the hypervisor page
  487. * allocator has atomically and successfully claimed the requested
  488. * number of pages, else non-zero.
  489. *
  490. * Any domain may have only one active claim. When sufficient memory
  491. * has been allocated to resolve the claim, the claim silently expires.
  492. * Claiming zero pages effectively resets any outstanding claim and
  493. * is always successful.
  494. *
  495. * Note that a valid claim may be staked even after memory has been
  496. * allocated for a domain. In this case, the claim is not incremental,
  497. * i.e. if the domain's tot_pages is 3, and a claim is staked for 10,
  498. * only 7 additional pages are claimed.
  499. *
  500. * Caller must be privileged or the hypercall fails.
  501. */
  502. #define XENMEM_claim_pages 24
  503. /*
  504. * XENMEM_claim_pages flags - the are no flags at this time.
  505. * The zero value is appropriate.
  506. */
  507. /*
  508. * With some legacy devices, certain guest-physical addresses cannot safely
  509. * be used for other purposes, e.g. to map guest RAM. This hypercall
  510. * enumerates those regions so the toolstack can avoid using them.
  511. */
  512. #define XENMEM_reserved_device_memory_map 27
  513. struct xen_reserved_device_memory {
  514. xen_pfn_t start_pfn;
  515. xen_ulong_t nr_pages;
  516. };
  517. typedef struct xen_reserved_device_memory xen_reserved_device_memory_t;
  518. DEFINE_XEN_GUEST_HANDLE(xen_reserved_device_memory_t);
  519. struct xen_reserved_device_memory_map {
  520. #define XENMEM_RDM_ALL 1 /* Request all regions (ignore dev union). */
  521. /* IN */
  522. uint32_t flags;
  523. /*
  524. * IN/OUT
  525. *
  526. * Gets set to the required number of entries when too low,
  527. * signaled by error code -ERANGE.
  528. */
  529. unsigned int nr_entries;
  530. /* OUT */
  531. XEN_GUEST_HANDLE(xen_reserved_device_memory_t) buffer;
  532. /* IN */
  533. union {
  534. struct physdev_pci_device pci;
  535. } dev;
  536. };
  537. typedef struct xen_reserved_device_memory_map xen_reserved_device_memory_map_t;
  538. DEFINE_XEN_GUEST_HANDLE(xen_reserved_device_memory_map_t);
  539. #endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */
  540. /*
  541. * XENMEM_get_vnumainfo used by guest to get
  542. * vNUMA topology from hypervisor.
  543. */
  544. #define XENMEM_get_vnumainfo 26
  545. /* vNUMA node memory ranges */
  546. struct xen_vmemrange {
  547. uint64_t start, end;
  548. unsigned int flags;
  549. unsigned int nid;
  550. };
  551. typedef struct xen_vmemrange xen_vmemrange_t;
  552. DEFINE_XEN_GUEST_HANDLE(xen_vmemrange_t);
  553. /*
  554. * vNUMA topology specifies vNUMA node number, distance table,
  555. * memory ranges and vcpu mapping provided for guests.
  556. * XENMEM_get_vnumainfo hypercall expects to see from guest
  557. * nr_vnodes, nr_vmemranges and nr_vcpus to indicate available memory.
  558. * After filling guests structures, nr_vnodes, nr_vmemranges and nr_vcpus
  559. * copied back to guest. Domain returns expected values of nr_vnodes,
  560. * nr_vmemranges and nr_vcpus to guest if the values where incorrect.
  561. */
  562. struct xen_vnuma_topology_info {
  563. /* IN */
  564. domid_t domid;
  565. uint16_t pad;
  566. /* IN/OUT */
  567. unsigned int nr_vnodes;
  568. unsigned int nr_vcpus;
  569. unsigned int nr_vmemranges;
  570. /* OUT */
  571. union {
  572. XEN_GUEST_HANDLE(uint) h;
  573. uint64_t pad;
  574. } vdistance;
  575. union {
  576. XEN_GUEST_HANDLE(uint) h;
  577. uint64_t pad;
  578. } vcpu_to_vnode;
  579. union {
  580. XEN_GUEST_HANDLE(xen_vmemrange_t) h;
  581. uint64_t pad;
  582. } vmemrange;
  583. };
  584. typedef struct xen_vnuma_topology_info xen_vnuma_topology_info_t;
  585. DEFINE_XEN_GUEST_HANDLE(xen_vnuma_topology_info_t);
  586. /* Next available subop number is 28 */
  587. #endif /* __XEN_PUBLIC_MEMORY_H__ */
  588. /*
  589. * Local variables:
  590. * mode: C
  591. * c-file-style: "BSD"
  592. * c-basic-offset: 4
  593. * tab-width: 4
  594. * indent-tabs-mode: nil
  595. * End:
  596. */