15084Sjohnlev /****************************************************************************** 25084Sjohnlev * grant_table.h 35084Sjohnlev * 45084Sjohnlev * Interface for granting foreign access to page frames, and receiving 55084Sjohnlev * page-ownership transfers. 65084Sjohnlev * 75084Sjohnlev * Permission is hereby granted, free of charge, to any person obtaining a copy 85084Sjohnlev * of this software and associated documentation files (the "Software"), to 95084Sjohnlev * deal in the Software without restriction, including without limitation the 105084Sjohnlev * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 115084Sjohnlev * sell copies of the Software, and to permit persons to whom the Software is 125084Sjohnlev * furnished to do so, subject to the following conditions: 135084Sjohnlev * 145084Sjohnlev * The above copyright notice and this permission notice shall be included in 155084Sjohnlev * all copies or substantial portions of the Software. 165084Sjohnlev * 175084Sjohnlev * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 185084Sjohnlev * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 195084Sjohnlev * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 205084Sjohnlev * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 215084Sjohnlev * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 225084Sjohnlev * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 235084Sjohnlev * DEALINGS IN THE SOFTWARE. 245084Sjohnlev * 255084Sjohnlev * Copyright (c) 2004, K A Fraser 265084Sjohnlev */ 275084Sjohnlev 285084Sjohnlev #ifndef __XEN_PUBLIC_GRANT_TABLE_H__ 295084Sjohnlev #define __XEN_PUBLIC_GRANT_TABLE_H__ 305084Sjohnlev 315084Sjohnlev 325084Sjohnlev /*********************************** 335084Sjohnlev * GRANT TABLE REPRESENTATION 345084Sjohnlev */ 355084Sjohnlev 365084Sjohnlev /* Some rough guidelines on accessing and updating grant-table entries 375084Sjohnlev * in a concurrency-safe manner. For more information, Linux contains a 385084Sjohnlev * reference implementation for guest OSes (arch/xen/kernel/grant_table.c). 395084Sjohnlev * 405084Sjohnlev * NB. WMB is a no-op on current-generation x86 processors. However, a 415084Sjohnlev * compiler barrier will still be required. 425084Sjohnlev * 435084Sjohnlev * Introducing a valid entry into the grant table: 445084Sjohnlev * 1. Write ent->domid. 455084Sjohnlev * 2. Write ent->frame: 465084Sjohnlev * GTF_permit_access: Frame to which access is permitted. 475084Sjohnlev * GTF_accept_transfer: Pseudo-phys frame slot being filled by new 485084Sjohnlev * frame, or zero if none. 495084Sjohnlev * 3. Write memory barrier (WMB). 505084Sjohnlev * 4. Write ent->flags, inc. valid type. 515084Sjohnlev * 525084Sjohnlev * Invalidating an unused GTF_permit_access entry: 535084Sjohnlev * 1. flags = ent->flags. 545084Sjohnlev * 2. Observe that !(flags & (GTF_reading|GTF_writing)). 555084Sjohnlev * 3. Check result of SMP-safe CMPXCHG(&ent->flags, flags, 0). 565084Sjohnlev * NB. No need for WMB as reuse of entry is control-dependent on success of 575084Sjohnlev * step 3, and all architectures guarantee ordering of ctrl-dep writes. 585084Sjohnlev * 595084Sjohnlev * Invalidating an in-use GTF_permit_access entry: 605084Sjohnlev * This cannot be done directly. Request assistance from the domain controller 615084Sjohnlev * which can set a timeout on the use of a grant entry and take necessary 625084Sjohnlev * action. (NB. This is not yet implemented!). 635084Sjohnlev * 645084Sjohnlev * Invalidating an unused GTF_accept_transfer entry: 655084Sjohnlev * 1. flags = ent->flags. 665084Sjohnlev * 2. Observe that !(flags & GTF_transfer_committed). [*] 675084Sjohnlev * 3. Check result of SMP-safe CMPXCHG(&ent->flags, flags, 0). 685084Sjohnlev * NB. No need for WMB as reuse of entry is control-dependent on success of 695084Sjohnlev * step 3, and all architectures guarantee ordering of ctrl-dep writes. 705084Sjohnlev * [*] If GTF_transfer_committed is set then the grant entry is 'committed'. 715084Sjohnlev * The guest must /not/ modify the grant entry until the address of the 725084Sjohnlev * transferred frame is written. It is safe for the guest to spin waiting 735084Sjohnlev * for this to occur (detect by observing GTF_transfer_completed in 745084Sjohnlev * ent->flags). 755084Sjohnlev * 765084Sjohnlev * Invalidating a committed GTF_accept_transfer entry: 775084Sjohnlev * 1. Wait for (ent->flags & GTF_transfer_completed). 785084Sjohnlev * 795084Sjohnlev * Changing a GTF_permit_access from writable to read-only: 805084Sjohnlev * Use SMP-safe CMPXCHG to set GTF_readonly, while checking !GTF_writing. 815084Sjohnlev * 825084Sjohnlev * Changing a GTF_permit_access from read-only to writable: 835084Sjohnlev * Use SMP-safe bit-setting instruction. 845084Sjohnlev */ 855084Sjohnlev 865084Sjohnlev /* 875084Sjohnlev * A grant table comprises a packed array of grant entries in one or more 885084Sjohnlev * page frames shared between Xen and a guest. 895084Sjohnlev * [XEN]: This field is written by Xen and read by the sharing guest. 905084Sjohnlev * [GST]: This field is written by the guest and read by Xen. 915084Sjohnlev */ 925084Sjohnlev struct grant_entry { 935084Sjohnlev /* GTF_xxx: various type and flag information. [XEN,GST] */ 945084Sjohnlev uint16_t flags; 955084Sjohnlev /* The domain being granted foreign privileges. [GST] */ 965084Sjohnlev domid_t domid; 975084Sjohnlev /* 985084Sjohnlev * GTF_permit_access: Frame that @domid is allowed to map and access. [GST] 995084Sjohnlev * GTF_accept_transfer: Frame whose ownership transferred by @domid. [XEN] 1005084Sjohnlev */ 1015084Sjohnlev uint32_t frame; 1025084Sjohnlev }; 1035084Sjohnlev typedef struct grant_entry grant_entry_t; 1045084Sjohnlev 1055084Sjohnlev /* 1065084Sjohnlev * Type of grant entry. 1075084Sjohnlev * GTF_invalid: This grant entry grants no privileges. 1085084Sjohnlev * GTF_permit_access: Allow @domid to map/access @frame. 1095084Sjohnlev * GTF_accept_transfer: Allow @domid to transfer ownership of one page frame 1105084Sjohnlev * to this guest. Xen writes the page number to @frame. 1115084Sjohnlev */ 1125084Sjohnlev #define GTF_invalid (0U<<0) 1135084Sjohnlev #define GTF_permit_access (1U<<0) 1145084Sjohnlev #define GTF_accept_transfer (2U<<0) 1155084Sjohnlev #define GTF_type_mask (3U<<0) 1165084Sjohnlev 1175084Sjohnlev /* 1185084Sjohnlev * Subflags for GTF_permit_access. 1195084Sjohnlev * GTF_readonly: Restrict @domid to read-only mappings and accesses. [GST] 1205084Sjohnlev * GTF_reading: Grant entry is currently mapped for reading by @domid. [XEN] 1215084Sjohnlev * GTF_writing: Grant entry is currently mapped for writing by @domid. [XEN] 122*10175SStuart.Maybee@Sun.COM * GTF_PAT, GTF_PWT, GTF_PCD: (x86) cache attribute flags for the grant [GST] 1235084Sjohnlev */ 1245084Sjohnlev #define _GTF_readonly (2) 1255084Sjohnlev #define GTF_readonly (1U<<_GTF_readonly) 1265084Sjohnlev #define _GTF_reading (3) 1275084Sjohnlev #define GTF_reading (1U<<_GTF_reading) 1285084Sjohnlev #define _GTF_writing (4) 1295084Sjohnlev #define GTF_writing (1U<<_GTF_writing) 130*10175SStuart.Maybee@Sun.COM #define _GTF_PWT (5) 131*10175SStuart.Maybee@Sun.COM #define GTF_PWT (1U<<_GTF_PWT) 132*10175SStuart.Maybee@Sun.COM #define _GTF_PCD (6) 133*10175SStuart.Maybee@Sun.COM #define GTF_PCD (1U<<_GTF_PCD) 134*10175SStuart.Maybee@Sun.COM #define _GTF_PAT (7) 135*10175SStuart.Maybee@Sun.COM #define GTF_PAT (1U<<_GTF_PAT) 1365084Sjohnlev 1375084Sjohnlev /* 1385084Sjohnlev * Subflags for GTF_accept_transfer: 1395084Sjohnlev * GTF_transfer_committed: Xen sets this flag to indicate that it is committed 1405084Sjohnlev * to transferring ownership of a page frame. When a guest sees this flag 1415084Sjohnlev * it must /not/ modify the grant entry until GTF_transfer_completed is 1425084Sjohnlev * set by Xen. 1435084Sjohnlev * GTF_transfer_completed: It is safe for the guest to spin-wait on this flag 1445084Sjohnlev * after reading GTF_transfer_committed. Xen will always write the frame 1455084Sjohnlev * address, followed by ORing this flag, in a timely manner. 1465084Sjohnlev */ 1475084Sjohnlev #define _GTF_transfer_committed (2) 1485084Sjohnlev #define GTF_transfer_committed (1U<<_GTF_transfer_committed) 1495084Sjohnlev #define _GTF_transfer_completed (3) 1505084Sjohnlev #define GTF_transfer_completed (1U<<_GTF_transfer_completed) 1515084Sjohnlev 1525084Sjohnlev 1535084Sjohnlev /*********************************** 1545084Sjohnlev * GRANT TABLE QUERIES AND USES 1555084Sjohnlev */ 1565084Sjohnlev 1575084Sjohnlev /* 1585084Sjohnlev * Reference to a grant entry in a specified domain's grant table. 1595084Sjohnlev */ 1605084Sjohnlev typedef uint32_t grant_ref_t; 1615084Sjohnlev 1625084Sjohnlev /* 1635084Sjohnlev * Handle to track a mapping created via a grant reference. 1645084Sjohnlev */ 1655084Sjohnlev typedef uint32_t grant_handle_t; 1665084Sjohnlev 1675084Sjohnlev /* 1685084Sjohnlev * GNTTABOP_map_grant_ref: Map the grant entry (<dom>,<ref>) for access 1695084Sjohnlev * by devices and/or host CPUs. If successful, <handle> is a tracking number 1705084Sjohnlev * that must be presented later to destroy the mapping(s). On error, <handle> 1715084Sjohnlev * is a negative status code. 1725084Sjohnlev * NOTES: 1735084Sjohnlev * 1. If GNTMAP_device_map is specified then <dev_bus_addr> is the address 1745084Sjohnlev * via which I/O devices may access the granted frame. 1755084Sjohnlev * 2. If GNTMAP_host_map is specified then a mapping will be added at 1765084Sjohnlev * either a host virtual address in the current address space, or at 1775084Sjohnlev * a PTE at the specified machine address. The type of mapping to 1785084Sjohnlev * perform is selected through the GNTMAP_contains_pte flag, and the 1795084Sjohnlev * address is specified in <host_addr>. 1805084Sjohnlev * 3. Mappings should only be destroyed via GNTTABOP_unmap_grant_ref. If a 1815084Sjohnlev * host mapping is destroyed by other means then it is *NOT* guaranteed 1825084Sjohnlev * to be accounted to the correct grant reference! 1835084Sjohnlev */ 1845084Sjohnlev #define GNTTABOP_map_grant_ref 0 1855084Sjohnlev struct gnttab_map_grant_ref { 1865084Sjohnlev /* IN parameters. */ 1875084Sjohnlev uint64_t host_addr; 1885084Sjohnlev uint32_t flags; /* GNTMAP_* */ 1895084Sjohnlev grant_ref_t ref; 1905084Sjohnlev domid_t dom; 1915084Sjohnlev /* OUT parameters. */ 1925084Sjohnlev int16_t status; /* GNTST_* */ 1935084Sjohnlev grant_handle_t handle; 1945084Sjohnlev uint64_t dev_bus_addr; 1955084Sjohnlev }; 1965084Sjohnlev typedef struct gnttab_map_grant_ref gnttab_map_grant_ref_t; 1975084Sjohnlev DEFINE_XEN_GUEST_HANDLE(gnttab_map_grant_ref_t); 1985084Sjohnlev 1995084Sjohnlev /* 2005084Sjohnlev * GNTTABOP_unmap_grant_ref: Destroy one or more grant-reference mappings 2015084Sjohnlev * tracked by <handle>. If <host_addr> or <dev_bus_addr> is zero, that 2025084Sjohnlev * field is ignored. If non-zero, they must refer to a device/host mapping 2035084Sjohnlev * that is tracked by <handle> 2045084Sjohnlev * NOTES: 2055084Sjohnlev * 1. The call may fail in an undefined manner if either mapping is not 2065084Sjohnlev * tracked by <handle>. 2075084Sjohnlev * 3. After executing a batch of unmaps, it is guaranteed that no stale 2085084Sjohnlev * mappings will remain in the device or host TLBs. 2095084Sjohnlev */ 2105084Sjohnlev #define GNTTABOP_unmap_grant_ref 1 2115084Sjohnlev struct gnttab_unmap_grant_ref { 2125084Sjohnlev /* IN parameters. */ 2135084Sjohnlev uint64_t host_addr; 2145084Sjohnlev uint64_t dev_bus_addr; 2155084Sjohnlev grant_handle_t handle; 2165084Sjohnlev /* OUT parameters. */ 2175084Sjohnlev int16_t status; /* GNTST_* */ 2185084Sjohnlev }; 2195084Sjohnlev typedef struct gnttab_unmap_grant_ref gnttab_unmap_grant_ref_t; 2205084Sjohnlev DEFINE_XEN_GUEST_HANDLE(gnttab_unmap_grant_ref_t); 2215084Sjohnlev 2225084Sjohnlev /* 2235084Sjohnlev * GNTTABOP_setup_table: Set up a grant table for <dom> comprising at least 2245084Sjohnlev * <nr_frames> pages. The frame addresses are written to the <frame_list>. 2255084Sjohnlev * Only <nr_frames> addresses are written, even if the table is larger. 2265084Sjohnlev * NOTES: 2275084Sjohnlev * 1. <dom> may be specified as DOMID_SELF. 2285084Sjohnlev * 2. Only a sufficiently-privileged domain may specify <dom> != DOMID_SELF. 2295084Sjohnlev * 3. Xen may not support more than a single grant-table page per domain. 2305084Sjohnlev */ 2315084Sjohnlev #define GNTTABOP_setup_table 2 2325084Sjohnlev struct gnttab_setup_table { 2335084Sjohnlev /* IN parameters. */ 2345084Sjohnlev domid_t dom; 2355084Sjohnlev uint32_t nr_frames; 2365084Sjohnlev /* OUT parameters. */ 2375084Sjohnlev int16_t status; /* GNTST_* */ 2385084Sjohnlev XEN_GUEST_HANDLE(ulong) frame_list; 2395084Sjohnlev }; 2405084Sjohnlev typedef struct gnttab_setup_table gnttab_setup_table_t; 2415084Sjohnlev DEFINE_XEN_GUEST_HANDLE(gnttab_setup_table_t); 2425084Sjohnlev 2435084Sjohnlev /* 2445084Sjohnlev * GNTTABOP_dump_table: Dump the contents of the grant table to the 2455084Sjohnlev * xen console. Debugging use only. 2465084Sjohnlev */ 2475084Sjohnlev #define GNTTABOP_dump_table 3 2485084Sjohnlev struct gnttab_dump_table { 2495084Sjohnlev /* IN parameters. */ 2505084Sjohnlev domid_t dom; 2515084Sjohnlev /* OUT parameters. */ 2525084Sjohnlev int16_t status; /* GNTST_* */ 2535084Sjohnlev }; 2545084Sjohnlev typedef struct gnttab_dump_table gnttab_dump_table_t; 2555084Sjohnlev DEFINE_XEN_GUEST_HANDLE(gnttab_dump_table_t); 2565084Sjohnlev 2575084Sjohnlev /* 2585084Sjohnlev * GNTTABOP_transfer_grant_ref: Transfer <frame> to a foreign domain. The 2595084Sjohnlev * foreign domain has previously registered its interest in the transfer via 2605084Sjohnlev * <domid, ref>. 2615084Sjohnlev * 2625084Sjohnlev * Note that, even if the transfer fails, the specified page no longer belongs 2635084Sjohnlev * to the calling domain *unless* the error is GNTST_bad_page. 2645084Sjohnlev */ 2655084Sjohnlev #define GNTTABOP_transfer 4 2665084Sjohnlev struct gnttab_transfer { 2675084Sjohnlev /* IN parameters. */ 2685084Sjohnlev xen_pfn_t mfn; 2695084Sjohnlev domid_t domid; 2705084Sjohnlev grant_ref_t ref; 2715084Sjohnlev /* OUT parameters. */ 2725084Sjohnlev int16_t status; 2735084Sjohnlev }; 2745084Sjohnlev typedef struct gnttab_transfer gnttab_transfer_t; 2755084Sjohnlev DEFINE_XEN_GUEST_HANDLE(gnttab_transfer_t); 2765084Sjohnlev 2775084Sjohnlev 2785084Sjohnlev /* 2795084Sjohnlev * GNTTABOP_copy: Hypervisor based copy 2805084Sjohnlev * source and destinations can be eithers MFNs or, for foreign domains, 2815084Sjohnlev * grant references. the foreign domain has to grant read/write access 2825084Sjohnlev * in its grant table. 2835084Sjohnlev * 2845084Sjohnlev * The flags specify what type source and destinations are (either MFN 2855084Sjohnlev * or grant reference). 2865084Sjohnlev * 2875084Sjohnlev * Note that this can also be used to copy data between two domains 2885084Sjohnlev * via a third party if the source and destination domains had previously 2895084Sjohnlev * grant appropriate access to their pages to the third party. 2905084Sjohnlev * 2915084Sjohnlev * source_offset specifies an offset in the source frame, dest_offset 2925084Sjohnlev * the offset in the target frame and len specifies the number of 2935084Sjohnlev * bytes to be copied. 2945084Sjohnlev */ 2955084Sjohnlev 2965084Sjohnlev #define _GNTCOPY_source_gref (0) 2975084Sjohnlev #define GNTCOPY_source_gref (1<<_GNTCOPY_source_gref) 2985084Sjohnlev #define _GNTCOPY_dest_gref (1) 2995084Sjohnlev #define GNTCOPY_dest_gref (1<<_GNTCOPY_dest_gref) 3005084Sjohnlev 3015084Sjohnlev #define GNTTABOP_copy 5 3025084Sjohnlev typedef struct gnttab_copy { 3035084Sjohnlev /* IN parameters. */ 3045084Sjohnlev struct { 3055084Sjohnlev union { 3065084Sjohnlev grant_ref_t ref; 3075084Sjohnlev xen_pfn_t gmfn; 3085084Sjohnlev } u; 3095084Sjohnlev domid_t domid; 3105084Sjohnlev uint16_t offset; 3115084Sjohnlev } source, dest; 3125084Sjohnlev uint16_t len; 3135084Sjohnlev uint16_t flags; /* GNTCOPY_* */ 3145084Sjohnlev /* OUT parameters. */ 3155084Sjohnlev int16_t status; 3165084Sjohnlev } gnttab_copy_t; 3175084Sjohnlev DEFINE_XEN_GUEST_HANDLE(gnttab_copy_t); 3185084Sjohnlev 3196144Srab /* 3206144Srab * GNTTABOP_query_size: Query the current and maximum sizes of the shared 3216144Srab * grant table. 3226144Srab * NOTES: 3236144Srab * 1. <dom> may be specified as DOMID_SELF. 3246144Srab * 2. Only a sufficiently-privileged domain may specify <dom> != DOMID_SELF. 3256144Srab */ 3266144Srab #define GNTTABOP_query_size 6 3276144Srab struct gnttab_query_size { 3286144Srab /* IN parameters. */ 3296144Srab domid_t dom; 3306144Srab /* OUT parameters. */ 3316144Srab uint32_t nr_frames; 3326144Srab uint32_t max_nr_frames; 3336144Srab int16_t status; /* GNTST_* */ 3346144Srab }; 3356144Srab typedef struct gnttab_query_size gnttab_query_size_t; 3366144Srab DEFINE_XEN_GUEST_HANDLE(gnttab_query_size_t); 3376144Srab 338*10175SStuart.Maybee@Sun.COM /* 339*10175SStuart.Maybee@Sun.COM * GNTTABOP_unmap_and_replace: Destroy one or more grant-reference mappings 340*10175SStuart.Maybee@Sun.COM * tracked by <handle> but atomically replace the page table entry with one 341*10175SStuart.Maybee@Sun.COM * pointing to the machine address under <new_addr>. <new_addr> will be 342*10175SStuart.Maybee@Sun.COM * redirected to the null entry. 343*10175SStuart.Maybee@Sun.COM * NOTES: 344*10175SStuart.Maybee@Sun.COM * 1. The call may fail in an undefined manner if either mapping is not 345*10175SStuart.Maybee@Sun.COM * tracked by <handle>. 346*10175SStuart.Maybee@Sun.COM * 2. After executing a batch of unmaps, it is guaranteed that no stale 347*10175SStuart.Maybee@Sun.COM * mappings will remain in the device or host TLBs. 348*10175SStuart.Maybee@Sun.COM */ 349*10175SStuart.Maybee@Sun.COM #define GNTTABOP_unmap_and_replace 7 350*10175SStuart.Maybee@Sun.COM struct gnttab_unmap_and_replace { 351*10175SStuart.Maybee@Sun.COM /* IN parameters. */ 352*10175SStuart.Maybee@Sun.COM uint64_t host_addr; 353*10175SStuart.Maybee@Sun.COM uint64_t new_addr; 354*10175SStuart.Maybee@Sun.COM grant_handle_t handle; 355*10175SStuart.Maybee@Sun.COM /* OUT parameters. */ 356*10175SStuart.Maybee@Sun.COM int16_t status; /* GNTST_* */ 357*10175SStuart.Maybee@Sun.COM }; 358*10175SStuart.Maybee@Sun.COM typedef struct gnttab_unmap_and_replace gnttab_unmap_and_replace_t; 359*10175SStuart.Maybee@Sun.COM DEFINE_XEN_GUEST_HANDLE(gnttab_unmap_and_replace_t); 360*10175SStuart.Maybee@Sun.COM 3615084Sjohnlev 3625084Sjohnlev /* 363*10175SStuart.Maybee@Sun.COM * Bitfield values for gnttab_map_grant_ref.flags. 3645084Sjohnlev */ 3655084Sjohnlev /* Map the grant entry for access by I/O devices. */ 3665084Sjohnlev #define _GNTMAP_device_map (0) 3675084Sjohnlev #define GNTMAP_device_map (1<<_GNTMAP_device_map) 3685084Sjohnlev /* Map the grant entry for access by host CPUs. */ 3695084Sjohnlev #define _GNTMAP_host_map (1) 3705084Sjohnlev #define GNTMAP_host_map (1<<_GNTMAP_host_map) 3715084Sjohnlev /* Accesses to the granted frame will be restricted to read-only access. */ 3725084Sjohnlev #define _GNTMAP_readonly (2) 3735084Sjohnlev #define GNTMAP_readonly (1<<_GNTMAP_readonly) 3745084Sjohnlev /* 3755084Sjohnlev * GNTMAP_host_map subflag: 3765084Sjohnlev * 0 => The host mapping is usable only by the guest OS. 3775084Sjohnlev * 1 => The host mapping is usable by guest OS + current application. 3785084Sjohnlev */ 3795084Sjohnlev #define _GNTMAP_application_map (3) 3805084Sjohnlev #define GNTMAP_application_map (1<<_GNTMAP_application_map) 3815084Sjohnlev 3825084Sjohnlev /* 3835084Sjohnlev * GNTMAP_contains_pte subflag: 3845084Sjohnlev * 0 => This map request contains a host virtual address. 3855084Sjohnlev * 1 => This map request contains the machine addess of the PTE to update. 3865084Sjohnlev */ 3875084Sjohnlev #define _GNTMAP_contains_pte (4) 3885084Sjohnlev #define GNTMAP_contains_pte (1<<_GNTMAP_contains_pte) 3895084Sjohnlev 3905084Sjohnlev /* 391*10175SStuart.Maybee@Sun.COM * Bits to be placed in guest kernel available PTE bits (architecture 392*10175SStuart.Maybee@Sun.COM * dependent; only supported when XENFEAT_gnttab_map_avail_bits is set). 393*10175SStuart.Maybee@Sun.COM */ 394*10175SStuart.Maybee@Sun.COM #define _GNTMAP_guest_avail0 (16) 395*10175SStuart.Maybee@Sun.COM #define GNTMAP_guest_avail_mask ((uint32_t)~0 << _GNTMAP_guest_avail0) 396*10175SStuart.Maybee@Sun.COM 397*10175SStuart.Maybee@Sun.COM /* 3985084Sjohnlev * Values for error status returns. All errors are -ve. 3995084Sjohnlev */ 4005084Sjohnlev #define GNTST_okay (0) /* Normal return. */ 4015084Sjohnlev #define GNTST_general_error (-1) /* General undefined error. */ 4025084Sjohnlev #define GNTST_bad_domain (-2) /* Unrecognsed domain id. */ 4035084Sjohnlev #define GNTST_bad_gntref (-3) /* Unrecognised or inappropriate gntref. */ 4045084Sjohnlev #define GNTST_bad_handle (-4) /* Unrecognised or inappropriate handle. */ 4055084Sjohnlev #define GNTST_bad_virt_addr (-5) /* Inappropriate virtual address to map. */ 4065084Sjohnlev #define GNTST_bad_dev_addr (-6) /* Inappropriate device address to unmap.*/ 4075084Sjohnlev #define GNTST_no_device_space (-7) /* Out of space in I/O MMU. */ 4085084Sjohnlev #define GNTST_permission_denied (-8) /* Not enough privilege for operation. */ 4095084Sjohnlev #define GNTST_bad_page (-9) /* Specified page was invalid for op. */ 410*10175SStuart.Maybee@Sun.COM #define GNTST_bad_copy_arg (-10) /* copy arguments cross page boundary. */ 411*10175SStuart.Maybee@Sun.COM #define GNTST_address_too_big (-11) /* transfer page address too large. */ 4125084Sjohnlev 4135084Sjohnlev #define GNTTABOP_error_msgs { \ 4145084Sjohnlev "okay", \ 4155084Sjohnlev "undefined error", \ 4165084Sjohnlev "unrecognised domain id", \ 4175084Sjohnlev "invalid grant reference", \ 4185084Sjohnlev "invalid mapping handle", \ 4195084Sjohnlev "invalid virtual address", \ 4205084Sjohnlev "invalid device address", \ 4215084Sjohnlev "no spare translation slot in the I/O MMU", \ 4225084Sjohnlev "permission denied", \ 4235084Sjohnlev "bad page", \ 424*10175SStuart.Maybee@Sun.COM "copy arguments cross page boundary", \ 425*10175SStuart.Maybee@Sun.COM "page address size too large" \ 4265084Sjohnlev } 4275084Sjohnlev 4285084Sjohnlev #endif /* __XEN_PUBLIC_GRANT_TABLE_H__ */ 4295084Sjohnlev 4305084Sjohnlev /* 4315084Sjohnlev * Local variables: 4325084Sjohnlev * mode: C 4335084Sjohnlev * c-set-style: "BSD" 4345084Sjohnlev * c-basic-offset: 4 4355084Sjohnlev * tab-width: 4 4365084Sjohnlev * indent-tabs-mode: nil 4375084Sjohnlev * End: 4385084Sjohnlev */ 439