uboot/include/xen/interface/memory.h
<<
>>
Prefs
   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/*
  14 * Increase or decrease the specified domain's memory reservation. Returns a
  15 * -ve errcode on failure, or the # extents successfully allocated or freed.
  16 * arg == addr of struct xen_memory_reservation.
  17 */
  18#define XENMEM_increase_reservation 0
  19#define XENMEM_decrease_reservation 1
  20#define XENMEM_populate_physmap     6
  21struct xen_memory_reservation {
  22        /*
  23         * XENMEM_increase_reservation:
  24         *   OUT: MFN (*not* GMFN) bases of extents that were allocated
  25         * XENMEM_decrease_reservation:
  26         *   IN:  GMFN bases of extents to free
  27         * XENMEM_populate_physmap:
  28         *   IN:  GPFN bases of extents to populate with memory
  29         *   OUT: GMFN bases of extents that were allocated
  30         *   (NB. This command also updates the mach_to_phys translation table)
  31         */
  32        GUEST_HANDLE(xen_pfn_t)extent_start;
  33
  34        /* Number of extents, and size/alignment of each (2^extent_order pages). */
  35        xen_ulong_t  nr_extents;
  36        unsigned int   extent_order;
  37
  38        /*
  39         * Maximum # bits addressable by the user of the allocated region (e.g.,
  40         * I/O devices often have a 32-bit limitation even in 64-bit systems). If
  41         * zero then the user has no addressing restriction.
  42         * This field is not used by XENMEM_decrease_reservation.
  43         */
  44        unsigned int   address_bits;
  45
  46        /*
  47         * Domain whose reservation is being changed.
  48         * Unprivileged domains can specify only DOMID_SELF.
  49         */
  50        domid_t        domid;
  51
  52};
  53
  54DEFINE_GUEST_HANDLE_STRUCT(xen_memory_reservation);
  55
  56/*
  57 * An atomic exchange of memory pages. If return code is zero then
  58 * @out.extent_list provides GMFNs of the newly-allocated memory.
  59 * Returns zero on complete success, otherwise a negative error code.
  60 * On complete success then always @nr_exchanged == @in.nr_extents.
  61 * On partial success @nr_exchanged indicates how much work was done.
  62 */
  63#define XENMEM_exchange             11
  64struct xen_memory_exchange {
  65        /*
  66         * [IN] Details of memory extents to be exchanged (GMFN bases).
  67         * Note that @in.address_bits is ignored and unused.
  68         */
  69        struct xen_memory_reservation in;
  70
  71        /*
  72         * [IN/OUT] Details of new memory extents.
  73         * We require that:
  74         *  1. @in.domid == @out.domid
  75         *  2. @in.nr_extents  << @in.extent_order ==
  76         *     @out.nr_extents << @out.extent_order
  77         *  3. @in.extent_start and @out.extent_start lists must not overlap
  78         *  4. @out.extent_start lists GPFN bases to be populated
  79         *  5. @out.extent_start is overwritten with allocated GMFN bases
  80         */
  81        struct xen_memory_reservation out;
  82
  83        /*
  84         * [OUT] Number of input extents that were successfully exchanged:
  85         *  1. The first @nr_exchanged input extents were successfully
  86         *     deallocated.
  87         *  2. The corresponding first entries in the output extent list correctly
  88         *     indicate the GMFNs that were successfully exchanged.
  89         *  3. All other input and output extents are untouched.
  90         *  4. If not all input exents are exchanged then the return code of this
  91         *     command will be non-zero.
  92         *  5. THIS FIELD MUST BE INITIALISED TO ZERO BY THE CALLER!
  93         */
  94        xen_ulong_t nr_exchanged;
  95};
  96
  97DEFINE_GUEST_HANDLE_STRUCT(xen_memory_exchange);
  98/*
  99 * Returns the maximum machine frame number of mapped RAM in this system.
 100 * This command always succeeds (it never returns an error code).
 101 * arg == NULL.
 102 */
 103#define XENMEM_maximum_ram_page     2
 104
 105/*
 106 * Returns the current or maximum memory reservation, in pages, of the
 107 * specified domain (may be DOMID_SELF). Returns -ve errcode on failure.
 108 * arg == addr of domid_t.
 109 */
 110#define XENMEM_current_reservation  3
 111#define XENMEM_maximum_reservation  4
 112
 113/*
 114 * Returns a list of MFN bases of 2MB extents comprising the machine_to_phys
 115 * mapping table. Architectures which do not have a m2p table do not implement
 116 * this command.
 117 * arg == addr of xen_machphys_mfn_list_t.
 118 */
 119#define XENMEM_machphys_mfn_list    5
 120struct xen_machphys_mfn_list {
 121        /*
 122         * Size of the 'extent_start' array. Fewer entries will be filled if the
 123         * machphys table is smaller than max_extents * 2MB.
 124         */
 125        unsigned int max_extents;
 126
 127        /*
 128         * Pointer to buffer to fill with list of extent starts. If there are
 129         * any large discontiguities in the machine address space, 2MB gaps in
 130         * the machphys table will be represented by an MFN base of zero.
 131         */
 132        GUEST_HANDLE(xen_pfn_t)extent_start;
 133
 134        /*
 135         * Number of extents written to the above array. This will be smaller
 136         * than 'max_extents' if the machphys table is smaller than max_e * 2MB.
 137         */
 138        unsigned int nr_extents;
 139};
 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        xen_ulong_t v_start, v_end; /* Start and end virtual addresses.   */
 152        xen_ulong_t max_mfn;        /* Maximum MFN that can be looked up. */
 153};
 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        u16    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};
 188
 189DEFINE_GUEST_HANDLE_STRUCT(xen_add_to_physmap);
 190
 191/*** REMOVED ***/
 192/*#define XENMEM_translate_gpfn_list  8*/
 193
 194#define XENMEM_add_to_physmap_range 23
 195struct xen_add_to_physmap_range {
 196        /* IN */
 197        /* Which domain to change the mapping for. */
 198        domid_t domid;
 199        u16 space; /* => enum phys_map_space */
 200
 201        /* Number of pages to go through */
 202        u16 size;
 203        domid_t foreign_domid; /* IFF gmfn_foreign */
 204
 205        /* Indexes into space being mapped. */
 206        GUEST_HANDLE(xen_ulong_t)idxs;
 207
 208        /* GPFN in domid where the source mapping page should appear. */
 209        GUEST_HANDLE(xen_pfn_t)gpfns;
 210
 211        /* OUT */
 212
 213        /* Per index error code. */
 214        GUEST_HANDLE(int)errs;
 215};
 216
 217DEFINE_GUEST_HANDLE_STRUCT(xen_add_to_physmap_range);
 218
 219/*
 220 * Returns the pseudo-physical memory map as it was when the domain
 221 * was started (specified by XENMEM_set_memory_map).
 222 * arg == addr of struct xen_memory_map.
 223 */
 224#define XENMEM_memory_map           9
 225struct xen_memory_map {
 226        /*
 227         * On call the number of entries which can be stored in buffer. On
 228         * return the number of entries which have been stored in
 229         * buffer.
 230         */
 231        unsigned int nr_entries;
 232
 233        /*
 234         * Entries in the buffer are in the same format as returned by the
 235         * BIOS INT 0x15 EAX=0xE820 call.
 236         */
 237        GUEST_HANDLE(void)buffer;
 238};
 239
 240DEFINE_GUEST_HANDLE_STRUCT(xen_memory_map);
 241
 242/*
 243 * Returns the real physical memory map. Passes the same structure as
 244 * XENMEM_memory_map.
 245 * arg == addr of struct xen_memory_map.
 246 */
 247#define XENMEM_machine_memory_map   10
 248
 249/*
 250 * Unmaps the page appearing at a particular GPFN from the specified guest's
 251 * pseudophysical address space.
 252 * arg == addr of xen_remove_from_physmap_t.
 253 */
 254#define XENMEM_remove_from_physmap      15
 255struct xen_remove_from_physmap {
 256        /* Which domain to change the mapping for. */
 257        domid_t domid;
 258
 259        /* GPFN of the current mapping of the page. */
 260        xen_pfn_t gpfn;
 261};
 262
 263DEFINE_GUEST_HANDLE_STRUCT(xen_remove_from_physmap);
 264
 265/*
 266 * Get the pages for a particular guest resource, so that they can be
 267 * mapped directly by a tools domain.
 268 */
 269#define XENMEM_acquire_resource 28
 270struct xen_mem_acquire_resource {
 271        /* IN - The domain whose resource is to be mapped */
 272        domid_t domid;
 273        /* IN - the type of resource */
 274        u16 type;
 275
 276#define XENMEM_resource_ioreq_server 0
 277#define XENMEM_resource_grant_table 1
 278
 279        /*
 280         * IN - a type-specific resource identifier, which must be zero
 281         *      unless stated otherwise.
 282         *
 283         * type == XENMEM_resource_ioreq_server -> id == ioreq server id
 284         * type == XENMEM_resource_grant_table -> id defined below
 285         */
 286        u32 id;
 287
 288#define XENMEM_resource_grant_table_id_shared 0
 289#define XENMEM_resource_grant_table_id_status 1
 290
 291        /* IN/OUT - As an IN parameter number of frames of the resource
 292         *          to be mapped. However, if the specified value is 0 and
 293         *          frame_list is NULL then this field will be set to the
 294         *          maximum value supported by the implementation on return.
 295         */
 296        u32 nr_frames;
 297        /*
 298         * OUT - Must be zero on entry. On return this may contain a bitwise
 299         *       OR of the following values.
 300         */
 301        u32 flags;
 302
 303        /* The resource pages have been assigned to the calling domain */
 304#define _XENMEM_rsrc_acq_caller_owned 0
 305#define XENMEM_rsrc_acq_caller_owned (1u << _XENMEM_rsrc_acq_caller_owned)
 306
 307        /*
 308         * IN - the index of the initial frame to be mapped. This parameter
 309         *      is ignored if nr_frames is 0.
 310         */
 311        u64 frame;
 312
 313#define XENMEM_resource_ioreq_server_frame_bufioreq 0
 314#define XENMEM_resource_ioreq_server_frame_ioreq(n) (1 + (n))
 315
 316        /*
 317         * IN/OUT - If the tools domain is PV then, upon return, frame_list
 318         *          will be populated with the MFNs of the resource.
 319         *          If the tools domain is HVM then it is expected that, on
 320         *          entry, frame_list will be populated with a list of GFNs
 321         *          that will be mapped to the MFNs of the resource.
 322         *          If -EIO is returned then the frame_list has only been
 323         *          partially mapped and it is up to the caller to unmap all
 324         *          the GFNs.
 325         *          This parameter may be NULL if nr_frames is 0.
 326         */
 327        GUEST_HANDLE(xen_pfn_t)frame_list;
 328};
 329
 330DEFINE_GUEST_HANDLE_STRUCT(xen_mem_acquire_resource);
 331
 332#endif /* __XEN_PUBLIC_MEMORY_H__ */
 333