diff options
Diffstat (limited to 'arch/ia64/kvm/kvm-ia64.c')
-rw-r--r-- | arch/ia64/kvm/kvm-ia64.c | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c index 5fdeec5fddcf..26e0e089bfe7 100644 --- a/arch/ia64/kvm/kvm-ia64.c +++ b/arch/ia64/kvm/kvm-ia64.c | |||
@@ -241,10 +241,10 @@ static int handle_mmio(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) | |||
241 | return 0; | 241 | return 0; |
242 | mmio: | 242 | mmio: |
243 | if (p->dir) | 243 | if (p->dir) |
244 | r = kvm_io_bus_read(&vcpu->kvm->mmio_bus, p->addr, | 244 | r = kvm_io_bus_read(vcpu->kvm, KVM_MMIO_BUS, p->addr, |
245 | p->size, &p->data); | 245 | p->size, &p->data); |
246 | else | 246 | else |
247 | r = kvm_io_bus_write(&vcpu->kvm->mmio_bus, p->addr, | 247 | r = kvm_io_bus_write(vcpu->kvm, KVM_MMIO_BUS, p->addr, |
248 | p->size, &p->data); | 248 | p->size, &p->data); |
249 | if (r) | 249 | if (r) |
250 | printk(KERN_ERR"kvm: No iodevice found! addr:%lx\n", p->addr); | 250 | printk(KERN_ERR"kvm: No iodevice found! addr:%lx\n", p->addr); |
@@ -636,12 +636,9 @@ static void kvm_vcpu_post_transition(struct kvm_vcpu *vcpu) | |||
636 | static int __vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) | 636 | static int __vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) |
637 | { | 637 | { |
638 | union context *host_ctx, *guest_ctx; | 638 | union context *host_ctx, *guest_ctx; |
639 | int r; | 639 | int r, idx; |
640 | 640 | ||
641 | /* | 641 | idx = srcu_read_lock(&vcpu->kvm->srcu); |
642 | * down_read() may sleep and return with interrupts enabled | ||
643 | */ | ||
644 | down_read(&vcpu->kvm->slots_lock); | ||
645 | 642 | ||
646 | again: | 643 | again: |
647 | if (signal_pending(current)) { | 644 | if (signal_pending(current)) { |
@@ -663,7 +660,7 @@ again: | |||
663 | if (r < 0) | 660 | if (r < 0) |
664 | goto vcpu_run_fail; | 661 | goto vcpu_run_fail; |
665 | 662 | ||
666 | up_read(&vcpu->kvm->slots_lock); | 663 | srcu_read_unlock(&vcpu->kvm->srcu, idx); |
667 | kvm_guest_enter(); | 664 | kvm_guest_enter(); |
668 | 665 | ||
669 | /* | 666 | /* |
@@ -687,7 +684,7 @@ again: | |||
687 | kvm_guest_exit(); | 684 | kvm_guest_exit(); |
688 | preempt_enable(); | 685 | preempt_enable(); |
689 | 686 | ||
690 | down_read(&vcpu->kvm->slots_lock); | 687 | idx = srcu_read_lock(&vcpu->kvm->srcu); |
691 | 688 | ||
692 | r = kvm_handle_exit(kvm_run, vcpu); | 689 | r = kvm_handle_exit(kvm_run, vcpu); |
693 | 690 | ||
@@ -697,10 +694,10 @@ again: | |||
697 | } | 694 | } |
698 | 695 | ||
699 | out: | 696 | out: |
700 | up_read(&vcpu->kvm->slots_lock); | 697 | srcu_read_unlock(&vcpu->kvm->srcu, idx); |
701 | if (r > 0) { | 698 | if (r > 0) { |
702 | kvm_resched(vcpu); | 699 | kvm_resched(vcpu); |
703 | down_read(&vcpu->kvm->slots_lock); | 700 | idx = srcu_read_lock(&vcpu->kvm->srcu); |
704 | goto again; | 701 | goto again; |
705 | } | 702 | } |
706 | 703 | ||
@@ -971,7 +968,7 @@ long kvm_arch_vm_ioctl(struct file *filp, | |||
971 | goto out; | 968 | goto out; |
972 | r = kvm_setup_default_irq_routing(kvm); | 969 | r = kvm_setup_default_irq_routing(kvm); |
973 | if (r) { | 970 | if (r) { |
974 | kfree(kvm->arch.vioapic); | 971 | kvm_ioapic_destroy(kvm); |
975 | goto out; | 972 | goto out; |
976 | } | 973 | } |
977 | break; | 974 | break; |
@@ -1377,12 +1374,14 @@ static void free_kvm(struct kvm *kvm) | |||
1377 | 1374 | ||
1378 | static void kvm_release_vm_pages(struct kvm *kvm) | 1375 | static void kvm_release_vm_pages(struct kvm *kvm) |
1379 | { | 1376 | { |
1377 | struct kvm_memslots *slots; | ||
1380 | struct kvm_memory_slot *memslot; | 1378 | struct kvm_memory_slot *memslot; |
1381 | int i, j; | 1379 | int i, j; |
1382 | unsigned long base_gfn; | 1380 | unsigned long base_gfn; |
1383 | 1381 | ||
1384 | for (i = 0; i < kvm->nmemslots; i++) { | 1382 | slots = rcu_dereference(kvm->memslots); |
1385 | memslot = &kvm->memslots[i]; | 1383 | for (i = 0; i < slots->nmemslots; i++) { |
1384 | memslot = &slots->memslots[i]; | ||
1386 | base_gfn = memslot->base_gfn; | 1385 | base_gfn = memslot->base_gfn; |
1387 | 1386 | ||
1388 | for (j = 0; j < memslot->npages; j++) { | 1387 | for (j = 0; j < memslot->npages; j++) { |
@@ -1405,6 +1404,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm) | |||
1405 | kfree(kvm->arch.vioapic); | 1404 | kfree(kvm->arch.vioapic); |
1406 | kvm_release_vm_pages(kvm); | 1405 | kvm_release_vm_pages(kvm); |
1407 | kvm_free_physmem(kvm); | 1406 | kvm_free_physmem(kvm); |
1407 | cleanup_srcu_struct(&kvm->srcu); | ||
1408 | free_kvm(kvm); | 1408 | free_kvm(kvm); |
1409 | } | 1409 | } |
1410 | 1410 | ||
@@ -1576,15 +1576,15 @@ out: | |||
1576 | return r; | 1576 | return r; |
1577 | } | 1577 | } |
1578 | 1578 | ||
1579 | int kvm_arch_set_memory_region(struct kvm *kvm, | 1579 | int kvm_arch_prepare_memory_region(struct kvm *kvm, |
1580 | struct kvm_userspace_memory_region *mem, | 1580 | struct kvm_memory_slot *memslot, |
1581 | struct kvm_memory_slot old, | 1581 | struct kvm_memory_slot old, |
1582 | struct kvm_userspace_memory_region *mem, | ||
1582 | int user_alloc) | 1583 | int user_alloc) |
1583 | { | 1584 | { |
1584 | unsigned long i; | 1585 | unsigned long i; |
1585 | unsigned long pfn; | 1586 | unsigned long pfn; |
1586 | int npages = mem->memory_size >> PAGE_SHIFT; | 1587 | int npages = memslot->npages; |
1587 | struct kvm_memory_slot *memslot = &kvm->memslots[mem->slot]; | ||
1588 | unsigned long base_gfn = memslot->base_gfn; | 1588 | unsigned long base_gfn = memslot->base_gfn; |
1589 | 1589 | ||
1590 | if (base_gfn + npages > (KVM_MAX_MEM_SIZE >> PAGE_SHIFT)) | 1590 | if (base_gfn + npages > (KVM_MAX_MEM_SIZE >> PAGE_SHIFT)) |
@@ -1608,6 +1608,14 @@ int kvm_arch_set_memory_region(struct kvm *kvm, | |||
1608 | return 0; | 1608 | return 0; |
1609 | } | 1609 | } |
1610 | 1610 | ||
1611 | void kvm_arch_commit_memory_region(struct kvm *kvm, | ||
1612 | struct kvm_userspace_memory_region *mem, | ||
1613 | struct kvm_memory_slot old, | ||
1614 | int user_alloc) | ||
1615 | { | ||
1616 | return; | ||
1617 | } | ||
1618 | |||
1611 | void kvm_arch_flush_shadow(struct kvm *kvm) | 1619 | void kvm_arch_flush_shadow(struct kvm *kvm) |
1612 | { | 1620 | { |
1613 | kvm_flush_remote_tlbs(kvm); | 1621 | kvm_flush_remote_tlbs(kvm); |
@@ -1802,7 +1810,7 @@ static int kvm_ia64_sync_dirty_log(struct kvm *kvm, | |||
1802 | if (log->slot >= KVM_MEMORY_SLOTS) | 1810 | if (log->slot >= KVM_MEMORY_SLOTS) |
1803 | goto out; | 1811 | goto out; |
1804 | 1812 | ||
1805 | memslot = &kvm->memslots[log->slot]; | 1813 | memslot = &kvm->memslots->memslots[log->slot]; |
1806 | r = -ENOENT; | 1814 | r = -ENOENT; |
1807 | if (!memslot->dirty_bitmap) | 1815 | if (!memslot->dirty_bitmap) |
1808 | goto out; | 1816 | goto out; |
@@ -1827,6 +1835,7 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, | |||
1827 | struct kvm_memory_slot *memslot; | 1835 | struct kvm_memory_slot *memslot; |
1828 | int is_dirty = 0; | 1836 | int is_dirty = 0; |
1829 | 1837 | ||
1838 | mutex_lock(&kvm->slots_lock); | ||
1830 | spin_lock(&kvm->arch.dirty_log_lock); | 1839 | spin_lock(&kvm->arch.dirty_log_lock); |
1831 | 1840 | ||
1832 | r = kvm_ia64_sync_dirty_log(kvm, log); | 1841 | r = kvm_ia64_sync_dirty_log(kvm, log); |
@@ -1840,12 +1849,13 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, | |||
1840 | /* If nothing is dirty, don't bother messing with page tables. */ | 1849 | /* If nothing is dirty, don't bother messing with page tables. */ |
1841 | if (is_dirty) { | 1850 | if (is_dirty) { |
1842 | kvm_flush_remote_tlbs(kvm); | 1851 | kvm_flush_remote_tlbs(kvm); |
1843 | memslot = &kvm->memslots[log->slot]; | 1852 | memslot = &kvm->memslots->memslots[log->slot]; |
1844 | n = ALIGN(memslot->npages, BITS_PER_LONG) / 8; | 1853 | n = ALIGN(memslot->npages, BITS_PER_LONG) / 8; |
1845 | memset(memslot->dirty_bitmap, 0, n); | 1854 | memset(memslot->dirty_bitmap, 0, n); |
1846 | } | 1855 | } |
1847 | r = 0; | 1856 | r = 0; |
1848 | out: | 1857 | out: |
1858 | mutex_unlock(&kvm->slots_lock); | ||
1849 | spin_unlock(&kvm->arch.dirty_log_lock); | 1859 | spin_unlock(&kvm->arch.dirty_log_lock); |
1850 | return r; | 1860 | return r; |
1851 | } | 1861 | } |