From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konrad Rzeszutek Wilk Subject: Re: [PATCH] xen-gntdev: Fix unmap notify on PV domains Date: Tue, 8 Feb 2011 17:58:56 -0500 Message-ID: <20110208225856.GA9714@dumpdata.com> References: <1296753544-13323-1-git-send-email-dgdegra@tycho.nsa.gov> <20110207231416.GA12956@dumpdata.com> <4D514FAE.4000709@tycho.nsa.gov> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <4D514FAE.4000709@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: jeremy@goop.org, xen-devel@lists.xensource.com, Ian.Campbell@citrix.com List-Id: xen-devel@lists.xenproject.org On Tue, Feb 08, 2011 at 09:14:06AM -0500, Daniel De Graaf wrote: > In paravirtualized guests, the struct page* for mappings is only a > placeholder, and cannot be used to access the granted memory. Use the > userspace mapping that we have set up in order to implement > UNMAP_NOTIFY_CLEAR_BYTE. > > Signed-off-by: Daniel De Graaf > > diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c > index 06de2c0..2b67f15 100644 > --- a/drivers/xen/gntdev.c > +++ b/drivers/xen/gntdev.c > @@ -287,7 +287,12 @@ static int unmap_grant_pages(struct grant_map *map, int offset, int pages) > > if (map->notify.flags & UNMAP_NOTIFY_CLEAR_BYTE) { > int pgno = (map->notify.addr >> PAGE_SHIFT); > - if (pgno >= offset && pgno < offset + pages) { > + if (pgno >= offset && pgno < offset + pages && use_ptemod) { > + void __user *tmp; > + tmp = map->vma->vm_start + map->notify.addr; > + copy_to_user(tmp, &err, 1); The compiler really hates that. You could use a uninitialized_value macro to ignore it. > + map->notify.flags &= ~UNMAP_NOTIFY_CLEAR_BYTE; > + } else if (pgno >= offset && pgno < offset + pages) { > uint8_t *tmp = kmap(map->pages[pgno]); > tmp[map->notify.addr & (PAGE_SIZE-1)] = 0; > kunmap(map->pages[pgno]); > @@ -296,7 +301,7 @@ static int unmap_grant_pages(struct grant_map *map, int offset, int pages) > } > > pr_debug("map %d+%d [%d+%d]\n", map->index, map->count, offset, pages); > - err = gnttab_unmap_refs(map->unmap_ops + offset, map->pages, pages); > + err = gnttab_unmap_refs(map->unmap_ops + offset, map->pages + offset, pages); > if (err) > return err; >