Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 80679
b: refs/heads/master
c: 80b14b5
h: refs/heads/master
i:
  80677: 569be10
  80675: 3ad2498
  80671: 6a3152e
v: v3
  • Loading branch information
Izik Eidus authored and Avi Kivity committed Jan 30, 2008
1 parent 8e04a14 commit c5b55ae
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5f43238d036fb30e73563e81e42d9c6f1de5551a
refs/heads/master: 80b14b5b32cb0a98234283daf9b5a6643e1a1ef3
1 change: 1 addition & 0 deletions trunk/drivers/kvm/kvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ struct kvm_memory_slot {
unsigned long *rmap;
unsigned long *dirty_bitmap;
unsigned long userspace_addr;
int user_alloc;
};

struct kvm {
Expand Down
14 changes: 14 additions & 0 deletions trunk/drivers/kvm/kvm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@ static int kvm_vm_ioctl_set_memory_region(struct kvm *kvm,

memset(new.rmap, 0, npages * sizeof(*new.rmap));

new.user_alloc = user_alloc;
if (user_alloc)
new.userspace_addr = mem->userspace_addr;
else {
Expand All @@ -727,6 +728,19 @@ static int kvm_vm_ioctl_set_memory_region(struct kvm *kvm,
if (IS_ERR((void *)new.userspace_addr))
goto out_unlock;
}
} else {
if (!old.user_alloc && old.rmap) {
int ret;

down_write(&current->mm->mmap_sem);
ret = do_munmap(current->mm, old.userspace_addr,
old.npages * PAGE_SIZE);
up_write(&current->mm->mmap_sem);
if (ret < 0)
printk(KERN_WARNING
"kvm_vm_ioctl_set_memory_region: "
"failed to munmap memory\n");
}
}

/* Allocate page dirty bitmap if needed */
Expand Down

0 comments on commit c5b55ae

Please sign in to comment.