Linux Audio

Check our new training course

Loading...
v3.1
 
  1/******************************************************************************
  2 * memory.h
  3 *
  4 * Memory reservation and information.
  5 *
  6 * Copyright (c) 2005, Keir Fraser <keir@xensource.com>
  7 */
  8
  9#ifndef __XEN_PUBLIC_MEMORY_H__
 10#define __XEN_PUBLIC_MEMORY_H__
 11
 12#include <linux/spinlock.h>
 13
 14/*
 15 * Increase or decrease the specified domain's memory reservation. Returns a
 16 * -ve errcode on failure, or the # extents successfully allocated or freed.
 17 * arg == addr of struct xen_memory_reservation.
 18 */
 19#define XENMEM_increase_reservation 0
 20#define XENMEM_decrease_reservation 1
 21#define XENMEM_populate_physmap     6
 22struct xen_memory_reservation {
 23
 24    /*
 25     * XENMEM_increase_reservation:
 26     *   OUT: MFN (*not* GMFN) bases of extents that were allocated
 27     * XENMEM_decrease_reservation:
 28     *   IN:  GMFN bases of extents to free
 29     * XENMEM_populate_physmap:
 30     *   IN:  GPFN bases of extents to populate with memory
 31     *   OUT: GMFN bases of extents that were allocated
 32     *   (NB. This command also updates the mach_to_phys translation table)
 33     */
 34    GUEST_HANDLE(ulong) extent_start;
 35
 36    /* Number of extents, and size/alignment of each (2^extent_order pages). */
 37    unsigned long  nr_extents;
 38    unsigned int   extent_order;
 39
 40    /*
 41     * Maximum # bits addressable by the user of the allocated region (e.g.,
 42     * I/O devices often have a 32-bit limitation even in 64-bit systems). If
 43     * zero then the user has no addressing restriction.
 44     * This field is not used by XENMEM_decrease_reservation.
 45     */
 46    unsigned int   address_bits;
 47
 48    /*
 49     * Domain whose reservation is being changed.
 50     * Unprivileged domains can specify only DOMID_SELF.
 51     */
 52    domid_t        domid;
 53
 54};
 55DEFINE_GUEST_HANDLE_STRUCT(xen_memory_reservation);
 56
 57/*
 58 * An atomic exchange of memory pages. If return code is zero then
 59 * @out.extent_list provides GMFNs of the newly-allocated memory.
 60 * Returns zero on complete success, otherwise a negative error code.
 61 * On complete success then always @nr_exchanged == @in.nr_extents.
 62 * On partial success @nr_exchanged indicates how much work was done.
 63 */
 64#define XENMEM_exchange             11
 65struct xen_memory_exchange {
 66    /*
 67     * [IN] Details of memory extents to be exchanged (GMFN bases).
 68     * Note that @in.address_bits is ignored and unused.
 69     */
 70    struct xen_memory_reservation in;
 71
 72    /*
 73     * [IN/OUT] Details of new memory extents.
 74     * We require that:
 75     *  1. @in.domid == @out.domid
 76     *  2. @in.nr_extents  << @in.extent_order ==
 77     *     @out.nr_extents << @out.extent_order
 78     *  3. @in.extent_start and @out.extent_start lists must not overlap
 79     *  4. @out.extent_start lists GPFN bases to be populated
 80     *  5. @out.extent_start is overwritten with allocated GMFN bases
 81     */
 82    struct xen_memory_reservation out;
 83
 84    /*
 85     * [OUT] Number of input extents that were successfully exchanged:
 86     *  1. The first @nr_exchanged input extents were successfully
 87     *     deallocated.
 88     *  2. The corresponding first entries in the output extent list correctly
 89     *     indicate the GMFNs that were successfully exchanged.
 90     *  3. All other input and output extents are untouched.
 91     *  4. If not all input exents are exchanged then the return code of this
 92     *     command will be non-zero.
 93     *  5. THIS FIELD MUST BE INITIALISED TO ZERO BY THE CALLER!
 94     */
 95    unsigned long nr_exchanged;
 96};
 97
 98DEFINE_GUEST_HANDLE_STRUCT(xen_memory_exchange);
 99/*
100 * Returns the maximum machine frame number of mapped RAM in this system.
101 * This command always succeeds (it never returns an error code).
102 * arg == NULL.
103 */
104#define XENMEM_maximum_ram_page     2
105
106/*
107 * Returns the current or maximum memory reservation, in pages, of the
108 * specified domain (may be DOMID_SELF). Returns -ve errcode on failure.
109 * arg == addr of domid_t.
110 */
111#define XENMEM_current_reservation  3
112#define XENMEM_maximum_reservation  4
113
114/*
115 * Returns a list of MFN bases of 2MB extents comprising the machine_to_phys
116 * mapping table. Architectures which do not have a m2p table do not implement
117 * this command.
118 * arg == addr of xen_machphys_mfn_list_t.
119 */
120#define XENMEM_machphys_mfn_list    5
121struct xen_machphys_mfn_list {
122    /*
123     * Size of the 'extent_start' array. Fewer entries will be filled if the
124     * machphys table is smaller than max_extents * 2MB.
125     */
126    unsigned int max_extents;
127
128    /*
129     * Pointer to buffer to fill with list of extent starts. If there are
130     * any large discontiguities in the machine address space, 2MB gaps in
131     * the machphys table will be represented by an MFN base of zero.
132     */
133    GUEST_HANDLE(ulong) extent_start;
134
135    /*
136     * Number of extents written to the above array. This will be smaller
137     * than 'max_extents' if the machphys table is smaller than max_e * 2MB.
138     */
139    unsigned int nr_extents;
140};
141DEFINE_GUEST_HANDLE_STRUCT(xen_machphys_mfn_list);
142
143/*
144 * Returns the location in virtual address space of the machine_to_phys
145 * mapping table. Architectures which do not have a m2p table, or which do not
146 * map it by default into guest address space, do not implement this command.
147 * arg == addr of xen_machphys_mapping_t.
148 */
149#define XENMEM_machphys_mapping     12
150struct xen_machphys_mapping {
151    unsigned long v_start, v_end; /* Start and end virtual addresses.   */
152    unsigned long max_mfn;        /* Maximum MFN that can be looked up. */
153};
154DEFINE_GUEST_HANDLE_STRUCT(xen_machphys_mapping_t);
155
 
 
 
 
 
 
 
 
 
