Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 356786
b: refs/heads/master
c: e40f193
h: refs/heads/master
v: v3
  • Loading branch information
Alex Williamson authored and Marcelo Tosatti committed Dec 14, 2012
1 parent b31180d commit 90b3c2b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9c695d42dbd465bcaa865603b411a73c60e60978
refs/heads/master: e40f193f5bb022e927a57a4f5d5194e4f12ddb74
19 changes: 11 additions & 8 deletions trunk/virt/kvm/kvm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,8 @@ int __kvm_set_memory_region(struct kvm *kvm,
old_memslots = kvm->memslots;
rcu_assign_pointer(kvm->memslots, slots);
synchronize_srcu_expedited(&kvm->srcu);
/* slot was deleted or moved, clear iommu mapping */
kvm_iommu_unmap_pages(kvm, &old);
/* From this point no new shadow pages pointing to a deleted,
* or moved, memslot will be created.
*
Expand All @@ -837,20 +839,19 @@ int __kvm_set_memory_region(struct kvm *kvm,
if (r)
goto out_free;

/* map/unmap the pages in iommu page table */
if (npages) {
r = kvm_iommu_map_pages(kvm, &new);
if (r)
goto out_free;
} else
kvm_iommu_unmap_pages(kvm, &old);

r = -ENOMEM;
slots = kmemdup(kvm->memslots, sizeof(struct kvm_memslots),
GFP_KERNEL);
if (!slots)
goto out_free;

/* map new memory slot into the iommu */
if (npages) {
r = kvm_iommu_map_pages(kvm, &new);
if (r)
goto out_slots;
}

/* actual memory is freed via old in kvm_free_physmem_slot below */
if (!npages) {
new.dirty_bitmap = NULL;
Expand All @@ -869,6 +870,8 @@ int __kvm_set_memory_region(struct kvm *kvm,

return 0;

out_slots:
kfree(slots);
out_free:
kvm_free_physmem_slot(&new, &old);
out:
Expand Down

0 comments on commit 90b3c2b

Please sign in to comment.