/******************************************************************************1* memory.h2*3* Memory reservation and information.4*5* Copyright (c) 2005, Keir Fraser <[email protected]>6*/78#ifndef __XEN_PUBLIC_MEMORY_H__9#define __XEN_PUBLIC_MEMORY_H__1011#include <linux/spinlock.h>1213/*14* Increase or decrease the specified domain's memory reservation. Returns a15* -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 019#define XENMEM_decrease_reservation 120#define XENMEM_populate_physmap 621struct xen_memory_reservation {2223/*24* XENMEM_increase_reservation:25* OUT: MFN (*not* GMFN) bases of extents that were allocated26* XENMEM_decrease_reservation:27* IN: GMFN bases of extents to free28* XENMEM_populate_physmap:29* IN: GPFN bases of extents to populate with memory30* OUT: GMFN bases of extents that were allocated31* (NB. This command also updates the mach_to_phys translation table)32*/33GUEST_HANDLE(ulong) extent_start;3435/* Number of extents, and size/alignment of each (2^extent_order pages). */36unsigned long nr_extents;37unsigned int extent_order;3839/*40* Maximum # bits addressable by the user of the allocated region (e.g.,41* I/O devices often have a 32-bit limitation even in 64-bit systems). If42* zero then the user has no addressing restriction.43* This field is not used by XENMEM_decrease_reservation.44*/45unsigned int address_bits;4647/*48* Domain whose reservation is being changed.49* Unprivileged domains can specify only DOMID_SELF.50*/51domid_t domid;5253};54DEFINE_GUEST_HANDLE_STRUCT(xen_memory_reservation);5556/*57* An atomic exchange of memory pages. If return code is zero then58* @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 1164struct 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*/69struct xen_memory_reservation in;7071/*72* [IN/OUT] Details of new memory extents.73* We require that:74* 1. @in.domid == @out.domid75* 2. @in.nr_extents << @in.extent_order ==76* @out.nr_extents << @out.extent_order77* 3. @in.extent_start and @out.extent_start lists must not overlap78* 4. @out.extent_start lists GPFN bases to be populated79* 5. @out.extent_start is overwritten with allocated GMFN bases80*/81struct xen_memory_reservation out;8283/*84* [OUT] Number of input extents that were successfully exchanged:85* 1. The first @nr_exchanged input extents were successfully86* deallocated.87* 2. The corresponding first entries in the output extent list correctly88* 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 this91* command will be non-zero.92* 5. THIS FIELD MUST BE INITIALISED TO ZERO BY THE CALLER!93*/94unsigned long nr_exchanged;95};9697DEFINE_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 2104105/*106* Returns the current or maximum memory reservation, in pages, of the107* specified domain (may be DOMID_SELF). Returns -ve errcode on failure.108* arg == addr of domid_t.109*/110#define XENMEM_current_reservation 3111#define XENMEM_maximum_reservation 4112113/*114* Returns a list of MFN bases of 2MB extents comprising the machine_to_phys115* mapping table. Architectures which do not have a m2p table do not implement116* this command.117* arg == addr of xen_machphys_mfn_list_t.118*/119#define XENMEM_machphys_mfn_list 5120struct xen_machphys_mfn_list {121/*122* Size of the 'extent_start' array. Fewer entries will be filled if the123* machphys table is smaller than max_extents * 2MB.124*/125unsigned int max_extents;126127/*128* Pointer to buffer to fill with list of extent starts. If there are129* any large discontiguities in the machine address space, 2MB gaps in130* the machphys table will be represented by an MFN base of zero.131*/132GUEST_HANDLE(ulong) extent_start;133134/*135* Number of extents written to the above array. This will be smaller136* than 'max_extents' if the machphys table is smaller than max_e * 2MB.137*/138unsigned int nr_extents;139};140DEFINE_GUEST_HANDLE_STRUCT(xen_machphys_mfn_list);141142/*143* Returns the location in virtual address space of the machine_to_phys144* mapping table. Architectures which do not have a m2p table, or which do not145* map it by default into guest address space, do not implement this command.146* arg == addr of xen_machphys_mapping_t.147*/148#define XENMEM_machphys_mapping 12149struct xen_machphys_mapping {150unsigned long v_start, v_end; /* Start and end virtual addresses. */151unsigned long max_mfn; /* Maximum MFN that can be looked up. */152};153DEFINE_GUEST_HANDLE_STRUCT(xen_machphys_mapping_t);154155/*156* Sets the GPFN at which a particular page appears in the specified guest's157* pseudophysical address space.158* arg == addr of xen_add_to_physmap_t.159*/160#define XENMEM_add_to_physmap 7161struct xen_add_to_physmap {162/* Which domain to change the mapping for. */163domid_t domid;164165/* Source mapping space. */166#define XENMAPSPACE_shared_info 0 /* shared info page */167#define XENMAPSPACE_grant_table 1 /* grant table page */168unsigned int space;169170/* Index into source mapping space. */171unsigned long idx;172173/* GPFN where the source mapping page should appear. */174unsigned long gpfn;175};176DEFINE_GUEST_HANDLE_STRUCT(xen_add_to_physmap);177178/*179* Translates a list of domain-specific GPFNs into MFNs. Returns a -ve error180* code on failure. This call only works for auto-translated guests.181*/182#define XENMEM_translate_gpfn_list 8183struct xen_translate_gpfn_list {184/* Which domain to translate for? */185domid_t domid;186187/* Length of list. */188unsigned long nr_gpfns;189190/* List of GPFNs to translate. */191GUEST_HANDLE(ulong) gpfn_list;192193/*194* Output list to contain MFN translations. May be the same as the input195* list (in which case each input GPFN is overwritten with the output MFN).196*/197GUEST_HANDLE(ulong) mfn_list;198};199DEFINE_GUEST_HANDLE_STRUCT(xen_translate_gpfn_list);200201/*202* Returns the pseudo-physical memory map as it was when the domain203* was started (specified by XENMEM_set_memory_map).204* arg == addr of struct xen_memory_map.205*/206#define XENMEM_memory_map 9207struct xen_memory_map {208/*209* On call the number of entries which can be stored in buffer. On210* return the number of entries which have been stored in211* buffer.212*/213unsigned int nr_entries;214215/*216* Entries in the buffer are in the same format as returned by the217* BIOS INT 0x15 EAX=0xE820 call.218*/219GUEST_HANDLE(void) buffer;220};221DEFINE_GUEST_HANDLE_STRUCT(xen_memory_map);222223/*224* Returns the real physical memory map. Passes the same structure as225* XENMEM_memory_map.226* arg == addr of struct xen_memory_map.227*/228#define XENMEM_machine_memory_map 10229230231/*232* Prevent the balloon driver from changing the memory reservation233* during a driver critical region.234*/235extern spinlock_t xen_reservation_lock;236#endif /* __XEN_PUBLIC_MEMORY_H__ */237238239