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