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