156/*
157 * Sets the GPFN at which a particular page appears in the specified guest's
158 * pseudophysical address space.
159 * arg == addr of xen_add_to_physmap_t.
160 */
161#define XENMEM_add_to_physmap      7
162struct xen_add_to_physmap {
163    /* Which domain to change the mapping for. */
164    domid_t domid;
165
 
 
 
166    /* Source mapping space. */
167#define XENMAPSPACE_shared_info 0 /* shared info page */
168#define XENMAPSPACE_grant_table 1 /* grant table page */
169    unsigned int space;
170
171    /* Index into source mapping space. */
172    unsigned long idx;
173
174    /* GPFN where the source mapping page should appear. */
175    unsigned long gpfn;
176};
177DEFINE_GUEST_HANDLE_STRUCT(xen_add_to_physmap);
178
179/*
180 * Translates a list of domain-specific GPFNs into MFNs. Returns a -ve error
181 * code on failure. This call only works for auto-translated guests.
182 */
183#define XENMEM_translate_gpfn_list  8
184struct xen_translate_gpfn_list {
185    /* Which domain to translate for? */
186    domid_t domid;
 
187
188    /* Length of list. */
189    unsigned long nr_gpfns;
 
190
191    /* List of GPFNs to translate. */
192    GUEST_HANDLE(ulong) gpfn_list;
193
194    /*
195     * Output list to contain MFN translations. May be the same as the input
196     * list (in which case each input GPFN is overwritten with the output MFN).
197     */
198    GUEST_HANDLE(ulong) mfn_list;
 
 
199};
200DEFINE_GUEST_HANDLE_STRUCT(xen_translate_gpfn_list);
201
202/*
203 * Returns the pseudo-physical memory map as it was when the domain
204 * was started (specified by XENMEM_set_memory_map).
205 * arg == addr of struct xen_memory_map.
206 */
207#define XENMEM_memory_map           9
208struct xen_memory_map {
209    /*
210     * On call the number of entries which can be stored in buffer. On
211     * return the number of entries which have been stored in
212     * buffer.
213     */
214    unsigned int nr_entries;
215
216    /*
217     * Entries in the buffer are in the same format as returned by the
218     * BIOS INT 0x15 EAX=0xE820 call.
219     */
220    GUEST_HANDLE(void) buffer;
221};
222DEFINE_GUEST_HANDLE_STRUCT(xen_memory_map);
223
224/*
225 * Returns the real physical memory map. Passes the same structure as
226 * XENMEM_memory_map.
227 * arg == addr of struct xen_memory_map.
228 */
229#define XENMEM_machine_memory_map   10
230
231
232/*
233 * Prevent the balloon driver from changing the memory reservation
234 * during a driver critical region.
235 */
236extern spinlock_t xen_reservation_lock;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
237#endif /* __XEN_PUBLIC_MEMORY_H__ */
v4.17
  1/* SPDX-License-Identifier: GPL-2.0 */
  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 <linux/spinlock.h>
 14
 15/*
 16 * Increase or decrease the specified domain's memory reservation. Returns a
 17 * -ve errcode on failure, or the # extents successfully allocated or freed.
 18 * arg == addr of struct xen_memory_reservation.
 19 */
 20#define XENMEM_increase_reservation 0
 21#define XENMEM_decrease_reservation 1
 22#define XENMEM_populate_physmap     6
 23struct xen_memory_reservation {
 24
 25    /*
 26     * XENMEM_increase_reservation:
 27     *   OUT: MFN (*not* GMFN) bases of extents that were allocated
 28     * XENMEM_decrease_reservation:
 29     *   IN:  GMFN bases of extents to free
 30     * XENMEM_populate_physmap:
 31     *   IN:  GPFN bases of extents to populate with memory
 32     *   OUT: GMFN bases of extents that were allocated
 33     *   (NB. This command also updates the mach_to_phys translation table)
 34     */
 35    GUEST_HANDLE(xen_pfn_t) extent_start;
 36
 37    /* Number of extents, and size/alignment of each (2^extent_order pages). */
 38    xen_ulong_t  nr_extents;
 39    unsigned int   extent_order;
 40
 41    /*
 42     * Maximum # bits addressable by the user of the allocated region (e.g.,
 43     * I/O devices often have a 32-bit limitation even in 64-bit systems). If
 44     * zero then the user has no addressing restriction.
 45     * This field is not used by XENMEM_decrease_reservation.
 46     */
 47    unsigned int   address_bits;
 48
 49    /*
 50     * Domain whose reservation is being changed.
 51     * Unprivileged domains can specify only DOMID_SELF.
 52     */
 53    domid_t        domid;
 54
 55};
 56DEFINE_GUEST_HANDLE_STRUCT(xen_memory_reservation);
 57
 58/*
 59 * An atomic exchange of memory pages. If return code is zero then
 60 * @out.extent_list provides GMFNs of the newly-allocated memory.
 61 * Returns zero on complete success, otherwise a negative error code.
 62 * On complete success then always @nr_exchanged == @in.nr_extents.
 63 * On partial success @nr_exchanged indicates how much work was done.
 64 */
 65#define XENMEM_exchange             11
 66struct xen_memory_exchange {
 67    /*
 68     * [IN] Details of memory extents to be exchanged (GMFN bases).
 69     * Note that @in.address_bits is ignored and unused.
 70     */
 71    struct xen_memory_reservation in;
 72
 73    /*
 74     * [IN/OUT] Details of new memory extents.
 75     * We require that:
 76     *  1. @in.domid == @out.domid
 77     *  2. @in.nr_extents  << @in.extent_order ==
 78     *     @out.nr_extents << @out.extent_order
 79     *  3. @in.extent_start and @out.extent_start lists must not overlap
 80     *  4. @out.extent_start lists GPFN bases to be populated
 81     *  5. @out.extent_start is overwritten with allocated GMFN bases
 82     */
 83    struct xen_memory_reservation out;
 84
 85    /*
 86     * [OUT] Number of input extents that were successfully exchanged:
 87     *  1. The first @nr_exchanged input extents were successfully
 88     *     deallocated.
 89     *  2. The corresponding first entries in the output extent list correctly
 90     *     indicate the GMFNs that were successfully exchanged.
 91     *  3. All other input and output extents are untouched.
 92     *  4. If not all input exents are exchanged then the return code of this
 93     *     command will be non-zero.
 94     *  5. THIS FIELD MUST BE INITIALISED TO ZERO BY THE CALLER!
 95     */
 96    xen_ulong_t nr_exchanged;
 97};
 98
 99DEFINE_GUEST_HANDLE_STRUCT(xen_memory_exchange);
