From: Paulina Szubarczyk <paulinaszubarczyk@gmail.com>
To: xen-devel@lists.xenproject.org, roger.pau@citrix.com
Cc: sstabellini@kernel.org, wei.liu2@citrix.com,
Paulina Szubarczyk <paulinaszubarczyk@gmail.com>,
ian.jackson@eu.citrix.com, david.vrabel@citrix.com,
anthony.perard@citrix.com
Subject: [PATCH v3 1/2] Interface for grant copy operation in libs.
Date: Wed, 22 Jun 2016 10:38:52 +0200 [thread overview]
Message-ID: <1466584733-19459-2-git-send-email-paulinaszubarczyk@gmail.com> (raw)
In-Reply-To: <1466584733-19459-1-git-send-email-paulinaszubarczyk@gmail.com>
In a linux part an ioctl(gntdev, IOCTL_GNTDEV_GRANT_COPY, ..)
system call is invoked. In mini-os the operation is yet not
implemented. For other OSs there is a dummy implementation.
Signed-off-by: Paulina Szubarczyk <paulinaszubarczyk@gmail.com>
---
Changes since v2:
- dropped the changes in libxc/include/xenctrl_compat
- changed the MINOR version in Makefile
- replaced 'return -1' -> 'abort()'in libs/gnttab/gnttab_unimp.c
- moved the struct 'xengnttab_copy_grant_segment' to
libs/gnttab/include/xengnttab.h
- added explicit assingment to ioctl_gntdev_grant_copy_segment
to the linux part
tools/include/xen-sys/Linux/gntdev.h | 21 ++++++++++++++++
tools/libs/gnttab/Makefile | 2 +-
tools/libs/gnttab/gnttab_core.c | 6 +++++
tools/libs/gnttab/gnttab_unimp.c | 6 +++++
tools/libs/gnttab/include/xengnttab.h | 28 ++++++++++++++++++++++
tools/libs/gnttab/libxengnttab.map | 5 ++++
tools/libs/gnttab/linux.c | 45 +++++++++++++++++++++++++++++++++++
tools/libs/gnttab/minios.c | 6 +++++
tools/libs/gnttab/private.h | 4 ++++
9 files changed, 122 insertions(+), 1 deletion(-)
diff --git a/tools/include/xen-sys/Linux/gntdev.h b/tools/include/xen-sys/Linux/gntdev.h
index caf6fb4..0ca07c9 100644
--- a/tools/include/xen-sys/Linux/gntdev.h
+++ b/tools/include/xen-sys/Linux/gntdev.h
@@ -147,4 +147,25 @@ struct ioctl_gntdev_unmap_notify {
/* Send an interrupt on the indicated event channel */
#define UNMAP_NOTIFY_SEND_EVENT 0x2
+struct ioctl_gntdev_grant_copy_segment {
+ union {
+ void *virt;
+ struct {
+ uint32_t ref;
+ uint16_t offset;
+ uint16_t domid;
+ } foreign;
+ } source, dest;
+ uint16_t len;
+ uint16_t flags;
+ int16_t status;
+};
+
+#define IOCTL_GNTDEV_GRANT_COPY \
+_IOC(_IOC_NONE, 'G', 8, sizeof(struct ioctl_gntdev_grant_copy))
+struct ioctl_gntdev_grant_copy {
+ unsigned int count;
+ struct ioctl_gntdev_grant_copy_segment *segments;
+};
+
#endif /* __LINUX_PUBLIC_GNTDEV_H__ */
diff --git a/tools/libs/gnttab/Makefile b/tools/libs/gnttab/Makefile
index af64542..95c2cd8 100644
--- a/tools/libs/gnttab/Makefile
+++ b/tools/libs/gnttab/Makefile
@@ -2,7 +2,7 @@ XEN_ROOT = $(CURDIR)/../../..
include $(XEN_ROOT)/tools/Rules.mk
MAJOR = 1
-MINOR = 0
+MINOR = 1
SHLIB_LDFLAGS += -Wl,--version-script=libxengnttab.map
CFLAGS += -Werror -Wmissing-prototypes
diff --git a/tools/libs/gnttab/gnttab_core.c b/tools/libs/gnttab/gnttab_core.c
index 5d0474d..968c833 100644
--- a/tools/libs/gnttab/gnttab_core.c
+++ b/tools/libs/gnttab/gnttab_core.c
@@ -113,6 +113,12 @@ int xengnttab_unmap(xengnttab_handle *xgt, void *start_address, uint32_t count)
return osdep_gnttab_unmap(xgt, start_address, count);
}
+int xengnttab_grant_copy(xengnttab_handle *xgt,
+ uint32_t count,
+ xengnttab_grant_copy_segment_t *segs)
+{
+ return osdep_gnttab_grant_copy(xgt, count, segs);
+}
/*
* Local variables:
* mode: C
diff --git a/tools/libs/gnttab/gnttab_unimp.c b/tools/libs/gnttab/gnttab_unimp.c
index b3a4a20..829eced 100644
--- a/tools/libs/gnttab/gnttab_unimp.c
+++ b/tools/libs/gnttab/gnttab_unimp.c
@@ -78,6 +78,12 @@ int xengnttab_unmap(xengnttab_handle *xgt, void *start_address, uint32_t count)
abort();
}
+int xengnttab_copy_grant(xengnttab_handle *xgt,
+ uint32_t count,
+ xengnttab_copy_grant_segment_t *segs)
+{
+ abort();
+}
/*
* Local variables:
* mode: C
diff --git a/tools/libs/gnttab/include/xengnttab.h b/tools/libs/gnttab/include/xengnttab.h
index 0431dcf..949fd9e 100644
--- a/tools/libs/gnttab/include/xengnttab.h
+++ b/tools/libs/gnttab/include/xengnttab.h
@@ -258,6 +258,34 @@ int xengnttab_unmap(xengnttab_handle *xgt, void *start_address, uint32_t count);
int xengnttab_set_max_grants(xengnttab_handle *xgt,
uint32_t nr_grants);
+struct xengnttab_grant_copy_segment {
+ union xengnttab_copy_ptr {
+ void *virt;
+ struct {
+ uint32_t ref;
+ uint16_t offset;
+ uint16_t domid;
+ } foreign;
+ } source, dest;
+ uint16_t len;
+ uint16_t flags;
+ int16_t status;
+};
+
+typedef struct xengnttab_grant_copy_segment xengnttab_grant_copy_segment_t;
+
+/**
+ * Copy memory from or to grant references. The information of each operations
+ * are contained in 'xengnttab_grant_copy_segment_t'. The @flag value indicate
+ * the direction of an operation (GNTCOPY_source_gref\GNTCOPY_dest_gref).
+ *
+ * The sum of fields @offset[i] and @len[i] of 'xengnttab_grant_copy_segment_t'
+ * should not exceed XEN_PAGE_SIZE
+ */
+int xengnttab_grant_copy(xengnttab_handle *xgt,
+ uint32_t count,
+ xengnttab_grant_copy_segment_t *segs);
+
/*
* Grant Sharing Interface (allocating and granting pages to others)
*/
diff --git a/tools/libs/gnttab/libxengnttab.map b/tools/libs/gnttab/libxengnttab.map
index dc737ac..f78da22 100644
--- a/tools/libs/gnttab/libxengnttab.map
+++ b/tools/libs/gnttab/libxengnttab.map
@@ -21,3 +21,8 @@ VERS_1.0 {
xengntshr_unshare;
local: *; /* Do not expose anything by default */
};
+
+VERS_1.1 {
+ global:
+ xengnttab_grant_copy;
+} VERS_1.0;
diff --git a/tools/libs/gnttab/linux.c b/tools/libs/gnttab/linux.c
index 7b0fba4..62ad7bd 100644
--- a/tools/libs/gnttab/linux.c
+++ b/tools/libs/gnttab/linux.c
@@ -235,6 +235,51 @@ int osdep_gnttab_unmap(xengnttab_handle *xgt,
return 0;
}
+int osdep_gnttab_grant_copy(xengnttab_handle *xgt,
+ uint32_t count,
+ xengnttab_grant_copy_segment_t *segs)
+{
+ int i, rc;
+ int fd = xgt->fd;
+ struct ioctl_gntdev_grant_copy copy;
+
+ copy.segments = calloc(count, sizeof(struct ioctl_gntdev_grant_copy_segment));
+ copy.count = count;
+ for (i = 0; i < count; i++)
+ {
+ copy.segments[i].flags = segs[i].flags;
+ copy.segments[i].len = segs[i].len;
+ if (segs[i].flags == GNTCOPY_dest_gref)
+ {
+ copy.segments[i].dest.foreign.ref = segs[i].dest.foreign.ref;
+ copy.segments[i].dest.foreign.domid = segs[i].dest.foreign.domid;
+ copy.segments[i].dest.foreign.offset = segs[i].dest.foreign.offset;
+ copy.segments[i].source.virt = segs[i].source.virt;
+ }
+ else
+ {
+ copy.segments[i].source.foreign.ref = segs[i].source.foreign.ref;
+ copy.segments[i].source.foreign.domid = segs[i].source.foreign.domid;
+ copy.segments[i].source.foreign.offset = segs[i].source.foreign.offset;
+ copy.segments[i].dest.virt = segs[i].dest.virt;
+ }
+ }
+
+ rc = ioctl(fd, IOCTL_GNTDEV_GRANT_COPY, ©);
+ if (rc)
+ {
+ GTERROR(xgt->logger, "ioctl GRANT COPY failed %d ", errno);
+ }
+ else
+ {
+ for (i = 0; i < count; i++)
+ segs[i].status = copy.segments[i].status;
+ }
+
+ free(copy.segments);
+ return rc;
+}
+
int osdep_gntshr_open(xengntshr_handle *xgs)
{
int fd = open(DEVXEN "gntalloc", O_RDWR);
diff --git a/tools/libs/gnttab/minios.c b/tools/libs/gnttab/minios.c
index 7e04174..0951bc9 100644
--- a/tools/libs/gnttab/minios.c
+++ b/tools/libs/gnttab/minios.c
@@ -106,6 +106,12 @@ int osdep_gnttab_set_max_grants(xengnttab_handle *xgt, uint32_t count)
return ret;
}
+int osdep_gnttab_grant_copy(xengnttab_handle *xgt,
+ uint32_t count,
+ xengnttab_grant_copy_segment_t *segs)
+{
+ return -1;
+}
/*
* Local variables:
* mode: C
diff --git a/tools/libs/gnttab/private.h b/tools/libs/gnttab/private.h
index d286c86..d6c5594 100644
--- a/tools/libs/gnttab/private.h
+++ b/tools/libs/gnttab/private.h
@@ -23,6 +23,10 @@ void *osdep_gnttab_grant_map(xengnttab_handle *xgt,
int osdep_gnttab_unmap(xengnttab_handle *xgt,
void *start_address,
uint32_t count);
+int osdep_gnttab_grant_copy(xengnttab_handle *xgt,
+ uint32_t count,
+ xengnttab_grant_copy_segment_t *segs);
+
int osdep_gntshr_open(xengntshr_handle *xgs);
int osdep_gntshr_close(xengntshr_handle *xgs);
--
1.9.1
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-06-22 8:43 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-22 8:38 [PATCH v3 0/2] qemu-qdisk: Implementation of grant copy operation Paulina Szubarczyk
2016-06-22 8:38 ` Paulina Szubarczyk [this message]
2016-06-22 9:37 ` [PATCH v3 1/2] Interface for grant copy operation in libs David Vrabel
2016-06-22 9:53 ` Paulina Szubarczyk
2016-06-22 11:24 ` Wei Liu
2016-06-22 14:19 ` Paulina Szubarczyk
2016-06-22 11:21 ` Wei Liu
2016-06-22 12:37 ` David Vrabel
2016-06-22 13:29 ` Wei Liu
2016-06-22 13:52 ` David Vrabel
2016-06-22 14:52 ` Wei Liu
2016-06-22 16:49 ` Wei Liu
2016-07-06 15:49 ` Roger Pau Monné
2016-07-05 16:27 ` George Dunlap
2016-07-08 13:18 ` Wei Liu
2016-07-13 9:12 ` Wei Liu
2016-06-22 8:38 ` [PATCH v3 2/2] qdisk - hw/block/xen_disk: grant copy implementation Paulina Szubarczyk
2016-07-13 12:34 ` Paulina Szubarczyk
2016-07-14 10:37 ` Wei Liu
2016-07-15 10:28 ` Paulina Szubarczyk
2016-07-15 11:15 ` Wei Liu
2016-07-15 17:11 ` Anthony PERARD
2016-07-19 10:16 ` Paulina Szubarczyk
2016-07-15 16:55 ` Anthony PERARD
2016-07-19 10:51 ` Paulina Szubarczyk
2016-07-19 9:12 ` Roger Pau Monné
2016-07-19 10:12 ` Paulina Szubarczyk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1466584733-19459-2-git-send-email-paulinaszubarczyk@gmail.com \
--to=paulinaszubarczyk@gmail.com \
--cc=anthony.perard@citrix.com \
--cc=david.vrabel@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.org \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).