ia64/xen-unstable

view xen/include/public/memory.h @ 17986:4bdc3de246c3

numa: Extend MEMOP_ allocation functions to take a node argument.

The address_bits field will be limited to 8 bits and is now embedded
in the mem_flags member, which additionally contains the node number
(limited to 8 bit).

Signed-off-by: Andre Przywara <andre.przywara@amd.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Sat Jul 05 14:43:37 2008 +0100 (2008-07-05)
parents 36e6f85cd572
children dade7f0bdc8d
line source
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 */
27 #ifndef __XEN_PUBLIC_MEMORY_H__
28 #define __XEN_PUBLIC_MEMORY_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
39 #if __XEN_INTERFACE_VERSION__ >= 0x00030209
40 /*
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.
45 */
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 #endif
53 struct xen_memory_reservation {
55 /*
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)
64 */
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
72 /* XENMEMF flags. */
73 unsigned int mem_flags;
74 #else
75 unsigned int address_bits;
76 #endif
78 /*
79 * Domain whose reservation is being changed.
80 * Unprivileged domains can specify only DOMID_SELF.
81 */
82 domid_t domid;
83 };
84 typedef struct xen_memory_reservation xen_memory_reservation_t;
85 DEFINE_XEN_GUEST_HANDLE(xen_memory_reservation_t);
87 /*
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.
93 */
94 #define XENMEM_exchange 11
95 struct xen_memory_exchange {
96 /*
97 * [IN] Details of memory extents to be exchanged (GMFN bases).
98 * Note that @in.address_bits is ignored and unused.
99 */
100 struct xen_memory_reservation in;
102 /*
103 * [IN/OUT] Details of new memory extents.
104 * We require that:
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
111 */
112 struct xen_memory_reservation out;
114 /*
115 * [OUT] Number of input extents that were successfully exchanged:
116 * 1. The first @nr_exchanged input extents were successfully
117 * deallocated.
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!
124 */
125 xen_ulong_t nr_exchanged;
126 };
127 typedef struct xen_memory_exchange xen_memory_exchange_t;
128 DEFINE_XEN_GUEST_HANDLE(xen_memory_exchange_t);
130 /*
131 * Returns the maximum machine frame number of mapped RAM in this system.
132 * This command always succeeds (it never returns an error code).
133 * arg == NULL.
134 */
135 #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
145 /*
146 * Returns the maximum GPFN in use by the guest, or -ve errcode on failure.
147 */
148 #define XENMEM_maximum_gpfn 14
150 /*
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
153 * this command.
154 * arg == addr of xen_machphys_mfn_list_t.
155 */
156 #define XENMEM_machphys_mfn_list 5
157 struct xen_machphys_mfn_list {
158 /*
159 * Size of the 'extent_start' array. Fewer entries will be filled if the
160 * machphys table is smaller than max_extents * 2MB.
161 */
162 unsigned int max_extents;
164 /*
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.
168 */
169 XEN_GUEST_HANDLE(xen_pfn_t) extent_start;
171 /*
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.
174 */
175 unsigned int nr_extents;
176 };
177 typedef struct xen_machphys_mfn_list xen_machphys_mfn_list_t;
178 DEFINE_XEN_GUEST_HANDLE(xen_machphys_mfn_list_t);
180 /*
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.
185 */
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. */
190 };
191 typedef struct xen_machphys_mapping xen_machphys_mapping_t;
192 DEFINE_XEN_GUEST_HANDLE(xen_machphys_mapping_t);
194 /*
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.
198 */
199 #define XENMEM_add_to_physmap 7
200 struct xen_add_to_physmap {
201 /* Which domain to change the mapping for. */
202 domid_t domid;
204 /* Source mapping space. */
205 #define XENMAPSPACE_shared_info 0 /* shared info page */
206 #define XENMAPSPACE_grant_table 1 /* grant table page */
207 unsigned int space;
209 /* Index into source mapping space. */
210 xen_ulong_t idx;
212 /* GPFN where the source mapping page should appear. */
213 xen_pfn_t gpfn;
214 };
215 typedef struct xen_add_to_physmap xen_add_to_physmap_t;
216 DEFINE_XEN_GUEST_HANDLE(xen_add_to_physmap_t);
218 /*
219 * Translates a list of domain-specific GPFNs into MFNs. Returns a -ve error
220 * code on failure. This call only works for auto-translated guests.
221 */
222 #define XENMEM_translate_gpfn_list 8
223 struct xen_translate_gpfn_list {
224 /* Which domain to translate for? */
225 domid_t domid;
227 /* Length of list. */
228 xen_ulong_t nr_gpfns;
230 /* List of GPFNs to translate. */
231 XEN_GUEST_HANDLE(xen_pfn_t) gpfn_list;
233 /*
234 * Output list to contain MFN translations. May be the same as the input
235 * list (in which case each input GPFN is overwritten with the output MFN).
236 */
237 XEN_GUEST_HANDLE(xen_pfn_t) mfn_list;
238 };
239 typedef struct xen_translate_gpfn_list xen_translate_gpfn_list_t;
240 DEFINE_XEN_GUEST_HANDLE(xen_translate_gpfn_list_t);
242 /*
243 * Returns the pseudo-physical memory map as it was when the domain
244 * was started (specified by XENMEM_set_memory_map).
245 * arg == addr of xen_memory_map_t.
246 */
247 #define XENMEM_memory_map 9
248 struct xen_memory_map {
249 /*
250 * On call the number of entries which can be stored in buffer. On
251 * return the number of entries which have been stored in
252 * buffer.
253 */
254 unsigned int nr_entries;
256 /*
257 * Entries in the buffer are in the same format as returned by the
258 * BIOS INT 0x15 EAX=0xE820 call.
259 */
260 XEN_GUEST_HANDLE(void) buffer;
261 };
262 typedef struct xen_memory_map xen_memory_map_t;
263 DEFINE_XEN_GUEST_HANDLE(xen_memory_map_t);
265 /*
266 * Returns the real physical memory map. Passes the same structure as
267 * XENMEM_memory_map.
268 * arg == addr of xen_memory_map_t.
269 */
270 #define XENMEM_machine_memory_map 10
272 /*
273 * Set the pseudo-physical memory map of a domain, as returned by
274 * XENMEM_memory_map.
275 * arg == addr of xen_foreign_memory_map_t.
276 */
277 #define XENMEM_set_memory_map 13
278 struct xen_foreign_memory_map {
279 domid_t domid;
280 struct xen_memory_map map;
281 };
282 typedef struct xen_foreign_memory_map xen_foreign_memory_map_t;
283 DEFINE_XEN_GUEST_HANDLE(xen_foreign_memory_map_t);
285 #endif /* __XEN_PUBLIC_MEMORY_H__ */
287 /*
288 * Local variables:
289 * mode: C
290 * c-set-style: "BSD"
291 * c-basic-offset: 4
292 * tab-width: 4
293 * indent-tabs-mode: nil
294 * End:
295 */