History

xen/gntdev: add ioctl for grant copy

Add IOCTL_GNTDEV_GRANT_COPY to allow applications to copy between user space buffers and grant references. This interface is similar to the GNTTABOP_copy hypercall ABI except the local buffers are provided using a virtual address (instead of a GFN and offset). To avoid userspace from having to page align its buffers the driver will use two or more ops if required. If the ioctl returns 0, the application must check the status of each segment with the segments status field. If the ioctl returns a -ve error code (EINVAL or EFAULT), the status of individual ops is undefined.

David Vrabel committed 11 years ago

Commit a4cdb551 parent 6a1f5132 files · +253 −0Browse files

Showing the changes to include/uapi (1 of 2 files). Show all

Unified · Split

include/uapi/xen/gntdev.h+50−0
@@ -144,6 +144,56 @@ struct ioctl_gntdev_unmap_notify { · 143 unmodified lines
144 __u32 event_channel_port;144 __u32 event_channel_port;
145};145};
146 146
147struct gntdev_grant_copy_segment {
148 union {
149 void __user *virt;
150 struct {
151 grant_ref_t ref;
152 __u16 offset;
153 domid_t domid;
154 } foreign;
155 } source, dest;
156 __u16 len;
157
158 __u16 flags; /* GNTCOPY_* */
159 __s16 status; /* GNTST_* */
160};
161
162/*
163 * Copy between grant references and local buffers.
164 *
165 * The copy is split into @count @segments, each of which can copy
166 * to/from one grant reference.
167 *
168 * Each segment is similar to struct gnttab_copy in the hypervisor ABI
169 * except the local buffer is specified using a virtual address
170 * (instead of a GFN and offset).
171 *
172 * The local buffer may cross a Xen page boundary -- the driver will
173 * split segments into multiple ops if required.
174 *
175 * Returns 0 if all segments have been processed and @status in each
176 * segment is valid. Note that one or more segments may have failed
177 * (status != GNTST_okay).
178 *
179 * If the driver had to split a segment into two or more ops, @status
180 * includes the status of the first failed op for that segment (or
181 * GNTST_okay if all ops were successful).
182 *
183 * If -1 is returned, the status of all segments is undefined.
184 *
185 * EINVAL: A segment has local buffers for both source and
186 * destination.
187 * EINVAL: A segment crosses the boundary of a foreign page.
188 * EFAULT: A segment's local buffer is not accessible.
189 */
190#define IOCTL_GNTDEV_GRANT_COPY \
191 _IOC(_IOC_NONE, 'G', 8, sizeof(struct ioctl_gntdev_grant_copy))
192struct ioctl_gntdev_grant_copy {
193 unsigned int count;
194 struct gntdev_grant_copy_segment __user *segments;
195};
196
147/* Clear (set to zero) the byte specified by index */197/* Clear (set to zero) the byte specified by index */
148#define UNMAP_NOTIFY_CLEAR_BYTE 0x1198#define UNMAP_NOTIFY_CLEAR_BYTE 0x1
149/* Send an interrupt on the indicated event channel */199/* Send an interrupt on the indicated event channel */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t