WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] xen: gntdev: move use of GNTMAP_contains_pte next to

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] xen: gntdev: move use of GNTMAP_contains_pte next to the map_op
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Wed, 8 Dec 2010 11:53:06 +0000
Cc: "Derek G. Murray" <Derek.Murray@xxxxxxxxxxxx>, Jeremy Fitzhardinge <jeremy@xxxxxxxx>, Gerd Hoffmann <kraxel@xxxxxxxxxx>, Ian Campbell <ian.campbell@xxxxxxxxxx>, Stefano Stabellini <Stefano.Stabellini@xxxxxxxxxxxxx>
Delivery-date: Wed, 08 Dec 2010 03:54:04 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
This flag controls the meaning of gnttab_map_grant_ref.host_addr and
specifies that the field contains a refernce to the pte entry to be
used to perform the mapping. Therefore move the use of this flag to
the point at which we actually use a reference to the pte instead of
something else, splitting up the usage of the flag in this way is
confusing and potentially error prone.

The other flags are all properties of the mapping itself as opposed to
properties of the hypercall arguments and therefore it make sense to
continue to pass them round in map->flags.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Cc: Jeremy Fitzhardinge <jeremy@xxxxxxxx>
Cc: Stefano Stabellini <Stefano.Stabellini@xxxxxxxxxxxxx>
Cc: Derek G. Murray <Derek.Murray@xxxxxxxxxxxx>
Cc: Gerd Hoffmann <kraxel@xxxxxxxxxx>
---
 drivers/xen/gntdev.c    |    5 +++--
 drivers/xen/hypercall.c |   18 ++++++++++++++----
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
index a33e443..295254b 100644
--- a/drivers/xen/gntdev.c
+++ b/drivers/xen/gntdev.c
@@ -204,7 +204,8 @@ static int find_grant_ptes(pte_t *pte, pgtable_t token, 
unsigned long addr, void
        BUG_ON(pgnr >= map->count);
        pte_maddr  = (u64)pfn_to_mfn(page_to_pfn(token)) << PAGE_SHIFT;
        pte_maddr += (unsigned long)pte & ~PAGE_MASK;
-       gnttab_set_map_op(&map->map_ops[pgnr], pte_maddr, map->flags,
+       gnttab_set_map_op(&map->map_ops[pgnr], pte_maddr,
+                         GNTMAP_contains_pte | map->flags,
                          map->grants[pgnr].ref,
                          map->grants[pgnr].domid);
        gnttab_set_unmap_op(&map->unmap_ops[pgnr], pte_maddr, map->flags,
@@ -577,7 +578,7 @@ static int gntdev_mmap(struct file *flip, struct 
vm_area_struct *vma)
        vma->vm_private_data = map;
        map->vma = vma;
 
-       map->flags = GNTMAP_host_map | GNTMAP_application_map | 
GNTMAP_contains_pte;
+       map->flags = GNTMAP_host_map | GNTMAP_application_map;
        if (!(vma->vm_flags & VM_WRITE))
                map->flags |= GNTMAP_readonly;
 
diff --git a/drivers/xen/hypercall.c b/drivers/xen/hypercall.c
index 4eb6b34..054826b 100644
--- a/drivers/xen/hypercall.c
+++ b/drivers/xen/hypercall.c
@@ -11,6 +11,7 @@
 #include <asm/xen/hypercall.h>
 
 struct mmap_hypercall {
+       spinlock_t lock;
        struct list_head list;
 };
 
@@ -67,14 +68,16 @@ static void hypercall_vm_open(struct vm_area_struct * vma)
 static void hypercall_vm_close(struct vm_area_struct * vma)
 {
        struct mmap_hypercall *priv = vma->vm_private_data;
-       struct page *page;
+       struct page *page, *tpage;
        printk(KERN_CRIT "hypercall_vm_close: vma %p %#lx-%#lx (%#lx) priv 
%p\n",
               vma, vma->vm_start, vma->vm_end, vma->vm_end - vma->vm_start, 
priv);
 
-       list_for_each_entry(page, &priv->list, lru) {
+       spin_lock(&priv->lock);
+       list_for_each_entry_safe(page, tpage, &priv->list, lru) {
                printk(KERN_CRIT "hypercall vm_close: page %p count %d\n", 
page, page_count(page));
                __free_page(page);
        }
+       spin_unlock(&priv->lock);
        vma->vm_private_data = NULL;
        kfree(priv);
 }
@@ -99,8 +102,10 @@ static int hypercall_mmap(struct file *file, struct 
vm_area_struct *vma)
        printk(KERN_CRIT "hypercall interface mmaped by %s: vma %p %#lx-%#lx 
(%#lx) priv %p\n",
               current->comm, vma, vma->vm_start, vma->vm_end, vma->vm_end - 
vma->vm_start, priv);
 
+       spin_lock_init(&priv->lock);
        INIT_LIST_HEAD(&priv->list);
 
+       spin_lock(&priv->lock);
        for (address = vma->vm_start; address < vma->vm_end; address += 
PAGE_SIZE)
        {
                struct page *page = alloc_page(GFP_KERNEL|__GFP_ZERO); 
//get_zeroed_page(GFP_KERNEL);
@@ -112,17 +117,22 @@ static int hypercall_mmap(struct file *file, struct 
vm_area_struct *vma)
                printk(KERN_CONT " vm_insert_page -> %d count %d", ret, 
page_count(page));
                if (ret) {
                        printk(KERN_CONT ": failure!\n");
-                       return -EINVAL;
+                       goto out_unlock;
                }
                printk(KERN_CONT " %p<-page->%p\n", page->lru.prev, 
page->lru.next);
                list_add_tail(&page->lru, &priv->list);
        }
+       spin_unlock(&priv->lock);
 
-       vma->vm_flags |= VM_RESERVED | VM_DONTCOPY;
+       vma->vm_flags |= VM_RESERVED | VM_IO | VM_DONTCOPY | VM_PFNMAP;
+       //vma->vm_flags |= VM_RESERVED | VM_DONTCOPY;
        vma->vm_ops = &hypercall_vm_ops;
        vma->vm_private_data = priv;
 
        return 0;
+out_unlock:
+       spin_unlock(&priv->lock);
+       return -EINVAL;
 }
 
 static int hypercall_open(struct inode *inode, struct file *file)
-- 
1.5.6.5


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>