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)
53 struct xen_memory_reservation {
56 * XENMEM_increase_reservation:
57 * OUT: MFN (*not* GMFN) bases of extents that were allocated
58 * XENMEM_decrease_reservation:
59 * IN: GMFN bases of extents to free
60 * XENMEM_populate_physmap:
61 * IN: GPFN bases of extents to populate with memory
62 * OUT: GMFN bases of extents that were allocated
63 * (NB. This command also updates the mach_to_phys translation table)
65 XEN_GUEST_HANDLE(xen_pfn_t) extent_start;
67 /* Number of extents, and size/alignment of each (2^extent_order pages). */
68 xen_ulong_t nr_extents;
69 unsigned int extent_order;
71 #if __XEN_INTERFACE_VERSION__ >= 0x00030209
73 unsigned int mem_flags;
75 unsigned int address_bits;
79 * Domain whose reservation is being changed.
80 * Unprivileged domains can specify only DOMID_SELF.
84 typedef struct xen_memory_reservation xen_memory_reservation_t;
85 DEFINE_XEN_GUEST_HANDLE(xen_memory_reservation_t);
88 * An atomic exchange of memory pages. If return code is zero then
89 * @out.extent_list provides GMFNs of the newly-allocated memory.
90 * Returns zero on complete success, otherwise a negative error code.
91 * On complete success then always @nr_exchanged == @in.nr_extents.
92 * On partial success @nr_exchanged indicates how much work was done.
94 #define XENMEM_exchange 11
95 struct xen_memory_exchange {
97 * [IN] Details of memory extents to be exchanged (GMFN bases).
98 * Note that @in.address_bits is ignored and unused.
100 struct xen_memory_reservation in;
103 * [IN/OUT] Details of new memory extents.
105 * 1. @in.domid == @out.domid
106 * 2. @in.nr_extents << @in.extent_order ==
107 * @out.nr_extents << @out.extent_order
108 * 3. @in.extent_start and @out.extent_start lists must not overlap
109 * 4. @out.extent_start lists GPFN bases to be populated
110 * 5. @out.extent_start is overwritten with allocated GMFN bases
112 struct xen_memory_reservation out;
115 * [OUT] Number of input extents that were successfully exchanged:
116 * 1. The first @nr_exchanged input extents were successfully
118 * 2. The corresponding first entries in the output extent list correctly
119 * indicate the GMFNs that were successfully exchanged.
120 * 3. All other input and output extents are untouched.
121 * 4. If not all input exents are exchanged then the return code of this
122 * command will be non-zero.
123 * 5. THIS FIELD MUST BE INITIALISED TO ZERO BY THE CALLER!
125 xen_ulong_t nr_exchanged;
127 typedef struct xen_memory_exchange xen_memory_exchange_t;
128 DEFINE_XEN_GUEST_HANDLE(xen_memory_exchange_t);
131 * Returns the maximum machine frame number of mapped RAM in this system.
132 * This command always succeeds (it never returns an error code).
135 #define XENMEM_maximum_ram_page 2
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.
142 #define XENMEM_current_reservation 3
143 #define XENMEM_maximum_reservation 4
146 * Returns the maximum GPFN in use by the guest, or -ve errcode on failure.
148 #define XENMEM_maximum_gpfn 14
151 * Returns a list of MFN bases of 2MB extents comprising the machine_to_phys
152 * mapping table. Architectures which do not have a m2p table do not implement
154 * arg == addr of xen_machphys_mfn_list_t.
156 #define XENMEM_machphys_mfn_list 5
157 struct xen_machphys_mfn_list {
159 * Size of the 'extent_start' array. Fewer entries will be filled if the
160 * machphys table is smaller than max_extents * 2MB.
162 unsigned int max_extents;
165 * Pointer to buffer to fill with list of extent starts. If there are
166 * any large discontiguities in the machine address space, 2MB gaps in
167 * the machphys table will be represented by an MFN base of zero.
169 XEN_GUEST_HANDLE(xen_pfn_t) extent_start;
172 * Number of extents written to the above array. This will be smaller
173 * than 'max_extents' if the machphys table is smaller than max_e * 2MB.
175 unsigned int nr_extents;
177 typedef struct xen_machphys_mfn_list xen_machphys_mfn_list_t;
178 DEFINE_XEN_GUEST_HANDLE(xen_machphys_mfn_list_t);
181 * Returns the location in virtual address space of the machine_to_phys
182 * mapping table. Architectures which do not have a m2p table, or which do not
183 * map it by default into guest address space, do not implement this command.
184 * arg == addr of xen_machphys_mapping_t.
186 #define XENMEM_machphys_mapping 12
187 struct xen_machphys_mapping {
188 xen_ulong_t v_start, v_end; /* Start and end virtual addresses. */
189 xen_ulong_t max_mfn; /* Maximum MFN that can be looked up. */
191 typedef struct xen_machphys_mapping xen_machphys_mapping_t;
192 DEFINE_XEN_GUEST_HANDLE(xen_machphys_mapping_t);
195 * Sets the GPFN at which a particular page appears in the specified guest's
196 * pseudophysical address space.
197 * arg == addr of xen_add_to_physmap_t.
199 #define XENMEM_add_to_physmap 7
200 struct xen_add_to_physmap {
201 /* Which domain to change the mapping for. */
204 /* Source mapping space. */
205 #define XENMAPSPACE_shared_info 0 /* shared info page */
206 #define XENMAPSPACE_grant_table 1 /* grant table page */
207 #define XENMAPSPACE_mfn 2 /* usual MFN */
210 /* Index into source mapping space. */
213 /* GPFN where the source mapping page should appear. */
216 typedef struct xen_add_to_physmap xen_add_to_physmap_t;
217 DEFINE_XEN_GUEST_HANDLE(xen_add_to_physmap_t);
220 * Unmaps the page appearing at a particular GPFN from the specified guest's
221 * pseudophysical address space.
222 * arg == addr of xen_remove_from_physmap_t.
224 #define XENMEM_remove_from_physmap 15
225 struct xen_remove_from_physmap {
226 /* Which domain to change the mapping for. */
229 /* GPFN of the current mapping of the page. */
232 typedef struct xen_remove_from_physmap xen_remove_from_physmap_t;
233 DEFINE_XEN_GUEST_HANDLE(xen_remove_from_physmap_t);
236 * Translates a list of domain-specific GPFNs into MFNs. Returns a -ve error
237 * code on failure. This call only works for auto-translated guests.
239 #define XENMEM_translate_gpfn_list 8
240 struct xen_translate_gpfn_list {
241 /* Which domain to translate for? */
244 /* Length of list. */
245 xen_ulong_t nr_gpfns;
247 /* List of GPFNs to translate. */
248 XEN_GUEST_HANDLE(xen_pfn_t) gpfn_list;
251 * Output list to contain MFN translations. May be the same as the input
252 * list (in which case each input GPFN is overwritten with the output MFN).
254 XEN_GUEST_HANDLE(xen_pfn_t) mfn_list;
256 typedef struct xen_translate_gpfn_list xen_translate_gpfn_list_t;
257 DEFINE_XEN_GUEST_HANDLE(xen_translate_gpfn_list_t);
260 * Returns the pseudo-physical memory map as it was when the domain
261 * was started (specified by XENMEM_set_memory_map).
262 * arg == addr of xen_memory_map_t.
264 #define XENMEM_memory_map 9
265 struct xen_memory_map {
267 * On call the number of entries which can be stored in buffer. On
268 * return the number of entries which have been stored in
271 unsigned int nr_entries;
274 * Entries in the buffer are in the same format as returned by the
275 * BIOS INT 0x15 EAX=0xE820 call.
277 XEN_GUEST_HANDLE(void) buffer;
279 typedef struct xen_memory_map xen_memory_map_t;
280 DEFINE_XEN_GUEST_HANDLE(xen_memory_map_t);
283 * Returns the real physical memory map. Passes the same structure as
285 * arg == addr of xen_memory_map_t.
287 #define XENMEM_machine_memory_map 10
290 * Set the pseudo-physical memory map of a domain, as returned by
292 * arg == addr of xen_foreign_memory_map_t.
294 #define XENMEM_set_memory_map 13
295 struct xen_foreign_memory_map {
297 struct xen_memory_map map;
299 typedef struct xen_foreign_memory_map xen_foreign_memory_map_t;
300 DEFINE_XEN_GUEST_HANDLE(xen_foreign_memory_map_t);
302 #endif /* __XEN_PUBLIC_MEMORY_H__ */
310 * indent-tabs-mode: nil