blob: e6adce6bc75c9c2c1ec7e51b96a65f64de4b91d4 [file] [log] [blame]
Jeremy Fitzhardingea42089d2007-07-17 18:37:04 -07001/******************************************************************************
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
Alex Nixon19001c82009-02-09 12:05:46 -080012#include <linux/spinlock.h>
13
Jeremy Fitzhardingea42089d2007-07-17 18:37:04 -070014/*
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 */
Isaku Yamahatabfdab122008-05-26 23:31:15 +010034 GUEST_HANDLE(ulong) extent_start;
Jeremy Fitzhardingea42089d2007-07-17 18:37:04 -070035
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};
Isaku Yamahatabfdab122008-05-26 23:31:15 +010055DEFINE_GUEST_HANDLE_STRUCT(xen_memory_reservation);
Jeremy Fitzhardingea42089d2007-07-17 18:37:04 -070056
57/*
58 * Returns the maximum machine frame number of mapped RAM in this system.
59 * This command always succeeds (it never returns an error code).
60 * arg == NULL.
61 */
62#define XENMEM_maximum_ram_page 2
63
64/*
65 * Returns the current or maximum memory reservation, in pages, of the
66 * specified domain (may be DOMID_SELF). Returns -ve errcode on failure.
67 * arg == addr of domid_t.
68 */
69#define XENMEM_current_reservation 3
70#define XENMEM_maximum_reservation 4
71
72/*
73 * Returns a list of MFN bases of 2MB extents comprising the machine_to_phys
74 * mapping table. Architectures which do not have a m2p table do not implement
75 * this command.
76 * arg == addr of xen_machphys_mfn_list_t.
77 */
78#define XENMEM_machphys_mfn_list 5
79struct xen_machphys_mfn_list {
80 /*
81 * Size of the 'extent_start' array. Fewer entries will be filled if the
82 * machphys table is smaller than max_extents * 2MB.
83 */
84 unsigned int max_extents;
85
86 /*
87 * Pointer to buffer to fill with list of extent starts. If there are
88 * any large discontiguities in the machine address space, 2MB gaps in
89 * the machphys table will be represented by an MFN base of zero.
90 */
Isaku Yamahatabfdab122008-05-26 23:31:15 +010091 GUEST_HANDLE(ulong) extent_start;
Jeremy Fitzhardingea42089d2007-07-17 18:37:04 -070092
93 /*
94 * Number of extents written to the above array. This will be smaller
95 * than 'max_extents' if the machphys table is smaller than max_e * 2MB.
96 */
97 unsigned int nr_extents;
98};
Isaku Yamahatabfdab122008-05-26 23:31:15 +010099DEFINE_GUEST_HANDLE_STRUCT(xen_machphys_mfn_list);
Jeremy Fitzhardingea42089d2007-07-17 18:37:04 -0700100
101/*
102 * Sets the GPFN at which a particular page appears in the specified guest's
103 * pseudophysical address space.
104 * arg == addr of xen_add_to_physmap_t.
105 */
106#define XENMEM_add_to_physmap 7
107struct xen_add_to_physmap {
108 /* Which domain to change the mapping for. */
109 domid_t domid;
110
111 /* Source mapping space. */
112#define XENMAPSPACE_shared_info 0 /* shared info page */
113#define XENMAPSPACE_grant_table 1 /* grant table page */
114 unsigned int space;
115
116 /* Index into source mapping space. */
117 unsigned long idx;
118
119 /* GPFN where the source mapping page should appear. */
120 unsigned long gpfn;
121};
Isaku Yamahatabfdab122008-05-26 23:31:15 +0100122DEFINE_GUEST_HANDLE_STRUCT(xen_add_to_physmap);
Jeremy Fitzhardingea42089d2007-07-17 18:37:04 -0700123
124/*
125 * Translates a list of domain-specific GPFNs into MFNs. Returns a -ve error
126 * code on failure. This call only works for auto-translated guests.
127 */
128#define XENMEM_translate_gpfn_list 8
129struct xen_translate_gpfn_list {
130 /* Which domain to translate for? */
131 domid_t domid;
132
133 /* Length of list. */
134 unsigned long nr_gpfns;
135
136 /* List of GPFNs to translate. */
Isaku Yamahatabfdab122008-05-26 23:31:15 +0100137 GUEST_HANDLE(ulong) gpfn_list;
Jeremy Fitzhardingea42089d2007-07-17 18:37:04 -0700138
139 /*
140 * Output list to contain MFN translations. May be the same as the input
141 * list (in which case each input GPFN is overwritten with the output MFN).
142 */
Isaku Yamahatabfdab122008-05-26 23:31:15 +0100143 GUEST_HANDLE(ulong) mfn_list;
Jeremy Fitzhardingea42089d2007-07-17 18:37:04 -0700144};
Isaku Yamahatabfdab122008-05-26 23:31:15 +0100145DEFINE_GUEST_HANDLE_STRUCT(xen_translate_gpfn_list);
Jeremy Fitzhardingea42089d2007-07-17 18:37:04 -0700146
Alex Nixon19001c82009-02-09 12:05:46 -0800147
148/*
149 * Prevent the balloon driver from changing the memory reservation
150 * during a driver critical region.
151 */
152extern spinlock_t xen_reservation_lock;
Jeremy Fitzhardingea42089d2007-07-17 18:37:04 -0700153#endif /* __XEN_PUBLIC_MEMORY_H__ */