~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/uapi/xen/gntdev.h

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /include/uapi/xen/gntdev.h (Version linux-6.12-rc7) and /include/uapi/xen/gntdev.h (Version linux-4.18.20)


  1 /* SPDX-License-Identifier: ((GPL-2.0 WITH Lin      1 /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR MIT) */
  2 /*********************************************      2 /******************************************************************************
  3  * gntdev.h                                         3  * gntdev.h
  4  *                                                  4  * 
  5  * Interface to /dev/xen/gntdev.                    5  * Interface to /dev/xen/gntdev.
  6  *                                                  6  * 
  7  * Copyright (c) 2007, D G Murray                   7  * Copyright (c) 2007, D G Murray
  8  * Copyright (c) 2018, Oleksandr Andrushchenko << 
  9  *                                                  8  * 
 10  * This program is free software; you can redi      9  * This program is free software; you can redistribute it and/or
 11  * modify it under the terms of the GNU Genera     10  * modify it under the terms of the GNU General Public License version 2
 12  * as published by the Free Software Foundatio     11  * as published by the Free Software Foundation; or, when distributed
 13  * separately from the Linux kernel or incorpo     12  * separately from the Linux kernel or incorporated into other
 14  * software packages, subject to the following     13  * software packages, subject to the following license:
 15  *                                                 14  * 
 16  * Permission is hereby granted, free of charg     15  * Permission is hereby granted, free of charge, to any person obtaining a copy
 17  * of this source file (the "Software"), to de     16  * of this source file (the "Software"), to deal in the Software without
 18  * restriction, including without limitation t     17  * restriction, including without limitation the rights to use, copy, modify,
 19  * merge, publish, distribute, sublicense, and     18  * merge, publish, distribute, sublicense, and/or sell copies of the Software,
 20  * and to permit persons to whom the Software      19  * and to permit persons to whom the Software is furnished to do so, subject to
 21  * the following conditions:                       20  * the following conditions:
 22  *                                                 21  * 
 23  * The above copyright notice and this permiss     22  * The above copyright notice and this permission notice shall be included in
 24  * all copies or substantial portions of the S     23  * all copies or substantial portions of the Software.
 25  *                                                 24  * 
 26  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT W     25  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 27  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE W     26  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 28  * FITNESS FOR A PARTICULAR PURPOSE AND NONINF     27  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 29  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR      28  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 30  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT     29  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 31  * FROM, OUT OF OR IN CONNECTION WITH THE SOFT     30  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 32  * IN THE SOFTWARE.                                31  * IN THE SOFTWARE.
 33  */                                                32  */
 34                                                    33 
 35 #ifndef __LINUX_PUBLIC_GNTDEV_H__                  34 #ifndef __LINUX_PUBLIC_GNTDEV_H__
 36 #define __LINUX_PUBLIC_GNTDEV_H__                  35 #define __LINUX_PUBLIC_GNTDEV_H__
 37                                                    36 
 38 #include <linux/types.h>                           37 #include <linux/types.h>
 39                                                    38 
 40 struct ioctl_gntdev_grant_ref {                    39 struct ioctl_gntdev_grant_ref {
 41         /* The domain ID of the grant to be ma     40         /* The domain ID of the grant to be mapped. */
 42         __u32 domid;                               41         __u32 domid;
 43         /* The grant reference of the grant to     42         /* The grant reference of the grant to be mapped. */
 44         __u32 ref;                                 43         __u32 ref;
 45 };                                                 44 };
 46                                                    45 
 47 /*                                                 46 /*
 48  * Inserts the grant references into the mappi     47  * Inserts the grant references into the mapping table of an instance
 49  * of gntdev. N.B. This does not perform the m     48  * of gntdev. N.B. This does not perform the mapping, which is deferred
 50  * until mmap() is called with @index as the o !!  49  * until mmap() is called with @index as the offset.
 51  * considered opaque to userspace, with one ex << 
 52  * references have ever been inserted into the << 
 53  * instance, @index will be set to 0. This is  << 
 54  * with userspace APIs that expect a file desc << 
 55  * mmap()'d at offset 0, such as Wayland. If @ << 
 56  * ioctl will fail.                            << 
 57  */                                                50  */
 58 #define IOCTL_GNTDEV_MAP_GRANT_REF \               51 #define IOCTL_GNTDEV_MAP_GRANT_REF \
 59 _IOC(_IOC_NONE, 'G', 0, sizeof(struct ioctl_gn     52 _IOC(_IOC_NONE, 'G', 0, sizeof(struct ioctl_gntdev_map_grant_ref))
 60 struct ioctl_gntdev_map_grant_ref {                53 struct ioctl_gntdev_map_grant_ref {
 61         /* IN parameters */                        54         /* IN parameters */
 62         /* The number of grants to be mapped.      55         /* The number of grants to be mapped. */
 63         __u32 count;                               56         __u32 count;
 64         __u32 pad;                                 57         __u32 pad;
 65         /* OUT parameters */                       58         /* OUT parameters */
 66         /* The offset to be used on a subseque     59         /* The offset to be used on a subsequent call to mmap(). */
 67         __u64 index;                               60         __u64 index;
 68         /* Variable IN parameter. */               61         /* Variable IN parameter. */
 69         /* Array of grant references, of size      62         /* Array of grant references, of size @count. */
 70         struct ioctl_gntdev_grant_ref refs[1];     63         struct ioctl_gntdev_grant_ref refs[1];
 71 };                                                 64 };
 72                                                    65 
 73 /*                                                 66 /*
 74  * Removes the grant references from the mappi     67  * Removes the grant references from the mapping table of an instance of
 75  * gntdev. N.B. munmap() must be called on the !!  68  * of gntdev. N.B. munmap() must be called on the relevant virtual address(es)
 76  * before this ioctl is called, or an error wi     69  * before this ioctl is called, or an error will result.
 77  */                                                70  */
 78 #define IOCTL_GNTDEV_UNMAP_GRANT_REF \             71 #define IOCTL_GNTDEV_UNMAP_GRANT_REF \
 79 _IOC(_IOC_NONE, 'G', 1, sizeof(struct ioctl_gn     72 _IOC(_IOC_NONE, 'G', 1, sizeof(struct ioctl_gntdev_unmap_grant_ref))
 80 struct ioctl_gntdev_unmap_grant_ref {              73 struct ioctl_gntdev_unmap_grant_ref {
 81         /* IN parameters */                        74         /* IN parameters */
 82         /* The offset was returned by the corr     75         /* The offset was returned by the corresponding map operation. */
 83         __u64 index;                               76         __u64 index;
 84         /* The number of pages to be unmapped.     77         /* The number of pages to be unmapped. */
 85         __u32 count;                               78         __u32 count;
 86         __u32 pad;                                 79         __u32 pad;
 87 };                                                 80 };
 88                                                    81 
 89 /*                                                 82 /*
 90  * Returns the offset in the driver's address      83  * Returns the offset in the driver's address space that corresponds
 91  * to @vaddr. This can be used to perform a mu     84  * to @vaddr. This can be used to perform a munmap(), followed by an
 92  * UNMAP_GRANT_REF ioctl, where no state about     85  * UNMAP_GRANT_REF ioctl, where no state about the offset is retained by
 93  * the caller. The number of pages that were a     86  * the caller. The number of pages that were allocated at the same time as
 94  * @vaddr is returned in @count.                   87  * @vaddr is returned in @count.
 95  *                                                 88  *
 96  * N.B. Where more than one page has been mapp     89  * N.B. Where more than one page has been mapped into a contiguous range, the
 97  *      supplied @vaddr must correspond to the     90  *      supplied @vaddr must correspond to the start of the range; otherwise
 98  *      an error will result. It is only possi     91  *      an error will result. It is only possible to munmap() the entire
 99  *      contiguously-allocated range at once,      92  *      contiguously-allocated range at once, and not any subrange thereof.
100  */                                                93  */
101 #define IOCTL_GNTDEV_GET_OFFSET_FOR_VADDR \        94 #define IOCTL_GNTDEV_GET_OFFSET_FOR_VADDR \
102 _IOC(_IOC_NONE, 'G', 2, sizeof(struct ioctl_gn     95 _IOC(_IOC_NONE, 'G', 2, sizeof(struct ioctl_gntdev_get_offset_for_vaddr))
103 struct ioctl_gntdev_get_offset_for_vaddr {         96 struct ioctl_gntdev_get_offset_for_vaddr {
104         /* IN parameters */                        97         /* IN parameters */
105         /* The virtual address of the first ma     98         /* The virtual address of the first mapped page in a range. */
106         __u64 vaddr;                               99         __u64 vaddr;
107         /* OUT parameters */                      100         /* OUT parameters */
108         /* The offset that was used in the ini    101         /* The offset that was used in the initial mmap() operation. */
109         __u64 offset;                             102         __u64 offset;
110         /* The number of pages mapped in the V    103         /* The number of pages mapped in the VM area that begins at @vaddr. */
111         __u32 count;                              104         __u32 count;
112         __u32 pad;                                105         __u32 pad;
113 };                                                106 };
114                                                   107 
115 /*                                                108 /*
116  * Sets the maximum number of grants that may     109  * Sets the maximum number of grants that may mapped at once by this gntdev
117  * instance.                                      110  * instance.
118  *                                                111  *
119  * N.B. This must be called before any other i    112  * N.B. This must be called before any other ioctl is performed on the device.
120  */                                               113  */
121 #define IOCTL_GNTDEV_SET_MAX_GRANTS \             114 #define IOCTL_GNTDEV_SET_MAX_GRANTS \
122 _IOC(_IOC_NONE, 'G', 3, sizeof(struct ioctl_gn    115 _IOC(_IOC_NONE, 'G', 3, sizeof(struct ioctl_gntdev_set_max_grants))
123 struct ioctl_gntdev_set_max_grants {              116 struct ioctl_gntdev_set_max_grants {
124         /* IN parameter */                        117         /* IN parameter */
125         /* The maximum number of grants that m    118         /* The maximum number of grants that may be mapped at once. */
126         __u32 count;                              119         __u32 count;
127 };                                                120 };
128                                                   121 
129 /*                                                122 /*
130  * Sets up an unmap notification within the pa    123  * Sets up an unmap notification within the page, so that the other side can do
131  * cleanup if this side crashes. Required to i    124  * cleanup if this side crashes. Required to implement cross-domain robust
132  * mutexes or close notification on communicat    125  * mutexes or close notification on communication channels.
133  *                                                126  *
134  * Each mapped page only supports one notifica    127  * Each mapped page only supports one notification; multiple calls referring to
135  * the same page overwrite the previous notifi    128  * the same page overwrite the previous notification. You must clear the
136  * notification prior to the IOCTL_GNTALLOC_DE    129  * notification prior to the IOCTL_GNTALLOC_DEALLOC_GREF if you do not want it
137  * to occur.                                      130  * to occur.
138  */                                               131  */
139 #define IOCTL_GNTDEV_SET_UNMAP_NOTIFY \           132 #define IOCTL_GNTDEV_SET_UNMAP_NOTIFY \
140 _IOC(_IOC_NONE, 'G', 7, sizeof(struct ioctl_gn    133 _IOC(_IOC_NONE, 'G', 7, sizeof(struct ioctl_gntdev_unmap_notify))
141 struct ioctl_gntdev_unmap_notify {                134 struct ioctl_gntdev_unmap_notify {
142         /* IN parameters */                       135         /* IN parameters */
143         /* Offset in the file descriptor for a    136         /* Offset in the file descriptor for a byte within the page (same as
144          * used in mmap). If using UNMAP_NOTIF    137          * used in mmap). If using UNMAP_NOTIFY_CLEAR_BYTE, this is the byte to
145          * be cleared. Otherwise, it can be an    138          * be cleared. Otherwise, it can be any byte in the page whose
146          * notification we are adjusting.         139          * notification we are adjusting.
147          */                                       140          */
148         __u64 index;                              141         __u64 index;
149         /* Action(s) to take on unmap */          142         /* Action(s) to take on unmap */
150         __u32 action;                             143         __u32 action;
151         /* Event channel to notify */             144         /* Event channel to notify */
152         __u32 event_channel_port;                 145         __u32 event_channel_port;
153 };                                                146 };
154                                                   147 
155 struct gntdev_grant_copy_segment {                148 struct gntdev_grant_copy_segment {
156         union {                                   149         union {
157                 void __user *virt;                150                 void __user *virt;
158                 struct {                          151                 struct {
159                         grant_ref_t ref;          152                         grant_ref_t ref;
160                         __u16 offset;             153                         __u16 offset;
161                         domid_t domid;            154                         domid_t domid;
162                 } foreign;                        155                 } foreign;
163         } source, dest;                           156         } source, dest;
164         __u16 len;                                157         __u16 len;
165                                                   158 
166         __u16 flags;  /* GNTCOPY_* */             159         __u16 flags;  /* GNTCOPY_* */
167         __s16 status; /* GNTST_* */               160         __s16 status; /* GNTST_* */
168 };                                                161 };
169                                                   162 
170 /*                                                163 /*
171  * Copy between grant references and local buf    164  * Copy between grant references and local buffers.
172  *                                                165  *
173  * The copy is split into @count @segments, ea    166  * The copy is split into @count @segments, each of which can copy
174  * to/from one grant reference.                   167  * to/from one grant reference.
175  *                                                168  *
176  * Each segment is similar to struct gnttab_co    169  * Each segment is similar to struct gnttab_copy in the hypervisor ABI
177  * except the local buffer is specified using     170  * except the local buffer is specified using a virtual address
178  * (instead of a GFN and offset).                 171  * (instead of a GFN and offset).
179  *                                                172  *
180  * The local buffer may cross a Xen page bound    173  * The local buffer may cross a Xen page boundary -- the driver will
181  * split segments into multiple ops if require    174  * split segments into multiple ops if required.
182  *                                                175  *
183  * Returns 0 if all segments have been process    176  * Returns 0 if all segments have been processed and @status in each
184  * segment is valid.  Note that one or more se    177  * segment is valid.  Note that one or more segments may have failed
185  * (status != GNTST_okay).                        178  * (status != GNTST_okay).
186  *                                                179  *
187  * If the driver had to split a segment into t    180  * If the driver had to split a segment into two or more ops, @status
188  * includes the status of the first failed op     181  * includes the status of the first failed op for that segment (or
189  * GNTST_okay if all ops were successful).        182  * GNTST_okay if all ops were successful).
190  *                                                183  *
191  * If -1 is returned, the status of all segmen    184  * If -1 is returned, the status of all segments is undefined.
192  *                                                185  *
193  * EINVAL: A segment has local buffers for bot    186  * EINVAL: A segment has local buffers for both source and
194  *         destination.                           187  *         destination.
195  * EINVAL: A segment crosses the boundary of a    188  * EINVAL: A segment crosses the boundary of a foreign page.
196  * EFAULT: A segment's local buffer is not acc    189  * EFAULT: A segment's local buffer is not accessible.
197  */                                               190  */
198 #define IOCTL_GNTDEV_GRANT_COPY \                 191 #define IOCTL_GNTDEV_GRANT_COPY \
199         _IOC(_IOC_NONE, 'G', 8, sizeof(struct     192         _IOC(_IOC_NONE, 'G', 8, sizeof(struct ioctl_gntdev_grant_copy))
200 struct ioctl_gntdev_grant_copy {                  193 struct ioctl_gntdev_grant_copy {
201         unsigned int count;                       194         unsigned int count;
202         struct gntdev_grant_copy_segment __use    195         struct gntdev_grant_copy_segment __user *segments;
203 };                                                196 };
204                                                   197 
205 /* Clear (set to zero) the byte specified by i    198 /* Clear (set to zero) the byte specified by index */
206 #define UNMAP_NOTIFY_CLEAR_BYTE 0x1               199 #define UNMAP_NOTIFY_CLEAR_BYTE 0x1
207 /* Send an interrupt on the indicated event ch    200 /* Send an interrupt on the indicated event channel */
208 #define UNMAP_NOTIFY_SEND_EVENT 0x2               201 #define UNMAP_NOTIFY_SEND_EVENT 0x2
209                                                << 
210 /*                                             << 
211  * Flags to be used while requesting memory ma << 
212  * to be allocated with DMA API.               << 
213  */                                            << 
214                                                << 
215 /*                                             << 
216  * The buffer is backed with memory allocated  << 
217  */                                            << 
218 #define GNTDEV_DMA_FLAG_WC              (1 <<  << 
219                                                << 
220 /*                                             << 
221  * The buffer is backed with memory allocated  << 
222  */                                            << 
223 #define GNTDEV_DMA_FLAG_COHERENT        (1 <<  << 
224                                                << 
225 /*                                             << 
226  * Create a dma-buf [1] from grant references  << 
227  * by the foreign domain @domid with flags @fl << 
228  *                                             << 
229  * By default dma-buf is backed by system memo << 
230  * one of the GNTDEV_DMA_FLAG_XXX flags it can << 
231  * a DMA write-combine or coherent buffer, e.g << 
232  * dma_alloc_coherent.                         << 
233  *                                             << 
234  * Returns 0 if dma-buf was successfully creat << 
235  * dma-buf's file descriptor is returned in @f << 
236  *                                             << 
237  * [1] Documentation/driver-api/dma-buf.rst    << 
238  */                                            << 
239                                                << 
240 #define IOCTL_GNTDEV_DMABUF_EXP_FROM_REFS \    << 
241         _IOC(_IOC_NONE, 'G', 9, \              << 
242              sizeof(struct ioctl_gntdev_dmabuf << 
243 struct ioctl_gntdev_dmabuf_exp_from_refs {     << 
244         /* IN parameters. */                   << 
245         /* Specific options for this dma-buf:  << 
246         __u32 flags;                           << 
247         /* Number of grant references in @refs << 
248         __u32 count;                           << 
249         /* OUT parameters. */                  << 
250         /* File descriptor of the dma-buf. */  << 
251         __u32 fd;                              << 
252         /* The domain ID of the grant referenc << 
253         __u32 domid;                           << 
254         /* Variable IN parameter. */           << 
255         /* Array of grant references of size @ << 
256         __u32 refs[1];                         << 
257 };                                             << 
258                                                << 
259 /*                                             << 
260  * This will block until the dma-buf with the  << 
261  * released. This is only valid for buffers cr << 
262  * IOCTL_GNTDEV_DMABUF_EXP_FROM_REFS.          << 
263  *                                             << 
264  * If within @wait_to_ms milliseconds the buff << 
265  * then -ETIMEDOUT error is returned.          << 
266  * If the buffer with the file descriptor @fd  << 
267  * been released, then -ENOENT is returned. Fo << 
268  * this must not be treated as error.          << 
269  */                                            << 
270 #define IOCTL_GNTDEV_DMABUF_EXP_WAIT_RELEASED  << 
271         _IOC(_IOC_NONE, 'G', 10, \             << 
272              sizeof(struct ioctl_gntdev_dmabuf << 
273 struct ioctl_gntdev_dmabuf_exp_wait_released { << 
274         /* IN parameters */                    << 
275         __u32 fd;                              << 
276         __u32 wait_to_ms;                      << 
277 };                                             << 
278                                                << 
279 /*                                             << 
280  * Import a dma-buf with file descriptor @fd a << 
281  * to the pages of that dma-buf into array @re << 
282  */                                            << 
283 #define IOCTL_GNTDEV_DMABUF_IMP_TO_REFS \      << 
284         _IOC(_IOC_NONE, 'G', 11, \             << 
285              sizeof(struct ioctl_gntdev_dmabuf << 
286 struct ioctl_gntdev_dmabuf_imp_to_refs {       << 
287         /* IN parameters. */                   << 
288         /* File descriptor of the dma-buf. */  << 
289         __u32 fd;                              << 
290         /* Number of grant references in @refs << 
291         __u32 count;                           << 
292         /* The domain ID for which references  << 
293         __u32 domid;                           << 
294         /* Reserved - must be zero. */         << 
295         __u32 reserved;                        << 
296         /* OUT parameters. */                  << 
297         /* Array of grant references of size @ << 
298         __u32 refs[1];                         << 
299 };                                             << 
300                                                << 
301 /*                                             << 
302  * This will close all references to the impor << 
303  * @fd, so it can be released by the owner. Th << 
304  * created with IOCTL_GNTDEV_DMABUF_IMP_TO_REF << 
305  */                                            << 
306 #define IOCTL_GNTDEV_DMABUF_IMP_RELEASE \      << 
307         _IOC(_IOC_NONE, 'G', 12, \             << 
308              sizeof(struct ioctl_gntdev_dmabuf << 
309 struct ioctl_gntdev_dmabuf_imp_release {       << 
310         /* IN parameters */                    << 
311         __u32 fd;                              << 
312         __u32 reserved;                        << 
313 };                                             << 
314                                                   202 
315 #endif /* __LINUX_PUBLIC_GNTDEV_H__ */            203 #endif /* __LINUX_PUBLIC_GNTDEV_H__ */
316                                                   204 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php