]> xenbits.xensource.com Git - people/aperard/linux.git/commitdiff
xen/gntdev: provide find_special_page VMA operation grant-mapping-fix-backport-3.16
authorDavid Vrabel <david.vrabel@citrix.com>
Thu, 18 Dec 2014 14:59:07 +0000 (14:59 +0000)
committerAnthony PERARD <anthony.perard@citrix.com>
Thu, 7 May 2015 17:06:41 +0000 (18:06 +0100)
For a PV guest, use the find_special_page op to find the right page.
To handle VMAs being split, remember the start of the original VMA so
the correct index in the pages array can be calculated.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
(cherry picked from commit dab069c61aa386f6a46c620f3a1075a4818f285b)

drivers/xen/gntdev.c

index 20c65771017df5fb19ca475d836cb898f466e33f..d5bb1a33d0a3fc7337975734f4305038c1959723 100644 (file)
@@ -93,6 +93,7 @@ struct grant_map {
        struct gnttab_map_grant_ref   *kmap_ops;
        struct gnttab_unmap_grant_ref *kunmap_ops;
        struct page **pages;
+       unsigned long pages_vm_start;
 };
 
 static int unmap_grant_pages(struct grant_map *map, int offset, int pages);
@@ -446,9 +447,18 @@ static void gntdev_vma_close(struct vm_area_struct *vma)
        gntdev_put_map(priv, map);
 }
 
+static struct page *gntdev_vma_find_special_page(struct vm_area_struct *vma,
+                                                unsigned long addr)
+{
+       struct grant_map *map = vma->vm_private_data;
+
+       return map->pages[(addr - map->pages_vm_start) >> PAGE_SHIFT];
+}
+
 static struct vm_operations_struct gntdev_vmops = {
        .open = gntdev_vma_open,
        .close = gntdev_vma_close,
+       .find_special_page = gntdev_vma_find_special_page,
 };
 
 /* ------------------------------------------------------------------ */
@@ -874,6 +884,7 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)
                                            set_grant_ptes_as_special, NULL);
                }
 #endif
+               map->pages_vm_start = vma->vm_start;
        }
 
        return 0;