1 | /* $NetBSD: grant_table.h,v 1.6 2011/12/07 15:04:18 cegger Exp $ */ |
2 | /****************************************************************************** |
3 | * grant_table.h |
4 | * |
5 | * Interface for granting foreign access to page frames, and receiving |
6 | * page-ownership transfers. |
7 | * |
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
9 | * of this software and associated documentation files (the "Software"), to |
10 | * deal in the Software without restriction, including without limitation the |
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
12 | * sell copies of the Software, and to permit persons to whom the Software is |
13 | * furnished to do so, subject to the following conditions: |
14 | * |
15 | * The above copyright notice and this permission notice shall be included in |
16 | * all copies or substantial portions of the Software. |
17 | * |
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
24 | * DEALINGS IN THE SOFTWARE. |
25 | * |
26 | * Copyright (c) 2004, K A Fraser |
27 | */ |
28 | |
29 | #ifndef __XEN_PUBLIC_GRANT_TABLE_H__ |
30 | #define __XEN_PUBLIC_GRANT_TABLE_H__ |
31 | |
32 | #include "xen.h" |
33 | |
34 | /*********************************** |
35 | * GRANT TABLE REPRESENTATION |
36 | */ |
37 | |
38 | /* Some rough guidelines on accessing and updating grant-table entries |
39 | * in a concurrency-safe manner. For more information, Linux contains a |
40 | * reference implementation for guest OSes (arch/xen/kernel/grant_table.c). |
41 | * |
42 | * NB. WMB is a no-op on current-generation x86 processors. However, a |
43 | * compiler barrier will still be required. |
44 | * |
45 | * Introducing a valid entry into the grant table: |
46 | * 1. Write ent->domid. |
47 | * 2. Write ent->frame: |
48 | * GTF_permit_access: Frame to which access is permitted. |
49 | * GTF_accept_transfer: Pseudo-phys frame slot being filled by new |
50 | * frame, or zero if none. |
51 | * 3. Write memory barrier (WMB). |
52 | * 4. Write ent->flags, inc. valid type. |
53 | * |
54 | * Invalidating an unused GTF_permit_access entry: |
55 | * 1. flags = ent->flags. |
56 | * 2. Observe that !(flags & (GTF_reading|GTF_writing)). |
57 | * 3. Check result of SMP-safe CMPXCHG(&ent->flags, flags, 0). |
58 | * NB. No need for WMB as reuse of entry is control-dependent on success of |
59 | * step 3, and all architectures guarantee ordering of ctrl-dep writes. |
60 | * |
61 | * Invalidating an in-use GTF_permit_access entry: |
62 | * This cannot be done directly. Request assistance from the domain controller |
63 | * which can set a timeout on the use of a grant entry and take necessary |
64 | * action. (NB. This is not yet implemented!). |
65 | * |
66 | * Invalidating an unused GTF_accept_transfer entry: |
67 | * 1. flags = ent->flags. |
68 | * 2. Observe that !(flags & GTF_transfer_committed). [*] |
69 | * 3. Check result of SMP-safe CMPXCHG(&ent->flags, flags, 0). |
70 | * NB. No need for WMB as reuse of entry is control-dependent on success of |
71 | * step 3, and all architectures guarantee ordering of ctrl-dep writes. |
72 | * [*] If GTF_transfer_committed is set then the grant entry is 'committed'. |
73 | * The guest must /not/ modify the grant entry until the address of the |
74 | * transferred frame is written. It is safe for the guest to spin waiting |
75 | * for this to occur (detect by observing GTF_transfer_completed in |
76 | * ent->flags). |
77 | * |
78 | * Invalidating a committed GTF_accept_transfer entry: |
79 | * 1. Wait for (ent->flags & GTF_transfer_completed). |
80 | * |
81 | * Changing a GTF_permit_access from writable to read-only: |
82 | * Use SMP-safe CMPXCHG to set GTF_readonly, while checking !GTF_writing. |
83 | * |
84 | * Changing a GTF_permit_access from read-only to writable: |
85 | * Use SMP-safe bit-setting instruction. |
86 | */ |
87 | |
88 | /* |
89 | * Reference to a grant entry in a specified domain's grant table. |
90 | */ |
91 | typedef uint32_t grant_ref_t; |
92 | |
93 | /* |
94 | * A grant table comprises a packed array of grant entries in one or more |
95 | * page frames shared between Xen and a guest. |
96 | * [XEN]: This field is written by Xen and read by the sharing guest. |
97 | * [GST]: This field is written by the guest and read by Xen. |
98 | */ |
99 | |
100 | /* |
101 | * Version 1 of the grant table entry structure is maintained purely |
102 | * for backwards compatibility. New guests should use version 2. |
103 | */ |
104 | #if __XEN_INTERFACE_VERSION__ < 0x0003020a |
105 | #define grant_entry_v1 grant_entry |
106 | #define grant_entry_v1_t grant_entry_t |
107 | #endif |
108 | struct grant_entry_v1 { |
109 | /* GTF_xxx: various type and flag information. [XEN,GST] */ |
110 | uint16_t flags; |
111 | /* The domain being granted foreign privileges. [GST] */ |
112 | domid_t domid; |
113 | /* |
114 | * GTF_permit_access: Frame that @domid is allowed to map and access. [GST] |
115 | * GTF_accept_transfer: Frame whose ownership transferred by @domid. [XEN] |
116 | */ |
117 | uint32_t frame; |
118 | }; |
119 | typedef struct grant_entry_v1 grant_entry_v1_t; |
120 | |
121 | /* |
122 | * Type of grant entry. |
123 | * GTF_invalid: This grant entry grants no privileges. |
124 | * GTF_permit_access: Allow @domid to map/access @frame. |
125 | * GTF_accept_transfer: Allow @domid to transfer ownership of one page frame |
126 | * to this guest. Xen writes the page number to @frame. |
127 | * GTF_transitive: Allow @domid to transitively access a subrange of |
128 | * @trans_grant in @trans_domid. No mappings are allowed. |
129 | */ |
130 | #define GTF_invalid (0U<<0) |
131 | #define GTF_permit_access (1U<<0) |
132 | #define GTF_accept_transfer (2U<<0) |
133 | #define GTF_transitive (3U<<0) |
134 | #define GTF_type_mask (3U<<0) |
135 | |
136 | /* |
137 | * Subflags for GTF_permit_access. |
138 | * GTF_readonly: Restrict @domid to read-only mappings and accesses. [GST] |
139 | * GTF_reading: Grant entry is currently mapped for reading by @domid. [XEN] |
140 | * GTF_writing: Grant entry is currently mapped for writing by @domid. [XEN] |
141 | * GTF_PAT, GTF_PWT, GTF_PCD: (x86) cache attribute flags for the grant [GST] |
142 | * GTF_sub_page: Grant access to only a subrange of the page. @domid |
143 | * will only be allowed to copy from the grant, and not |
144 | * map it. [GST] |
145 | */ |
146 | #define _GTF_readonly (2) |
147 | #define GTF_readonly (1U<<_GTF_readonly) |
148 | #define _GTF_reading (3) |
149 | #define GTF_reading (1U<<_GTF_reading) |
150 | #define _GTF_writing (4) |
151 | #define GTF_writing (1U<<_GTF_writing) |
152 | #define _GTF_PWT (5) |
153 | #define GTF_PWT (1U<<_GTF_PWT) |
154 | #define _GTF_PCD (6) |
155 | #define GTF_PCD (1U<<_GTF_PCD) |
156 | #define _GTF_PAT (7) |
157 | #define GTF_PAT (1U<<_GTF_PAT) |
158 | #define _GTF_sub_page (8) |
159 | #define GTF_sub_page (1U<<_GTF_sub_page) |
160 | |
161 | /* |
162 | * Subflags for GTF_accept_transfer: |
163 | * GTF_transfer_committed: Xen sets this flag to indicate that it is committed |
164 | * to transferring ownership of a page frame. When a guest sees this flag |
165 | * it must /not/ modify the grant entry until GTF_transfer_completed is |
166 | * set by Xen. |
167 | * GTF_transfer_completed: It is safe for the guest to spin-wait on this flag |
168 | * after reading GTF_transfer_committed. Xen will always write the frame |
169 | * address, followed by ORing this flag, in a timely manner. |
170 | */ |
171 | #define _GTF_transfer_committed (2) |
172 | #define GTF_transfer_committed (1U<<_GTF_transfer_committed) |
173 | #define _GTF_transfer_completed (3) |
174 | #define GTF_transfer_completed (1U<<_GTF_transfer_completed) |
175 | |
176 | /* |
177 | * Version 2 grant table entries. These fulfil the same role as |
178 | * version 1 entries, but can represent more complicated operations. |
179 | * Any given domain will have either a version 1 or a version 2 table, |
180 | * and every entry in the table will be the same version. |
181 | * |
182 | * The interface by which domains use grant references does not depend |
183 | * on the grant table version in use by the other domain. |
184 | */ |
185 | #if __XEN_INTERFACE_VERSION__ >= 0x0003020a |
186 | /* |
187 | * Version 1 and version 2 grant entries share a common prefix. The |
188 | * fields of the prefix are documented as part of struct |
189 | * grant_entry_v1. |
190 | */ |
191 | struct grant_entry_header { |
192 | uint16_t flags; |
193 | domid_t domid; |
194 | }; |
195 | typedef struct grant_entry_header grant_entry_header_t; |
196 | |
197 | /* |
198 | * Version 2 of the grant entry structure. |
199 | */ |
200 | union grant_entry_v2 { |
201 | grant_entry_header_t hdr; |
202 | |
203 | /* |
204 | * This member is used for V1-style full page grants, where either: |
205 | * |
206 | * -- hdr.type is GTF_accept_transfer, or |
207 | * -- hdr.type is GTF_permit_access and GTF_sub_page is not set. |
208 | * |
209 | * In that case, the frame field has the same semantics as the |
210 | * field of the same name in the V1 entry structure. |
211 | */ |
212 | struct { |
213 | grant_entry_header_t hdr; |
214 | uint32_t pad0; |
215 | uint64_t frame; |
216 | } full_page; |
217 | |
218 | /* |
219 | * If the grant type is GTF_grant_access and GTF_sub_page is set, |
220 | * @domid is allowed to access bytes [@page_off,@page_off+@length) |
221 | * in frame @frame. |
222 | */ |
223 | struct { |
224 | grant_entry_header_t hdr; |
225 | uint16_t page_off; |
226 | uint16_t length; |
227 | uint64_t frame; |
228 | } sub_page; |
229 | |
230 | /* |
231 | * If the grant is GTF_transitive, @domid is allowed to use the |
232 | * grant @gref in domain @trans_domid, as if it was the local |
233 | * domain. Obviously, the transitive access must be compatible |
234 | * with the original grant. |
235 | * |
236 | * The current version of Xen does not allow transitive grants |
237 | * to be mapped. |
238 | */ |
239 | struct { |
240 | grant_entry_header_t hdr; |
241 | domid_t trans_domid; |
242 | uint16_t pad0; |
243 | grant_ref_t gref; |
244 | } transitive; |
245 | |
246 | uint32_t __spacer[4]; /* Pad to a power of two */ |
247 | }; |
248 | typedef union grant_entry_v2 grant_entry_v2_t; |
249 | |
250 | typedef uint16_t grant_status_t; |
251 | |
252 | #endif /* __XEN_INTERFACE_VERSION__ */ |
253 | |
254 | /*********************************** |
255 | * GRANT TABLE QUERIES AND USES |
256 | */ |
257 | |
258 | /* |
259 | * Handle to track a mapping created via a grant reference. |
260 | */ |
261 | typedef uint32_t grant_handle_t; |
262 | |
263 | /* |
264 | * GNTTABOP_map_grant_ref: Map the grant entry (<dom>,<ref>) for access |
265 | * by devices and/or host CPUs. If successful, <handle> is a tracking number |
266 | * that must be presented later to destroy the mapping(s). On error, <handle> |
267 | * is a negative status code. |
268 | * NOTES: |
269 | * 1. If GNTMAP_device_map is specified then <dev_bus_addr> is the address |
270 | * via which I/O devices may access the granted frame. |
271 | * 2. If GNTMAP_host_map is specified then a mapping will be added at |
272 | * either a host virtual address in the current address space, or at |
273 | * a PTE at the specified machine address. The type of mapping to |
274 | * perform is selected through the GNTMAP_contains_pte flag, and the |
275 | * address is specified in <host_addr>. |
276 | * 3. Mappings should only be destroyed via GNTTABOP_unmap_grant_ref. If a |
277 | * host mapping is destroyed by other means then it is *NOT* guaranteed |
278 | * to be accounted to the correct grant reference! |
279 | */ |
280 | #define GNTTABOP_map_grant_ref 0 |
281 | struct gnttab_map_grant_ref { |
282 | /* IN parameters. */ |
283 | uint64_t host_addr; |
284 | uint32_t flags; /* GNTMAP_* */ |
285 | grant_ref_t ref; |
286 | domid_t dom; |
287 | /* OUT parameters. */ |
288 | int16_t status; /* GNTST_* */ |
289 | grant_handle_t handle; |
290 | uint64_t dev_bus_addr; |
291 | }; |
292 | typedef struct gnttab_map_grant_ref gnttab_map_grant_ref_t; |
293 | DEFINE_XEN_GUEST_HANDLE(gnttab_map_grant_ref_t); |
294 | |
295 | /* |
296 | * GNTTABOP_unmap_grant_ref: Destroy one or more grant-reference mappings |
297 | * tracked by <handle>. If <host_addr> or <dev_bus_addr> is zero, that |
298 | * field is ignored. If non-zero, they must refer to a device/host mapping |
299 | * that is tracked by <handle> |
300 | * NOTES: |
301 | * 1. The call may fail in an undefined manner if either mapping is not |
302 | * tracked by <handle>. |
303 | * 3. After executing a batch of unmaps, it is guaranteed that no stale |
304 | * mappings will remain in the device or host TLBs. |
305 | */ |
306 | #define GNTTABOP_unmap_grant_ref 1 |
307 | struct gnttab_unmap_grant_ref { |
308 | /* IN parameters. */ |
309 | uint64_t host_addr; |
310 | uint64_t dev_bus_addr; |
311 | grant_handle_t handle; |
312 | /* OUT parameters. */ |
313 | int16_t status; /* GNTST_* */ |
314 | }; |
315 | typedef struct gnttab_unmap_grant_ref gnttab_unmap_grant_ref_t; |
316 | DEFINE_XEN_GUEST_HANDLE(gnttab_unmap_grant_ref_t); |
317 | |
318 | /* |
319 | * GNTTABOP_setup_table: Set up a grant table for <dom> comprising at least |
320 | * <nr_frames> pages. The frame addresses are written to the <frame_list>. |
321 | * Only <nr_frames> addresses are written, even if the table is larger. |
322 | * NOTES: |
323 | * 1. <dom> may be specified as DOMID_SELF. |
324 | * 2. Only a sufficiently-privileged domain may specify <dom> != DOMID_SELF. |
325 | * 3. Xen may not support more than a single grant-table page per domain. |
326 | */ |
327 | #define GNTTABOP_setup_table 2 |
328 | struct gnttab_setup_table { |
329 | /* IN parameters. */ |
330 | domid_t dom; |
331 | uint32_t nr_frames; |
332 | /* OUT parameters. */ |
333 | int16_t status; /* GNTST_* */ |
334 | XEN_GUEST_HANDLE(ulong) frame_list; |
335 | }; |
336 | typedef struct gnttab_setup_table gnttab_setup_table_t; |
337 | DEFINE_XEN_GUEST_HANDLE(gnttab_setup_table_t); |
338 | |
339 | /* |
340 | * GNTTABOP_dump_table: Dump the contents of the grant table to the |
341 | * xen console. Debugging use only. |
342 | */ |
343 | #define GNTTABOP_dump_table 3 |
344 | struct gnttab_dump_table { |
345 | /* IN parameters. */ |
346 | domid_t dom; |
347 | /* OUT parameters. */ |
348 | int16_t status; /* GNTST_* */ |
349 | }; |
350 | typedef struct gnttab_dump_table gnttab_dump_table_t; |
351 | DEFINE_XEN_GUEST_HANDLE(gnttab_dump_table_t); |
352 | |
353 | /* |
354 | * GNTTABOP_transfer_grant_ref: Transfer <frame> to a foreign domain. The |
355 | * foreign domain has previously registered its interest in the transfer via |
356 | * <domid, ref>. |
357 | * |
358 | * Note that, even if the transfer fails, the specified page no longer belongs |
359 | * to the calling domain *unless* the error is GNTST_bad_page. |
360 | */ |
361 | #define GNTTABOP_transfer 4 |
362 | struct gnttab_transfer { |
363 | /* IN parameters. */ |
364 | xen_pfn_t mfn; |
365 | domid_t domid; |
366 | grant_ref_t ref; |
367 | /* OUT parameters. */ |
368 | int16_t status; |
369 | }; |
370 | typedef struct gnttab_transfer gnttab_transfer_t; |
371 | DEFINE_XEN_GUEST_HANDLE(gnttab_transfer_t); |
372 | |
373 | |
374 | /* |
375 | * GNTTABOP_copy: Hypervisor based copy |
376 | * source and destinations can be eithers MFNs or, for foreign domains, |
377 | * grant references. the foreign domain has to grant read/write access |
378 | * in its grant table. |
379 | * |
380 | * The flags specify what type source and destinations are (either MFN |
381 | * or grant reference). |
382 | * |
383 | * Note that this can also be used to copy data between two domains |
384 | * via a third party if the source and destination domains had previously |
385 | * grant appropriate access to their pages to the third party. |
386 | * |
387 | * source_offset specifies an offset in the source frame, dest_offset |
388 | * the offset in the target frame and len specifies the number of |
389 | * bytes to be copied. |
390 | */ |
391 | |
392 | #define _GNTCOPY_source_gref (0) |
393 | #define GNTCOPY_source_gref (1<<_GNTCOPY_source_gref) |
394 | #define _GNTCOPY_dest_gref (1) |
395 | #define GNTCOPY_dest_gref (1<<_GNTCOPY_dest_gref) |
396 | #define _GNTCOPY_can_fail (2) |
397 | #define GNTCOPY_can_fail (1<<_GNTCOPY_can_fail) |
398 | |
399 | #define GNTTABOP_copy 5 |
400 | typedef struct gnttab_copy { |
401 | /* IN parameters. */ |
402 | struct { |
403 | union { |
404 | grant_ref_t ref; |
405 | xen_pfn_t gmfn; |
406 | } u; |
407 | domid_t domid; |
408 | uint16_t offset; |
409 | } source, dest; |
410 | uint16_t len; |
411 | uint16_t flags; /* GNTCOPY_* */ |
412 | /* OUT parameters. */ |
413 | int16_t status; |
414 | } gnttab_copy_t; |
415 | DEFINE_XEN_GUEST_HANDLE(gnttab_copy_t); |
416 | |
417 | /* |
418 | * GNTTABOP_query_size: Query the current and maximum sizes of the shared |
419 | * grant table. |
420 | * NOTES: |
421 | * 1. <dom> may be specified as DOMID_SELF. |
422 | * 2. Only a sufficiently-privileged domain may specify <dom> != DOMID_SELF. |
423 | */ |
424 | #define GNTTABOP_query_size 6 |
425 | struct gnttab_query_size { |
426 | /* IN parameters. */ |
427 | domid_t dom; |
428 | /* OUT parameters. */ |
429 | uint32_t nr_frames; |
430 | uint32_t max_nr_frames; |
431 | int16_t status; /* GNTST_* */ |
432 | }; |
433 | typedef struct gnttab_query_size gnttab_query_size_t; |
434 | DEFINE_XEN_GUEST_HANDLE(gnttab_query_size_t); |
435 | |
436 | /* |
437 | * GNTTABOP_unmap_and_replace: Destroy one or more grant-reference mappings |
438 | * tracked by <handle> but atomically replace the page table entry with one |
439 | * pointing to the machine address under <new_addr>. <new_addr> will be |
440 | * redirected to the null entry. |
441 | * NOTES: |
442 | * 1. The call may fail in an undefined manner if either mapping is not |
443 | * tracked by <handle>. |
444 | * 2. After executing a batch of unmaps, it is guaranteed that no stale |
445 | * mappings will remain in the device or host TLBs. |
446 | */ |
447 | #define GNTTABOP_unmap_and_replace 7 |
448 | struct gnttab_unmap_and_replace { |
449 | /* IN parameters. */ |
450 | uint64_t host_addr; |
451 | uint64_t new_addr; |
452 | grant_handle_t handle; |
453 | /* OUT parameters. */ |
454 | int16_t status; /* GNTST_* */ |
455 | }; |
456 | typedef struct gnttab_unmap_and_replace gnttab_unmap_and_replace_t; |
457 | DEFINE_XEN_GUEST_HANDLE(gnttab_unmap_and_replace_t); |
458 | |
459 | #if __XEN_INTERFACE_VERSION__ >= 0x0003020a |
460 | /* |
461 | * GNTTABOP_set_version: Request a particular version of the grant |
462 | * table shared table structure. This operation can only be performed |
463 | * once in any given domain. It must be performed before any grants |
464 | * are activated; otherwise, the domain will be stuck with version 1. |
465 | * The only defined versions are 1 and 2. |
466 | */ |
467 | #define GNTTABOP_set_version 8 |
468 | struct gnttab_set_version { |
469 | /* IN/OUT parameters */ |
470 | uint32_t version; |
471 | }; |
472 | typedef struct gnttab_set_version gnttab_set_version_t; |
473 | DEFINE_XEN_GUEST_HANDLE(gnttab_set_version_t); |
474 | |
475 | |
476 | /* |
477 | * GNTTABOP_get_status_frames: Get the list of frames used to store grant |
478 | * status for <dom>. In grant format version 2, the status is separated |
479 | * from the other shared grant fields to allow more efficient synchronization |
480 | * using barriers instead of atomic cmpexch operations. |
481 | * <nr_frames> specify the size of vector <frame_list>. |
482 | * The frame addresses are returned in the <frame_list>. |
483 | * Only <nr_frames> addresses are returned, even if the table is larger. |
484 | * NOTES: |
485 | * 1. <dom> may be specified as DOMID_SELF. |
486 | * 2. Only a sufficiently-privileged domain may specify <dom> != DOMID_SELF. |
487 | */ |
488 | #define GNTTABOP_get_status_frames 9 |
489 | struct gnttab_get_status_frames { |
490 | /* IN parameters. */ |
491 | uint32_t nr_frames; |
492 | domid_t dom; |
493 | /* OUT parameters. */ |
494 | int16_t status; /* GNTST_* */ |
495 | XEN_GUEST_HANDLE(uint64_t) frame_list; |
496 | }; |
497 | typedef struct gnttab_get_status_frames gnttab_get_status_frames_t; |
498 | DEFINE_XEN_GUEST_HANDLE(gnttab_get_status_frames_t); |
499 | |
500 | /* |
501 | * GNTTABOP_get_version: Get the grant table version which is in |
502 | * effect for domain <dom>. |
503 | */ |
504 | #define GNTTABOP_get_version 10 |
505 | struct gnttab_get_version { |
506 | /* IN parameters */ |
507 | domid_t dom; |
508 | uint16_t pad; |
509 | /* OUT parameters */ |
510 | uint32_t version; |
511 | }; |
512 | typedef struct gnttab_get_version gnttab_get_version_t; |
513 | DEFINE_XEN_GUEST_HANDLE(gnttab_get_version_t); |
514 | |
515 | #endif /* __XEN_INTERFACE_VERSION__ */ |
516 | |
517 | /* |
518 | * Bitfield values for gnttab_map_grant_ref.flags. |
519 | */ |
520 | /* Map the grant entry for access by I/O devices. */ |
521 | #define _GNTMAP_device_map (0) |
522 | #define GNTMAP_device_map (1<<_GNTMAP_device_map) |
523 | /* Map the grant entry for access by host CPUs. */ |
524 | #define _GNTMAP_host_map (1) |
525 | #define GNTMAP_host_map (1<<_GNTMAP_host_map) |
526 | /* Accesses to the granted frame will be restricted to read-only access. */ |
527 | #define _GNTMAP_readonly (2) |
528 | #define GNTMAP_readonly (1<<_GNTMAP_readonly) |
529 | /* |
530 | * GNTMAP_host_map subflag: |
531 | * 0 => The host mapping is usable only by the guest OS. |
532 | * 1 => The host mapping is usable by guest OS + current application. |
533 | */ |
534 | #define _GNTMAP_application_map (3) |
535 | #define GNTMAP_application_map (1<<_GNTMAP_application_map) |
536 | |
537 | /* |
538 | * GNTMAP_contains_pte subflag: |
539 | * 0 => This map request contains a host virtual address. |
540 | * 1 => This map request contains the machine addess of the PTE to update. |
541 | */ |
542 | #define _GNTMAP_contains_pte (4) |
543 | #define GNTMAP_contains_pte (1<<_GNTMAP_contains_pte) |
544 | |
545 | #define _GNTMAP_can_fail (5) |
546 | #define GNTMAP_can_fail (1<<_GNTMAP_can_fail) |
547 | |
548 | /* |
549 | * Bits to be placed in guest kernel available PTE bits (architecture |
550 | * dependent; only supported when XENFEAT_gnttab_map_avail_bits is set). |
551 | */ |
552 | #define _GNTMAP_guest_avail0 (16) |
553 | #define GNTMAP_guest_avail_mask ((uint32_t)~0 << _GNTMAP_guest_avail0) |
554 | |
555 | /* |
556 | * Values for error status returns. All errors are -ve. |
557 | */ |
558 | #define GNTST_okay (0) /* Normal return. */ |
559 | #define GNTST_general_error (-1) /* General undefined error. */ |
560 | #define GNTST_bad_domain (-2) /* Unrecognsed domain id. */ |
561 | #define GNTST_bad_gntref (-3) /* Unrecognised or inappropriate gntref. */ |
562 | #define GNTST_bad_handle (-4) /* Unrecognised or inappropriate handle. */ |
563 | #define GNTST_bad_virt_addr (-5) /* Inappropriate virtual address to map. */ |
564 | #define GNTST_bad_dev_addr (-6) /* Inappropriate device address to unmap.*/ |
565 | #define GNTST_no_device_space (-7) /* Out of space in I/O MMU. */ |
566 | #define GNTST_permission_denied (-8) /* Not enough privilege for operation. */ |
567 | #define GNTST_bad_page (-9) /* Specified page was invalid for op. */ |
568 | #define GNTST_bad_copy_arg (-10) /* copy arguments cross page boundary. */ |
569 | #define GNTST_address_too_big (-11) /* transfer page address too large. */ |
570 | #define GNTST_eagain (-12) /* Could not map at the moment. Retry. */ |
571 | |
572 | #define GNTTABOP_error_msgs { \ |
573 | "okay", \ |
574 | "undefined error", \ |
575 | "unrecognised domain id", \ |
576 | "invalid grant reference", \ |
577 | "invalid mapping handle", \ |
578 | "invalid virtual address", \ |
579 | "invalid device address", \ |
580 | "no spare translation slot in the I/O MMU", \ |
581 | "permission denied", \ |
582 | "bad page", \ |
583 | "copy arguments cross page boundary", \ |
584 | "page address size too large", \ |
585 | "could not map at the moment, retry" \ |
586 | } |
587 | |
588 | #endif /* __XEN_PUBLIC_GRANT_TABLE_H__ */ |
589 | |
590 | /* |
591 | * Local variables: |
592 | * mode: C |
593 | * c-set-style: "BSD" |
594 | * c-basic-offset: 4 |
595 | * tab-width: 4 |
596 | * indent-tabs-mode: nil |
597 | * End: |
598 | */ |
599 | |