From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Cc: Ian.Campbell@eu.citrix.com, xen-devel@lists.xensource.com,
Ian.Jackson@eu.citrix.com, Stefano.Stabellini@eu.citrix.com
Subject: Re: [PATCH 1/3] libxc: add xc_gnttab_map_grant_ref_notify
Date: Thu, 1 Sep 2011 15:29:22 -0400 [thread overview]
Message-ID: <20110901192922.GB21520@dumpdata.com> (raw)
In-Reply-To: <1314894138-28747-2-git-send-email-dgdegra@tycho.nsa.gov>
On Thu, Sep 01, 2011 at 12:22:16PM -0400, Daniel De Graaf wrote:
> Normally, when a userspace process mapping a grant crashes, the domain
> providing the reference receives no indication that its peer has
> crashed, possibly leading to unexpected freezes or timeouts. This
> function provides a notification of the unmap by signalling an event
> channel and/or clearing a specific byte in the page.
>
> Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
> ---
> tools/libxc/xc_gnttab.c | 15 ++++++++++++
> tools/libxc/xc_linux_osdep.c | 52 ++++++++++++++++++++++++++++++++++++++++++
> tools/libxc/xenctrl.h | 21 +++++++++++++++++
> tools/libxc/xenctrlosdep.h | 5 ++++
> 4 files changed, 93 insertions(+), 0 deletions(-)
>
> diff --git a/tools/libxc/xc_gnttab.c b/tools/libxc/xc_gnttab.c
> index 4f55fce..dc7aa0c 100644
> --- a/tools/libxc/xc_gnttab.c
> +++ b/tools/libxc/xc_gnttab.c
> @@ -174,6 +174,21 @@ void *xc_gnttab_map_domain_grant_refs(xc_gnttab *xcg,
> count, domid, refs, prot);
> }
>
> +void *xc_gnttab_map_grant_ref_notify(xc_gnttab *xcg,
> + uint32_t domid,
> + uint32_t ref,
> + uint32_t notify_offset,
> + evtchn_port_t notify_port)
> +{
> + if (xcg->ops->u.gnttab.map_grant_ref_notify)
> + return xcg->ops->u.gnttab.map_grant_ref_notify(xcg, xcg->ops_handle,
> + domid, ref, notify_offset, notify_port);
> + else
> + return xcg->ops->u.gnttab.map_grant_ref(xcg, xcg->ops_handle,
> + domid, ref, PROT_READ|PROT_WRITE);
> +}
> +
> +
> int xc_gnttab_munmap(xc_gnttab *xcg,
> void *start_address,
> uint32_t count)
> diff --git a/tools/libxc/xc_linux_osdep.c b/tools/libxc/xc_linux_osdep.c
> index dca6718..8f7718f 100644
> --- a/tools/libxc/xc_linux_osdep.c
> +++ b/tools/libxc/xc_linux_osdep.c
> @@ -613,6 +613,57 @@ static void *linux_gnttab_map_domain_grant_refs(xc_gnttab *xcg, xc_osdep_handle
> return do_gnttab_map_grant_refs(xcg, h, count, &domid, 0, refs, prot);
> }
>
> +static void *linux_gnttab_map_grant_ref_notify(xc_gnttab *xch, xc_osdep_handle h,
> + uint32_t domid, uint32_t ref,
> + uint32_t notify_offset,
> + evtchn_port_t notify_port)
> +{
> + int fd = (int)h;
> + struct ioctl_gntdev_map_grant_ref map;
> + struct ioctl_gntdev_unmap_notify notify;
That looks a bit odd. Like the formatting is off?
> + void *addr;
> +
> + map.count = 1;
> + map.refs[0].domid = domid;
> + map.refs[0].ref = ref;
> +
> + if ( ioctl(fd, IOCTL_GNTDEV_MAP_GRANT_REF, &map) ) {
> + PERROR("xc_gnttab_map_grant_ref: ioctl MAP_GRANT_REF failed");
> + return NULL;
> + }
> +
> + addr = mmap(NULL, XC_PAGE_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, map.index);
> + if ( addr == MAP_FAILED )
> + {
> + int saved_errno = errno;
> + struct ioctl_gntdev_unmap_grant_ref unmap_grant;
> +
> + PERROR("xc_gnttab_map_grant_ref: mmap failed");
> + unmap_grant.index = map.index;
> + unmap_grant.count = 1;
> + ioctl(fd, IOCTL_GNTDEV_UNMAP_GRANT_REF, &unmap_grant);
> + errno = saved_errno;
> + return NULL;
> + }
> +
> + notify.index = map.index;
> + notify.action = 0;
> + if (notify_offset >= 0) {
> + notify.index += notify_offset;
> + notify.action |= UNMAP_NOTIFY_CLEAR_BYTE;
> + }
> + if (notify_port >= 0) {
> + notify.event_channel_port = notify_port;
> + notify.action |= UNMAP_NOTIFY_SEND_EVENT;
> + }
> + if (notify.action && ioctl(fd, IOCTL_GNTDEV_SET_UNMAP_NOTIFY, ¬ify)) {
> + PERROR("linux_gnttab_map_grant_ref_notify: ioctl SET_UNMAP_NOTIFY failed");
Perhaps reporting via an argument that we failed at doing the notify would
be useful? That way at least you know you need to do polling.
> + }
> +
> + return addr;
> +}
> +
> +
> static int linux_gnttab_munmap(xc_gnttab *xcg, xc_osdep_handle h,
> void *start_address, uint32_t count)
> {
> @@ -662,6 +713,7 @@ static struct xc_osdep_ops linux_gnttab_ops = {
> .map_grant_ref = &linux_gnttab_map_grant_ref,
> .map_grant_refs = &linux_gnttab_map_grant_refs,
> .map_domain_grant_refs = &linux_gnttab_map_domain_grant_refs,
> + .map_grant_ref_notify = &linux_gnttab_map_grant_ref_notify,
> .munmap = &linux_gnttab_munmap,
> },
> };
> diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h
> index 1b82ee0..7859571 100644
> --- a/tools/libxc/xenctrl.h
> +++ b/tools/libxc/xenctrl.h
> @@ -1349,6 +1349,27 @@ void *xc_gnttab_map_domain_grant_refs(xc_gnttab *xcg,
> int prot);
>
> /*
> + * Memory maps a grant reference from one domain to a local address range.
> + * Mappings should be unmapped with xc_gnttab_munmap. Logs errors.
^^^^^^^^^^^^ .. that looks odd?
> + * This version always maps writable pages, and will attempt to set up
> + * an unmap notification at the given offset and event channel. When the
> + * page is unmapped, the byte at the given offset will be zeroed and a
> + * wakeup will be sent to the given event channel.
> + *
> + * @parm xcg a handle on an open grant table interface
> + * @parm domid the domain to map memory from
> + * @parm ref the grant reference ID to map
> + * @parm notify_offset The byte offset in the page to use for unmap
> + * notification; -1 for none.
> + * @parm notify_port The event channel port to use for unmap notify, or -1
> + */
> +void *xc_gnttab_map_grant_ref_notify(xc_gnttab *xcg,
> + uint32_t domid,
> + uint32_t ref,
> + uint32_t notify_offset,
> + evtchn_port_t notify_port);
> +
> +/*
> * Unmaps the @count pages starting at @start_address, which were mapped by a
> * call to xc_gnttab_map_grant_ref or xc_gnttab_map_grant_refs. Never logs.
> */
> diff --git a/tools/libxc/xenctrlosdep.h b/tools/libxc/xenctrlosdep.h
> index bfe46e0..01969c5 100644
> --- a/tools/libxc/xenctrlosdep.h
> +++ b/tools/libxc/xenctrlosdep.h
> @@ -119,6 +119,11 @@ struct xc_osdep_ops
> uint32_t domid,
> uint32_t *refs,
> int prot);
> + void *(*map_grant_ref_notify)(xc_gnttab *xcg, xc_osdep_handle h,
> + uint32_t domid,
> + uint32_t ref,
> + uint32_t notify_offset,
> + evtchn_port_t notify_port);
> int (*munmap)(xc_gnttab *xcg, xc_osdep_handle h,
> void *start_address,
> uint32_t count);
> --
> 1.7.6
next prev parent reply other threads:[~2011-09-01 19:29 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-19 14:38 [PATCH] libvchan: interdomain communications library Daniel De Graaf
2011-08-22 7:40 ` Vasiliy G Tolstov
2011-08-24 19:28 ` Konrad Rzeszutek Wilk
2011-08-22 9:15 ` Ian Campbell
2011-08-24 18:52 ` Daniel De Graaf
2011-08-25 10:27 ` Tim Deegan
2011-08-25 18:36 ` Jeremy Fitzhardinge
2011-08-24 18:52 ` [PATCH v2] " Daniel De Graaf
2011-08-26 14:01 ` Ian Jackson
2011-08-29 18:48 ` [PATCH v3] " Daniel De Graaf
2011-08-30 10:32 ` Ian Campbell
2011-08-31 19:17 ` Daniel De Graaf
2011-09-01 16:28 ` Ian Campbell
2011-09-01 16:47 ` Daniel De Graaf
2011-09-01 16:56 ` Ian Jackson
2011-09-01 17:46 ` Daniel De Graaf
2011-09-01 16:22 ` [PATCH v4 0/3] " Daniel De Graaf
2011-09-01 16:22 ` [PATCH 1/3] libxc: add xc_gnttab_map_grant_ref_notify Daniel De Graaf
2011-09-01 19:29 ` Konrad Rzeszutek Wilk [this message]
2011-09-01 16:22 ` [PATCH 2/3] libxc: add xc_gntshr_* functions Daniel De Graaf
2011-09-01 19:24 ` Konrad Rzeszutek Wilk
2011-09-01 16:22 ` [PATCH 3/3] libvchan: interdomain communications library Daniel De Graaf
2011-09-19 22:43 ` [PATCH v5 0/3] Daniel De Graaf
2011-09-19 22:43 ` [PATCH 1/3] libxc: add xc_gnttab_map_grant_ref_notify Daniel De Graaf
2011-09-21 10:03 ` Ian Campbell
2011-09-21 15:02 ` Daniel De Graaf
2011-09-21 15:25 ` Ian Campbell
2011-09-21 17:07 ` Daniel De Graaf
2011-09-22 8:32 ` Ian Campbell
2011-09-22 18:09 ` Daniel De Graaf
2011-09-19 22:43 ` [PATCH 2/3] libxc: add xc_gntshr_* functions Daniel De Graaf
2011-09-21 10:13 ` Ian Campbell
2011-09-19 22:43 ` [PATCH 3/3] libvchan: interdomain communications library Daniel De Graaf
2011-09-21 10:53 ` Ian Campbell
2011-09-21 16:31 ` Daniel De Graaf
2011-09-22 8:18 ` Ian Campbell
2011-09-21 13:44 ` Ian Campbell
2011-09-22 22:14 ` [PATCH v6 0/3] libxenvchan: " Daniel De Graaf
2011-09-22 22:14 ` [PATCH 1/3] libxc: add xc_gnttab_map_grant_ref_notify Daniel De Graaf
2011-09-30 9:16 ` Ian Campbell
2011-09-30 14:12 ` Ian Jackson
2011-09-30 14:17 ` Ian Campbell
2011-09-22 22:14 ` [PATCH 2/3] libxc: add xc_gntshr_* functions Daniel De Graaf
2011-09-22 22:14 ` [PATCH 3/3] libvchan: interdomain communications library Daniel De Graaf
2011-09-30 7:51 ` [PATCH v6 0/3] libxenvchan: " Vasiliy Tolstov
2011-09-30 8:28 ` Vasiliy Tolstov
2011-09-30 14:40 ` Daniel De Graaf
2011-11-24 20:02 ` Anil Madhavapeddy
2011-11-25 16:53 ` Daniel De Graaf
2011-11-25 16:54 ` [PATCH] libxc: Fix checks on grant notify arguments Daniel De Graaf
2011-12-01 18:20 ` Ian Jackson
2011-11-25 16:56 ` [PATCH 1/2] xen/events: prevent calling evtchn_get on invlaid channels Daniel De Graaf
2011-11-25 16:56 ` [PATCH 2/2] xen/gntalloc: release grant references on page free Daniel De Graaf
2011-11-25 18:37 ` [PATCH] xen/gntalloc: fix reference counts on multi-page mappings Daniel De Graaf
2011-09-30 8:34 ` [PATCH v6 0/3] libxenvchan: interdomain communications library Ian Campbell
2011-09-30 8:37 ` [PATCH] libxc: osdep: report missing backends in common code Ian Campbell
2011-10-06 18:44 ` [PATCH v6 0/3] libxenvchan: interdomain communications library Ian Jackson
2011-10-07 8:41 ` Roger Pau Monné
2011-10-07 9:15 ` Keir Fraser
2011-10-07 9:48 ` Ian Jackson
2011-10-07 10:22 ` Roger Pau Monné
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=20110901192922.GB21520@dumpdata.com \
--to=konrad.wilk@oracle.com \
--cc=Ian.Campbell@eu.citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=Stefano.Stabellini@eu.citrix.com \
--cc=dgdegra@tycho.nsa.gov \
--cc=xen-devel@lists.xensource.com \
/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).