From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konrad Rzeszutek Wilk Subject: Re: [PATCH 1/6 v2] xenbus: Support HVM backends Date: Mon, 24 Oct 2011 17:55:46 -0400 Message-ID: <20111024215546.GK2441@phenom.dumpdata.com> References: <1319124957-32269-2-git-send-email-dgdegra@tycho.nsa.gov> <1319129284-521-1-git-send-email-dgdegra@tycho.nsa.gov> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <1319129284-521-1-git-send-email-dgdegra@tycho.nsa.gov> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Daniel De Graaf Cc: xen-devel@lists.xensource.com, Ian.Campbell@citrix.com, david.vrabel@citrix.com List-Id: xen-devel@lists.xenproject.org On Thu, Oct 20, 2011 at 12:48:04PM -0400, Daniel De Graaf wrote: > Initial version lacked the list_del in xenbus_unmap_ring_vfree_hvm > > -------------------------------------------------------->8 > > Add HVM implementations of xenbus_(map,unmap)_ring_v(alloc,free) so > that ring mappings can be done without using GNTMAP_contains_pte which > is not supported on HVM. > > Signed-off-by: Daniel De Graaf > --- > drivers/xen/xenbus/xenbus_client.c | 155 +++++++++++++++++++++++++++++------- > 1 files changed, 125 insertions(+), 30 deletions(-) > > diff --git a/drivers/xen/xenbus/xenbus_client.c b/drivers/xen/xenbus/xenbus_client.c > index 52bc57f..4b2fbcc 100644 > --- a/drivers/xen/xenbus/xenbus_client.c > +++ b/drivers/xen/xenbus/xenbus_client.c > @@ -32,15 +32,26 @@ > > #include > #include > +#include > #include > #include > #include > #include > #include > +#include > #include > #include > #include > > +struct xenbus_map_node { > + struct list_head next; > + struct page *page; > + grant_handle_t handle; > +}; > + > +static DEFINE_SPINLOCK(xenbus_valloc_lock); > +static LIST_HEAD(xenbus_valloc_pages); > + > const char *xenbus_strstate(enum xenbus_state state) > { > static const char *const name[] = { > @@ -419,21 +430,8 @@ int xenbus_free_evtchn(struct xenbus_device *dev, int port) > EXPORT_SYMBOL_GPL(xenbus_free_evtchn); > > > -/** > - * xenbus_map_ring_valloc > - * @dev: xenbus device > - * @gnt_ref: grant reference > - * @vaddr: pointer to address to be filled out by mapping > - * > - * Based on Rusty Russell's skeleton driver's map_page. > - * Map a page of memory into this domain from another domain's grant table. > - * xenbus_map_ring_valloc allocates a page of virtual address space, maps the > - * page to that address, and sets *vaddr to that address. > - * Returns 0 on success, and GNTST_* (see xen/include/interface/grant_table.h) > - * or -ENOMEM on error. If an error is returned, device will switch to > - * XenbusStateClosing and the error message will be saved in XenStore. > - */ > -int xenbus_map_ring_valloc(struct xenbus_device *dev, int gnt_ref, void **vaddr) > +static int xenbus_map_ring_valloc_pv(struct xenbus_device *dev, > + int gnt_ref, void **vaddr) > { > struct gnttab_map_grant_ref op = { > .flags = GNTMAP_host_map | GNTMAP_contains_pte, > @@ -468,6 +466,64 @@ int xenbus_map_ring_valloc(struct xenbus_device *dev, int gnt_ref, void **vaddr) > *vaddr = area->addr; > return 0; > } > + > +static int xenbus_map_ring_valloc_hvm(struct xenbus_device *dev, > + int gnt_ref, void **vaddr) > +{ > + struct xenbus_map_node *node; > + int err; > + void *addr; > + > + *vaddr = NULL; > + > + node = kzalloc(sizeof(*node), GFP_KERNEL); > + if (!node) > + return -ENOMEM; > + > + err = alloc_xenballooned_pages(1, &node->page, false); Add /* lowmem */ on the 'false' parameter.