diff options
-rw-r--r-- | drivers/xen/gntalloc.c | 14 | ||||
-rw-r--r-- | drivers/xen/gntdev.c | 16 |
2 files changed, 26 insertions, 4 deletions
diff --git a/drivers/xen/gntalloc.c b/drivers/xen/gntalloc.c index a7ffdfe19fc9..f6832f46aea4 100644 --- a/drivers/xen/gntalloc.c +++ b/drivers/xen/gntalloc.c | |||
@@ -427,6 +427,17 @@ static long gntalloc_ioctl(struct file *filp, unsigned int cmd, | |||
427 | return 0; | 427 | return 0; |
428 | } | 428 | } |
429 | 429 | ||
430 | static void gntalloc_vma_open(struct vm_area_struct *vma) | ||
431 | { | ||
432 | struct gntalloc_gref *gref = vma->vm_private_data; | ||
433 | if (!gref) | ||
434 | return; | ||
435 | |||
436 | spin_lock(&gref_lock); | ||
437 | gref->users++; | ||
438 | spin_unlock(&gref_lock); | ||
439 | } | ||
440 | |||
430 | static void gntalloc_vma_close(struct vm_area_struct *vma) | 441 | static void gntalloc_vma_close(struct vm_area_struct *vma) |
431 | { | 442 | { |
432 | struct gntalloc_gref *gref = vma->vm_private_data; | 443 | struct gntalloc_gref *gref = vma->vm_private_data; |
@@ -441,6 +452,7 @@ static void gntalloc_vma_close(struct vm_area_struct *vma) | |||
441 | } | 452 | } |
442 | 453 | ||
443 | static struct vm_operations_struct gntalloc_vmops = { | 454 | static struct vm_operations_struct gntalloc_vmops = { |
455 | .open = gntalloc_vma_open, | ||
444 | .close = gntalloc_vma_close, | 456 | .close = gntalloc_vma_close, |
445 | }; | 457 | }; |
446 | 458 | ||
@@ -471,8 +483,6 @@ static int gntalloc_mmap(struct file *filp, struct vm_area_struct *vma) | |||
471 | vma->vm_private_data = gref; | 483 | vma->vm_private_data = gref; |
472 | 484 | ||
473 | vma->vm_flags |= VM_RESERVED; | 485 | vma->vm_flags |= VM_RESERVED; |
474 | vma->vm_flags |= VM_DONTCOPY; | ||
475 | vma->vm_flags |= VM_PFNMAP | VM_PFN_AT_MMAP; | ||
476 | 486 | ||
477 | vma->vm_ops = &gntalloc_vmops; | 487 | vma->vm_ops = &gntalloc_vmops; |
478 | 488 | ||
diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c index d96d311b858e..687761f65e5c 100644 --- a/drivers/xen/gntdev.c +++ b/drivers/xen/gntdev.c | |||
@@ -358,17 +358,26 @@ static int unmap_grant_pages(struct grant_map *map, int offset, int pages) | |||
358 | 358 | ||
359 | /* ------------------------------------------------------------------ */ | 359 | /* ------------------------------------------------------------------ */ |
360 | 360 | ||
361 | static void gntdev_vma_open(struct vm_area_struct *vma) | ||
362 | { | ||
363 | struct grant_map *map = vma->vm_private_data; | ||
364 | |||
365 | pr_debug("gntdev_vma_open %p\n", vma); | ||
366 | atomic_inc(&map->users); | ||
367 | } | ||
368 | |||
361 | static void gntdev_vma_close(struct vm_area_struct *vma) | 369 | static void gntdev_vma_close(struct vm_area_struct *vma) |
362 | { | 370 | { |
363 | struct grant_map *map = vma->vm_private_data; | 371 | struct grant_map *map = vma->vm_private_data; |
364 | 372 | ||
365 | pr_debug("close %p\n", vma); | 373 | pr_debug("gntdev_vma_close %p\n", vma); |
366 | map->vma = NULL; | 374 | map->vma = NULL; |
367 | vma->vm_private_data = NULL; | 375 | vma->vm_private_data = NULL; |
368 | gntdev_put_map(map); | 376 | gntdev_put_map(map); |
369 | } | 377 | } |
370 | 378 | ||
371 | static struct vm_operations_struct gntdev_vmops = { | 379 | static struct vm_operations_struct gntdev_vmops = { |
380 | .open = gntdev_vma_open, | ||
372 | .close = gntdev_vma_close, | 381 | .close = gntdev_vma_close, |
373 | }; | 382 | }; |
374 | 383 | ||
@@ -680,7 +689,10 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma) | |||
680 | 689 | ||
681 | vma->vm_ops = &gntdev_vmops; | 690 | vma->vm_ops = &gntdev_vmops; |
682 | 691 | ||
683 | vma->vm_flags |= VM_RESERVED|VM_DONTCOPY|VM_DONTEXPAND|VM_PFNMAP; | 692 | vma->vm_flags |= VM_RESERVED|VM_DONTEXPAND; |
693 | |||
694 | if (use_ptemod) | ||
695 | vma->vm_flags |= VM_DONTCOPY|VM_PFNMAP; | ||
684 | 696 | ||
685 | vma->vm_private_data = map; | 697 | vma->vm_private_data = map; |
686 | 698 | ||