1 /******************************************************************************
4 * Memory reservation and information.
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:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
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.
24 * Copyright (c) 2005, Keir Fraser <keir@xensource.com>
27 #ifndef __XEN_PUBLIC_MEMORY_H__
28 #define __XEN_PUBLIC_MEMORY_H__
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.
35 #define XENMEM_increase_reservation 0
36 #define XENMEM_decrease_reservation 1
37 #define XENMEM_populate_physmap 6
39 #if __XEN_INTERFACE_VERSION__ >= 0x00030209
41 * Maximum # bits addressable by the user of the allocated region (e.g., I/O
42 * devices often have a 32-bit limitation even in 64-bit systems). If zero
43 * then the user has no addressing restriction. This field is not used by
44 * XENMEM_decrease_reservation.
46 #define XENMEMF_address_bits(x) (x)
47 #define XENMEMF_get_address_bits(x) ((x) & 0xffu)
48 /* NUMA node to allocate from. */
49 #define XENMEMF_node(x) (((x) + 1) << 8)
50 #define XENMEMF_get_node(x) ((((x) >> 8) - 1) & 0xffu)
51 /* Flag to populate physmap with populate-on-demand entries */
52 #define XENMEMF_populate_on_demand (1<<16)
55 struct xen_memory_reservation
{
58 * XENMEM_increase_reservation:
59 * OUT: MFN (*not* GMFN) bases of extents that were allocated
60 * XENMEM_decrease_reservation:
61 * IN: GMFN bases of extents to free
62 * XENMEM_populate_physmap:
63 * IN: GPFN bases of extents to populate with memory
64 * OUT: GMFN bases of extents that were allocated
65 * (NB. This command also updates the mach_to_phys translation table)
67 XEN_GUEST_HANDLE(xen_pfn_t
) extent_start
;
69 /* Number of extents, and size/alignment of each (2^extent_order pages). */
70 xen_ulong_t nr_extents
;
71 unsigned int extent_order
;
73 #if __XEN_INTERFACE_VERSION__ >= 0x00030209
75 unsigned int mem_flags
;
77 unsigned int address_bits
;
81 * Domain whose reservation is being changed.
82 * Unprivileged domains can specify only DOMID_SELF.
86 typedef struct xen_memory_reservation xen_memory_reservation_t
;
87 DEFINE_XEN_GUEST_HANDLE(xen_memory_reservation_t
);
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.
96 #define XENMEM_exchange 11
97 struct xen_memory_exchange
{
99 * [IN] Details of memory extents to be exchanged (GMFN bases).
100 * Note that @in.address_bits is ignored and unused.
102 struct xen_memory_reservation in
;
105 * [IN/OUT] Details of new memory extents.
107 * 1. @in.domid == @out.domid
108 * 2. @in.nr_extents << @in.extent_order ==
109 * @out.nr_extents << @out.extent_order
110 * 3. @in.extent_start and @out.extent_start lists must not overlap
111 * 4. @out.extent_start lists GPFN bases to be populated
112 * 5. @out.extent_start is overwritten with allocated GMFN bases
114 struct xen_memory_reservation out
;
117 * [OUT] Number of input extents that were successfully exchanged:
118 * 1. The first @nr_exchanged input extents were successfully
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!
127 xen_ulong_t nr_exchanged
;
129 typedef struct xen_memory_exchange xen_memory_exchange_t
;
130 DEFINE_XEN_GUEST_HANDLE(xen_memory_exchange_t
);
133 * Returns the maximum machine frame number of mapped RAM in this system.
134 * This command always succeeds (it never returns an error code).
137 #define XENMEM_maximum_ram_page 2
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 domid_t.
144 #define XENMEM_current_reservation 3
145 #define XENMEM_maximum_reservation 4
148 * Returns the maximum GPFN in use by the guest, or -ve errcode on failure.
150 #define XENMEM_maximum_gpfn 14
153 * Returns a list of MFN bases of 2MB extents comprising the machine_to_phys
154 * mapping table. Architectures which do not have a m2p table do not implement
156 * arg == addr of xen_machphys_mfn_list_t.
158 #define XENMEM_machphys_mfn_list 5
159 struct xen_machphys_mfn_list
{
161 * Size of the 'extent_start' array. Fewer entries will be filled if the
162 * machphys table is smaller than max_extents * 2MB.
164 unsigned int max_extents
;
167 * Pointer to buffer to fill with list of extent starts. If there are
168 * any large discontiguities in the machine address space, 2MB gaps in
169 * the machphys table will be represented by an MFN base of zero.
171 XEN_GUEST_HANDLE(xen_pfn_t
) extent_start
;
174 * Number of extents written to the above array. This will be smaller
175 * than 'max_extents' if the machphys table is smaller than max_e * 2MB.
177 unsigned int nr_extents
;
179 typedef struct xen_machphys_mfn_list xen_machphys_mfn_list_t
;
180 DEFINE_XEN_GUEST_HANDLE(xen_machphys_mfn_list_t
);
183 * Returns the location in virtual address space of the machine_to_phys
184 * mapping table. Architectures which do not have a m2p table, or which do not
185 * map it by default into guest address space, do not implement this command.
186 * arg == addr of xen_machphys_mapping_t.
188 #define XENMEM_machphys_mapping 12
189 struct xen_machphys_mapping
{
190 xen_ulong_t v_start
, v_end
; /* Start and end virtual addresses. */
191 xen_ulong_t max_mfn
; /* Maximum MFN that can be looked up. */
193 typedef struct xen_machphys_mapping xen_machphys_mapping_t
;
194 DEFINE_XEN_GUEST_HANDLE(xen_machphys_mapping_t
);
197 * Sets the GPFN at which a particular page appears in the specified guest's
198 * pseudophysical address space.
199 * arg == addr of xen_add_to_physmap_t.
201 #define XENMEM_add_to_physmap 7
202 struct xen_add_to_physmap
{
203 /* Which domain to change the mapping for. */
206 /* Source mapping space. */
207 #define XENMAPSPACE_shared_info 0 /* shared info page */
208 #define XENMAPSPACE_grant_table 1 /* grant table page */
209 #define XENMAPSPACE_gmfn 2 /* GMFN */
212 /* Index into source mapping space. */
215 /* GPFN where the source mapping page should appear. */
218 typedef struct xen_add_to_physmap xen_add_to_physmap_t
;
219 DEFINE_XEN_GUEST_HANDLE(xen_add_to_physmap_t
);
222 /*#define XENMEM_translate_gpfn_list 8*/
225 * Returns the pseudo-physical memory map as it was when the domain
226 * was started (specified by XENMEM_set_memory_map).
227 * arg == addr of xen_memory_map_t.
229 #define XENMEM_memory_map 9
230 struct xen_memory_map
{
232 * On call the number of entries which can be stored in buffer. On
233 * return the number of entries which have been stored in
236 unsigned int nr_entries
;
239 * Entries in the buffer are in the same format as returned by the
240 * BIOS INT 0x15 EAX=0xE820 call.
242 XEN_GUEST_HANDLE(void) buffer
;
244 typedef struct xen_memory_map xen_memory_map_t
;
245 DEFINE_XEN_GUEST_HANDLE(xen_memory_map_t
);
248 * Returns the real physical memory map. Passes the same structure as
250 * arg == addr of xen_memory_map_t.
252 #define XENMEM_machine_memory_map 10
255 * Set the pseudo-physical memory map of a domain, as returned by
257 * arg == addr of xen_foreign_memory_map_t.
259 #define XENMEM_set_memory_map 13
260 struct xen_foreign_memory_map
{
262 struct xen_memory_map map
;
264 typedef struct xen_foreign_memory_map xen_foreign_memory_map_t
;
265 DEFINE_XEN_GUEST_HANDLE(xen_foreign_memory_map_t
);
267 #define XENMEM_set_pod_target 16
268 #define XENMEM_get_pod_target 17
269 struct xen_pod_target
{
271 uint64_t target_pages
;
274 uint64_t pod_cache_pages
;
275 uint64_t pod_entries
;
279 typedef struct xen_pod_target xen_pod_target_t
;
280 #endif /* __XEN_PUBLIC_MEMORY_H__ */
288 * indent-tabs-mode: nil