| 
									
										
										
										
											2007-07-17 18:37:04 -07:00
										 |  |  | /******************************************************************************
 | 
					
						
							|  |  |  |  * memory.h | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Memory reservation and information. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Copyright (c) 2005, Keir Fraser <keir@xensource.com> | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef __XEN_PUBLIC_MEMORY_H__
 | 
					
						
							|  |  |  | #define __XEN_PUBLIC_MEMORY_H__
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-09 12:05:46 -08:00
										 |  |  | #include <linux/spinlock.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-07-17 18:37:04 -07:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Increase or decrease the specified domain's memory reservation. Returns a | 
					
						
							|  |  |  |  * -ve errcode on failure, or the # extents successfully allocated or freed. | 
					
						
							|  |  |  |  * arg == addr of struct xen_memory_reservation. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #define XENMEM_increase_reservation 0
 | 
					
						
							|  |  |  | #define XENMEM_decrease_reservation 1
 | 
					
						
							|  |  |  | #define XENMEM_populate_physmap     6
 | 
					
						
							|  |  |  | struct xen_memory_reservation { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /*
 | 
					
						
							|  |  |  |      * XENMEM_increase_reservation: | 
					
						
							|  |  |  |      *   OUT: MFN (*not* GMFN) bases of extents that were allocated | 
					
						
							|  |  |  |      * XENMEM_decrease_reservation: | 
					
						
							|  |  |  |      *   IN:  GMFN bases of extents to free | 
					
						
							|  |  |  |      * XENMEM_populate_physmap: | 
					
						
							|  |  |  |      *   IN:  GPFN bases of extents to populate with memory | 
					
						
							|  |  |  |      *   OUT: GMFN bases of extents that were allocated | 
					
						
							|  |  |  |      *   (NB. This command also updates the mach_to_phys translation table) | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2012-08-22 17:20:14 +01:00
										 |  |  |     GUEST_HANDLE(xen_pfn_t) extent_start; | 
					
						
							| 
									
										
										
										
											2007-07-17 18:37:04 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /* Number of extents, and size/alignment of each (2^extent_order pages). */ | 
					
						
							| 
									
										
										
										
											2012-09-14 13:34:43 +00:00
										 |  |  |     xen_ulong_t  nr_extents; | 
					
						
							| 
									
										
										
										
											2007-07-17 18:37:04 -07:00
										 |  |  |     unsigned int   extent_order; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /*
 | 
					
						
							|  |  |  |      * Maximum # bits addressable by the user of the allocated region (e.g., | 
					
						
							|  |  |  |      * I/O devices often have a 32-bit limitation even in 64-bit systems). If | 
					
						
							|  |  |  |      * zero then the user has no addressing restriction. | 
					
						
							|  |  |  |      * This field is not used by XENMEM_decrease_reservation. | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     unsigned int   address_bits; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /*
 | 
					
						
							|  |  |  |      * Domain whose reservation is being changed. | 
					
						
							|  |  |  |      * Unprivileged domains can specify only DOMID_SELF. | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     domid_t        domid; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2008-05-26 23:31:15 +01:00
										 |  |  | DEFINE_GUEST_HANDLE_STRUCT(xen_memory_reservation); | 
					
						
							| 
									
										
										
										
											2007-07-17 18:37:04 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-09 12:05:46 -08:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * An atomic exchange of memory pages. If return code is zero then | 
					
						
							|  |  |  |  * @out.extent_list provides GMFNs of the newly-allocated memory. | 
					
						
							|  |  |  |  * Returns zero on complete success, otherwise a negative error code. | 
					
						
							|  |  |  |  * On complete success then always @nr_exchanged == @in.nr_extents. | 
					
						
							|  |  |  |  * On partial success @nr_exchanged indicates how much work was done. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #define XENMEM_exchange             11
 | 
					
						
							|  |  |  | struct xen_memory_exchange { | 
					
						
							|  |  |  |     /*
 | 
					
						
							|  |  |  |      * [IN] Details of memory extents to be exchanged (GMFN bases). | 
					
						
							|  |  |  |      * Note that @in.address_bits is ignored and unused. | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     struct xen_memory_reservation in; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /*
 | 
					
						
							|  |  |  |      * [IN/OUT] Details of new memory extents. | 
					
						
							|  |  |  |      * We require that: | 
					
						
							|  |  |  |      *  1. @in.domid == @out.domid | 
					
						
							|  |  |  |      *  2. @in.nr_extents  << @in.extent_order == | 
					
						
							|  |  |  |      *     @out.nr_extents << @out.extent_order | 
					
						
							|  |  |  |      *  3. @in.extent_start and @out.extent_start lists must not overlap | 
					
						
							|  |  |  |      *  4. @out.extent_start lists GPFN bases to be populated | 
					
						
							|  |  |  |      *  5. @out.extent_start is overwritten with allocated GMFN bases | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     struct xen_memory_reservation out; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /*
 | 
					
						
							|  |  |  |      * [OUT] Number of input extents that were successfully exchanged: | 
					
						
							|  |  |  |      *  1. The first @nr_exchanged input extents were successfully | 
					
						
							|  |  |  |      *     deallocated. | 
					
						
							|  |  |  |      *  2. The corresponding first entries in the output extent list correctly | 
					
						
							|  |  |  |      *     indicate the GMFNs that were successfully exchanged. | 
					
						
							|  |  |  |      *  3. All other input and output extents are untouched. | 
					
						
							|  |  |  |      *  4. If not all input exents are exchanged then the return code of this | 
					
						
							|  |  |  |      *     command will be non-zero. | 
					
						
							|  |  |  |      *  5. THIS FIELD MUST BE INITIALISED TO ZERO BY THE CALLER! | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2012-09-14 13:34:43 +00:00
										 |  |  |     xen_ulong_t nr_exchanged; | 
					
						
							| 
									
										
										
										
											2009-02-09 12:05:46 -08:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | DEFINE_GUEST_HANDLE_STRUCT(xen_memory_exchange); | 
					
						
							| 
									
										
										
										
											2007-07-17 18:37:04 -07:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Returns the maximum machine frame number of mapped RAM in this system. | 
					
						
							|  |  |  |  * This command always succeeds (it never returns an error code). | 
					
						
							|  |  |  |  * arg == NULL. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #define XENMEM_maximum_ram_page     2
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * Returns the current or maximum memory reservation, in pages, of the | 
					
						
							|  |  |  |  * specified domain (may be DOMID_SELF). Returns -ve errcode on failure. | 
					
						
							|  |  |  |  * arg == addr of domid_t. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #define XENMEM_current_reservation  3
 | 
					
						
							|  |  |  | #define XENMEM_maximum_reservation  4
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * Returns a list of MFN bases of 2MB extents comprising the machine_to_phys | 
					
						
							|  |  |  |  * mapping table. Architectures which do not have a m2p table do not implement | 
					
						
							|  |  |  |  * this command. | 
					
						
							|  |  |  |  * arg == addr of xen_machphys_mfn_list_t. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #define XENMEM_machphys_mfn_list    5
 | 
					
						
							|  |  |  | struct xen_machphys_mfn_list { | 
					
						
							|  |  |  |     /*
 | 
					
						
							|  |  |  |      * Size of the 'extent_start' array. Fewer entries will be filled if the | 
					
						
							|  |  |  |      * machphys table is smaller than max_extents * 2MB. | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     unsigned int max_extents; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /*
 | 
					
						
							|  |  |  |      * Pointer to buffer to fill with list of extent starts. If there are | 
					
						
							|  |  |  |      * any large discontiguities in the machine address space, 2MB gaps in | 
					
						
							|  |  |  |      * the machphys table will be represented by an MFN base of zero. | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2012-08-22 17:20:14 +01:00
										 |  |  |     GUEST_HANDLE(xen_pfn_t) extent_start; | 
					
						
							| 
									
										
										
										
											2007-07-17 18:37:04 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /*
 | 
					
						
							|  |  |  |      * Number of extents written to the above array. This will be smaller | 
					
						
							|  |  |  |      * than 'max_extents' if the machphys table is smaller than max_e * 2MB. | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     unsigned int nr_extents; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2008-05-26 23:31:15 +01:00
										 |  |  | DEFINE_GUEST_HANDLE_STRUCT(xen_machphys_mfn_list); | 
					
						
							| 
									
										
										
										
											2007-07-17 18:37:04 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-30 12:37:26 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Returns the location in virtual address space of the machine_to_phys | 
					
						
							|  |  |  |  * mapping table. Architectures which do not have a m2p table, or which do not | 
					
						
							|  |  |  |  * map it by default into guest address space, do not implement this command. | 
					
						
							|  |  |  |  * arg == addr of xen_machphys_mapping_t. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #define XENMEM_machphys_mapping     12
 | 
					
						
							|  |  |  | struct xen_machphys_mapping { | 
					
						
							| 
									
										
										
										
											2012-09-14 13:34:43 +00:00
										 |  |  |     xen_ulong_t v_start, v_end; /* Start and end virtual addresses.   */ | 
					
						
							|  |  |  |     xen_ulong_t max_mfn;        /* Maximum MFN that can be looked up. */ | 
					
						
							| 
									
										
										
										
											2010-09-30 12:37:26 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | DEFINE_GUEST_HANDLE_STRUCT(xen_machphys_mapping_t); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-03 16:37:09 +01:00
										 |  |  | #define XENMAPSPACE_shared_info  0 /* shared info page */
 | 
					
						
							|  |  |  | #define XENMAPSPACE_grant_table  1 /* grant table page */
 | 
					
						
							|  |  |  | #define XENMAPSPACE_gmfn         2 /* GMFN */
 | 
					
						
							|  |  |  | #define XENMAPSPACE_gmfn_range   3 /* GMFN range, XENMEM_add_to_physmap only. */
 | 
					
						
							|  |  |  | #define XENMAPSPACE_gmfn_foreign 4 /* GMFN from another dom,
 | 
					
						
							|  |  |  | 				    * XENMEM_add_to_physmap_range only. | 
					
						
							|  |  |  | 				    */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-07-17 18:37:04 -07:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Sets the GPFN at which a particular page appears in the specified guest's | 
					
						
							|  |  |  |  * pseudophysical address space. | 
					
						
							|  |  |  |  * arg == addr of xen_add_to_physmap_t. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #define XENMEM_add_to_physmap      7
 | 
					
						
							|  |  |  | struct xen_add_to_physmap { | 
					
						
							|  |  |  |     /* Which domain to change the mapping for. */ | 
					
						
							|  |  |  |     domid_t domid; | 
					
						
							| 
									
										
										
										
											2012-08-06 15:27:24 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /* Number of pages to go through for gmfn_range */ | 
					
						
							|  |  |  |     uint16_t    size; | 
					
						
							| 
									
										
										
										
											2007-07-17 18:37:04 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /* Source mapping space. */ | 
					
						
							|  |  |  |     unsigned int space; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* Index into source mapping space. */ | 
					
						
							| 
									
										
										
										
											2012-09-14 13:34:43 +00:00
										 |  |  |     xen_ulong_t idx; | 
					
						
							| 
									
										
										
										
											2007-07-17 18:37:04 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /* GPFN where the source mapping page should appear. */ | 
					
						
							| 
									
										
										
										
											2012-08-22 17:20:14 +01:00
										 |  |  |     xen_pfn_t gpfn; | 
					
						
							| 
									
										
										
										
											2007-07-17 18:37:04 -07:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2008-05-26 23:31:15 +01:00
										 |  |  | DEFINE_GUEST_HANDLE_STRUCT(xen_add_to_physmap); | 
					
						
							| 
									
										
										
										
											2007-07-17 18:37:04 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-17 09:39:13 +01:00
										 |  |  | /*** REMOVED ***/ | 
					
						
							|  |  |  | /*#define XENMEM_translate_gpfn_list  8*/ | 
					
						
							| 
									
										
										
										
											2007-07-17 18:37:04 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-03 16:37:09 +01:00
										 |  |  | #define XENMEM_add_to_physmap_range 23
 | 
					
						
							|  |  |  | struct xen_add_to_physmap_range { | 
					
						
							| 
									
										
										
										
											2013-02-19 22:00:58 -05:00
										 |  |  |     /* IN */ | 
					
						
							| 
									
										
										
										
											2012-10-03 16:37:09 +01:00
										 |  |  |     /* Which domain to change the mapping for. */ | 
					
						
							|  |  |  |     domid_t domid; | 
					
						
							|  |  |  |     uint16_t space; /* => enum phys_map_space */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* Number of pages to go through */ | 
					
						
							|  |  |  |     uint16_t size; | 
					
						
							|  |  |  |     domid_t foreign_domid; /* IFF gmfn_foreign */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* Indexes into space being mapped. */ | 
					
						
							|  |  |  |     GUEST_HANDLE(xen_ulong_t) idxs; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* GPFN in domid where the source mapping page should appear. */ | 
					
						
							|  |  |  |     GUEST_HANDLE(xen_pfn_t) gpfns; | 
					
						
							| 
									
										
										
										
											2013-02-19 22:00:58 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /* OUT */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* Per index error code. */ | 
					
						
							|  |  |  |     GUEST_HANDLE(int) errs; | 
					
						
							| 
									
										
										
										
											2012-10-03 16:37:09 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | DEFINE_GUEST_HANDLE_STRUCT(xen_add_to_physmap_range); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-06 19:09:48 -08:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Returns the pseudo-physical memory map as it was when the domain | 
					
						
							|  |  |  |  * was started (specified by XENMEM_set_memory_map). | 
					
						
							|  |  |  |  * arg == addr of struct xen_memory_map. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #define XENMEM_memory_map           9
 | 
					
						
							|  |  |  | struct xen_memory_map { | 
					
						
							|  |  |  |     /*
 | 
					
						
							|  |  |  |      * On call the number of entries which can be stored in buffer. On | 
					
						
							|  |  |  |      * return the number of entries which have been stored in | 
					
						
							|  |  |  |      * buffer. | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     unsigned int nr_entries; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /*
 | 
					
						
							|  |  |  |      * Entries in the buffer are in the same format as returned by the | 
					
						
							|  |  |  |      * BIOS INT 0x15 EAX=0xE820 call. | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     GUEST_HANDLE(void) buffer; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | DEFINE_GUEST_HANDLE_STRUCT(xen_memory_map); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * Returns the real physical memory map. Passes the same structure as | 
					
						
							|  |  |  |  * XENMEM_memory_map. | 
					
						
							|  |  |  |  * arg == addr of struct xen_memory_map. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #define XENMEM_machine_memory_map   10
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-09 12:05:46 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * Prevent the balloon driver from changing the memory reservation | 
					
						
							|  |  |  |  * during a driver critical region. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | extern spinlock_t xen_reservation_lock; | 
					
						
							| 
									
										
										
										
											2012-10-03 16:37:09 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * Unmaps the page appearing at a particular GPFN from the specified guest's | 
					
						
							|  |  |  |  * pseudophysical address space. | 
					
						
							|  |  |  |  * arg == addr of xen_remove_from_physmap_t. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #define XENMEM_remove_from_physmap      15
 | 
					
						
							|  |  |  | struct xen_remove_from_physmap { | 
					
						
							|  |  |  |     /* Which domain to change the mapping for. */ | 
					
						
							|  |  |  |     domid_t domid; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* GPFN of the current mapping of the page. */ | 
					
						
							|  |  |  |     xen_pfn_t gpfn; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | DEFINE_GUEST_HANDLE_STRUCT(xen_remove_from_physmap); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-07-17 18:37:04 -07:00
										 |  |  | #endif /* __XEN_PUBLIC_MEMORY_H__ */
 |