aboutsummaryrefslogtreecommitdiffstats
path: root/include/xen/interface
diff options
context:
space:
mode:
authorJeremy Fitzhardinge <jeremy@xensource.com>2007-07-17 21:37:06 -0400
committerJeremy Fitzhardinge <jeremy@goop.org>2007-07-18 11:47:44 -0400
commitad9a86121f5a374b48ce2924f8a9d7e94a04db27 (patch)
treec14af462957ce9ee6de3e4537e15879c25a679aa /include/xen/interface
parentb536b4b9623084d86f2b1f19cb44a2d6d74f00bf (diff)
xen: Add grant table support
Add Xen 'grant table' driver which allows granting of access to selected local memory pages by other virtual machines and, symmetrically, the mapping of remote memory pages which other virtual machines have granted access to. This driver is a prerequisite for many of the Xen virtual device drivers, which grant the 'device driver domain' restricted and temporary access to only those memory pages that are currently involved in I/O operations. Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com> Signed-off-by: Ian Pratt <ian.pratt@xensource.com> Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk> Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Diffstat (limited to 'include/xen/interface')
-rw-r--r--include/xen/interface/grant_table.h94
1 files changed, 84 insertions, 10 deletions
diff --git a/include/xen/interface/grant_table.h b/include/xen/interface/grant_table.h
index e9e06695ed52..219049802cf2 100644
--- a/include/xen/interface/grant_table.h
+++ b/include/xen/interface/grant_table.h
@@ -4,6 +4,24 @@
4 * Interface for granting foreign access to page frames, and receiving 4 * Interface for granting foreign access to page frames, and receiving
5 * page-ownership transfers. 5 * page-ownership transfers.
6 * 6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to
9 * deal in the Software without restriction, including without limitation the
10 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
11 * sell copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
24 *
7 * Copyright (c) 2004, K A Fraser 25 * Copyright (c) 2004, K A Fraser
8 */ 26 */
9 27
@@ -17,7 +35,7 @@
17 35
18/* Some rough guidelines on accessing and updating grant-table entries 36/* Some rough guidelines on accessing and updating grant-table entries
19 * in a concurrency-safe manner. For more information, Linux contains a 37 * in a concurrency-safe manner. For more information, Linux contains a
20 * reference implementation for guest OSes (arch/i386/mach-xen/grant_table.c). 38 * reference implementation for guest OSes (arch/xen/kernel/grant_table.c).
21 * 39 *
22 * NB. WMB is a no-op on current-generation x86 processors. However, a 40 * NB. WMB is a no-op on current-generation x86 processors. However, a
23 * compiler barrier will still be required. 41 * compiler barrier will still be required.
@@ -144,9 +162,9 @@ typedef uint32_t grant_handle_t;
144 * that must be presented later to destroy the mapping(s). On error, <handle> 162 * that must be presented later to destroy the mapping(s). On error, <handle>
145 * is a negative status code. 163 * is a negative status code.
146 * NOTES: 164 * NOTES:
147 * 1. If GNTPIN_map_for_dev is specified then <dev_bus_addr> is the address 165 * 1. If GNTMAP_device_map is specified then <dev_bus_addr> is the address
148 * via which I/O devices may access the granted frame. 166 * via which I/O devices may access the granted frame.
149 * 2. If GNTPIN_map_for_host is specified then a mapping will be added at 167 * 2. If GNTMAP_host_map is specified then a mapping will be added at
150 * either a host virtual address in the current address space, or at 168 * either a host virtual address in the current address space, or at
151 * a PTE at the specified machine address. The type of mapping to 169 * a PTE at the specified machine address. The type of mapping to
152 * perform is selected through the GNTMAP_contains_pte flag, and the 170 * perform is selected through the GNTMAP_contains_pte flag, and the
@@ -167,7 +185,6 @@ struct gnttab_map_grant_ref {
167 grant_handle_t handle; 185 grant_handle_t handle;
168 uint64_t dev_bus_addr; 186 uint64_t dev_bus_addr;
169}; 187};
170DEFINE_GUEST_HANDLE_STRUCT(gnttab_map_grant_ref);
171 188
172/* 189/*
173 * GNTTABOP_unmap_grant_ref: Destroy one or more grant-reference mappings 190 * GNTTABOP_unmap_grant_ref: Destroy one or more grant-reference mappings
@@ -189,7 +206,6 @@ struct gnttab_unmap_grant_ref {
189 /* OUT parameters. */ 206 /* OUT parameters. */
190 int16_t status; /* GNTST_* */ 207 int16_t status; /* GNTST_* */
191}; 208};
192DEFINE_GUEST_HANDLE_STRUCT(gnttab_unmap_grant_ref);
193 209
194/* 210/*
195 * GNTTABOP_setup_table: Set up a grant table for <dom> comprising at least 211 * GNTTABOP_setup_table: Set up a grant table for <dom> comprising at least
@@ -207,9 +223,8 @@ struct gnttab_setup_table {
207 uint32_t nr_frames; 223 uint32_t nr_frames;
208 /* OUT parameters. */ 224 /* OUT parameters. */
209 int16_t status; /* GNTST_* */ 225 int16_t status; /* GNTST_* */
210 GUEST_HANDLE(ulong) frame_list; 226 ulong *frame_list;
211}; 227};
212DEFINE_GUEST_HANDLE_STRUCT(gnttab_setup_table);
213 228
214/* 229/*
215 * GNTTABOP_dump_table: Dump the contents of the grant table to the 230 * GNTTABOP_dump_table: Dump the contents of the grant table to the
@@ -222,7 +237,6 @@ struct gnttab_dump_table {
222 /* OUT parameters. */ 237 /* OUT parameters. */
223 int16_t status; /* GNTST_* */ 238 int16_t status; /* GNTST_* */
224}; 239};
225DEFINE_GUEST_HANDLE_STRUCT(gnttab_dump_table);
226 240
227/* 241/*
228 * GNTTABOP_transfer_grant_ref: Transfer <frame> to a foreign domain. The 242 * GNTTABOP_transfer_grant_ref: Transfer <frame> to a foreign domain. The
@@ -241,7 +255,65 @@ struct gnttab_transfer {
241 /* OUT parameters. */ 255 /* OUT parameters. */
242 int16_t status; 256 int16_t status;
243}; 257};
244DEFINE_GUEST_HANDLE_STRUCT(gnttab_transfer); 258
259
260/*
261 * GNTTABOP_copy: Hypervisor based copy
262 * source and destinations can be eithers MFNs or, for foreign domains,
263 * grant references. the foreign domain has to grant read/write access
264 * in its grant table.
265 *
266 * The flags specify what type source and destinations are (either MFN
267 * or grant reference).
268 *
269 * Note that this can also be used to copy data between two domains
270 * via a third party if the source and destination domains had previously
271 * grant appropriate access to their pages to the third party.
272 *
273 * source_offset specifies an offset in the source frame, dest_offset
274 * the offset in the target frame and len specifies the number of
275 * bytes to be copied.
276 */
277
278#define _GNTCOPY_source_gref (0)
279#define GNTCOPY_source_gref (1<<_GNTCOPY_source_gref)
280#define _GNTCOPY_dest_gref (1)
281#define GNTCOPY_dest_gref (1<<_GNTCOPY_dest_gref)
282
283#define GNTTABOP_copy 5
284struct gnttab_copy {
285 /* IN parameters. */
286 struct {
287 union {
288 grant_ref_t ref;
289 unsigned long gmfn;
290 } u;
291 domid_t domid;
292 uint16_t offset;
293 } source, dest;
294 uint16_t len;
295 uint16_t flags; /* GNTCOPY_* */
296 /* OUT parameters. */
297 int16_t status;
298};
299
300/*
301 * GNTTABOP_query_size: Query the current and maximum sizes of the shared
302 * grant table.
303 * NOTES:
304 * 1. <dom> may be specified as DOMID_SELF.
305 * 2. Only a sufficiently-privileged domain may specify <dom> != DOMID_SELF.
306 */
307#define GNTTABOP_query_size 6
308struct gnttab_query_size {
309 /* IN parameters. */
310 domid_t dom;
311 /* OUT parameters. */
312 uint32_t nr_frames;
313 uint32_t max_nr_frames;
314 int16_t status; /* GNTST_* */
315};
316
245 317
246/* 318/*
247 * Bitfield values for update_pin_status.flags. 319 * Bitfield values for update_pin_status.flags.
@@ -284,6 +356,7 @@ DEFINE_GUEST_HANDLE_STRUCT(gnttab_transfer);
284#define GNTST_no_device_space (-7) /* Out of space in I/O MMU. */ 356#define GNTST_no_device_space (-7) /* Out of space in I/O MMU. */
285#define GNTST_permission_denied (-8) /* Not enough privilege for operation. */ 357#define GNTST_permission_denied (-8) /* Not enough privilege for operation. */
286#define GNTST_bad_page (-9) /* Specified page was invalid for op. */ 358#define GNTST_bad_page (-9) /* Specified page was invalid for op. */
359#define GNTST_bad_copy_arg (-10) /* copy arguments cross page boundary */
287 360
288#define GNTTABOP_error_msgs { \ 361#define GNTTABOP_error_msgs { \
289 "okay", \ 362 "okay", \
@@ -295,7 +368,8 @@ DEFINE_GUEST_HANDLE_STRUCT(gnttab_transfer);
295 "invalid device address", \ 368 "invalid device address", \
296 "no spare translation slot in the I/O MMU", \ 369 "no spare translation slot in the I/O MMU", \
297 "permission denied", \ 370 "permission denied", \
298 "bad page" \ 371 "bad page", \
372 "copy arguments cross page boundary" \
299} 373}
300 374
301#endif /* __XEN_PUBLIC_GRANT_TABLE_H__ */ 375#endif /* __XEN_PUBLIC_GRANT_TABLE_H__ */