100/*
101 * Returns the maximum machine frame number of mapped RAM in this system.
102 * This command always succeeds (it never returns an error code).
103 * arg == NULL.
104 */
105#define XENMEM_maximum_ram_page     2
106
107/*
108 * Returns the current or maximum memory reservation, in pages, of the
109 * specified domain (may be DOMID_SELF). Returns -ve errcode on failure.
110 * arg == addr of domid_t.
111 */
112#define XENMEM_current_reservation  3
113#define XENMEM_maximum_reservation  4
114
115/*
116 * Returns a list of MFN bases of 2MB extents comprising the machine_to_phys
117 * mapping table. Architectures which do not have a m2p table do not implement
118 * this command.
119 * arg == addr of xen_machphys_mfn_list_t.
120 */
121#define XENMEM_machphys_mfn_list    5
122struct xen_machphys_mfn_list {
123    /*
124     * Size of the 'extent_start' array. Fewer entries will be filled if the
125     * machphys table is smaller than max_extents * 2MB.
126     */
127    unsigned int max_extents;
128
129    /*
130     * Pointer to buffer to fill with list of extent starts. If there are
131     * any large discontiguities in the machine address space, 2MB gaps in
132     * the machphys table will be represented by an MFN base of zero.
133     */
134    GUEST_HANDLE(xen_pfn_t) extent_start;
135
136    /*
137     * Number of extents written to the above array. This will be smaller
138     * than 'max_extents' if the machphys table is smaller than max_e * 2MB.
139     */
140    unsigned int nr_extents;
141};
142DEFINE_GUEST_HANDLE_STRUCT(xen_machphys_mfn_list);
143
144/*
145 * Returns the location in virtual address space of the machine_to_phys
146 * mapping table. Architectures which do not have a m2p table, or which do not
147 * map it by default into guest address space, do not implement this command.
148 * arg == addr of xen_machphys_mapping_t.
149 */
150#define XENMEM_machphys_mapping     12
151struct xen_machphys_mapping {
152    xen_ulong_t v_start, v_end; /* Start and end virtual addresses.   */
153    xen_ulong_t max_mfn;        /* Maximum MFN that can be looked up. */
154};
155DEFINE_GUEST_HANDLE_STRUCT(xen_machphys_mapping_t);
156
157#define XENMAPSPACE_shared_info  0 /* shared info page */
158#define XENMAPSPACE_grant_table  1 /* grant table page */
159#define XENMAPSPACE_gmfn         2 /* GMFN */
160#define XENMAPSPACE_gmfn_range   3 /* GMFN range, XENMEM_add_to_physmap only. */
161#define XENMAPSPACE_gmfn_foreign 4 /* GMFN from another dom,
162				    * XENMEM_add_to_physmap_range only.
163				    */
164#define XENMAPSPACE_dev_mmio     5 /* device mmio region */
165
166/*
167 * Sets the GPFN at which a particular page appears in the specified guest's
168 * pseudophysical address space.
169 * arg == addr of xen_add_to_physmap_t.
170 */
171#define XENMEM_add_to_physmap      7
172struct xen_add_to_physmap {
173    /* Which domain to change the mapping for. */
174    domid_t domid;
175
176    /* Number of pages to go through for gmfn_range */
177    uint16_t    size;
178
179    /* Source mapping space. */
 
 
180    unsigned int space;
181
182    /* Index into source mapping space. */
183    xen_ulong_t idx;
184
185    /* GPFN where the source mapping page should appear. */
186    xen_pfn_t gpfn;
187};
188DEFINE_GUEST_HANDLE_STRUCT(xen_add_to_physmap);
189
190/*** REMOVED ***/
191/*#define XENMEM_translate_gpfn_list  8*/
192
193#define XENMEM_add_to_physmap_range 23
194struct xen_add_to_physmap_range {
195    /* IN */
196    /* Which domain to change the mapping for. */
197    domid_t domid;
198    uint16_t space; /* => enum phys_map_space */
199
200    /* Number of pages to go through */
201    uint16_t size;
202    domid_t foreign_domid; /* IFF gmfn_foreign */
203
204    /* Indexes into space being mapped. */
205    GUEST_HANDLE(xen_ulong_t) idxs;
206
207    /* GPFN in domid where the source mapping page should appear. */
208    GUEST_HANDLE(xen_pfn_t) gpfns;
209
210    /* OUT */
211
212    /* Per index error code. */
213    GUEST_HANDLE(int) errs;
214};
215DEFINE_GUEST_HANDLE_STRUCT(xen_add_to_physmap_range);
216
217/*
218 * Returns the pseudo-physical memory map as it was when the domain
219 * was started (specified by XENMEM_set_memory_map).
220 * arg == addr of struct xen_memory_map.
221 */
222#define XENMEM_memory_map           9
223struct xen_memory_map {
224    /*
225     * On call the number of entries which can be stored in buffer. On
226     * return the number of entries which have been stored in
227     * buffer.
228     */
229    unsigned int nr_entries;
230
231    /*
232     * Entries in the buffer are in the same format as returned by the
233     * BIOS INT 0x15 EAX=0xE820 call.
234     */
235    GUEST_HANDLE(void) buffer;
236};
237DEFINE_GUEST_HANDLE_STRUCT(xen_memory_map);
238
239/*
240 * Returns the real physical memory map. Passes the same structure as
241 * XENMEM_memory_map.
242 * arg == addr of struct xen_memory_map.
243 */
244#define XENMEM_machine_memory_map   10
245
246
247/*
248 * Prevent the balloon driver from changing the memory reservation
249 * during a driver critical region.
250 */
251extern spinlock_t xen_reservation_lock;
252
253/*
254 * Unmaps the page appearing at a particular GPFN from the specified guest's
255 * pseudophysical address space.
256 * arg == addr of xen_remove_from_physmap_t.
257 */
258#define XENMEM_remove_from_physmap      15
259struct xen_remove_from_physmap {
260    /* Which domain to change the mapping for. */
261    domid_t domid;
262
263    /* GPFN of the current mapping of the page. */
264    xen_pfn_t gpfn;
265};
266DEFINE_GUEST_HANDLE_STRUCT(xen_remove_from_physmap);
267
268#endif /* __XEN_PUBLIC_MEMORY_H__ */