diff options
Diffstat (limited to 'arch/ia64/kvm')
-rw-r--r-- | arch/ia64/kvm/Kconfig | 2 | ||||
-rw-r--r-- | arch/ia64/kvm/kvm-ia64.c | 67 | ||||
-rw-r--r-- | arch/ia64/kvm/kvm_fw.c | 28 | ||||
-rw-r--r-- | arch/ia64/kvm/mmio.c | 4 | ||||
-rw-r--r-- | arch/ia64/kvm/vcpu.c | 4 | ||||
-rw-r--r-- | arch/ia64/kvm/vmm.c | 2 |
6 files changed, 61 insertions, 46 deletions
diff --git a/arch/ia64/kvm/Kconfig b/arch/ia64/kvm/Kconfig index ef3e7be29caf..fa4d1e59deb0 100644 --- a/arch/ia64/kvm/Kconfig +++ b/arch/ia64/kvm/Kconfig | |||
@@ -26,6 +26,7 @@ config KVM | |||
26 | select ANON_INODES | 26 | select ANON_INODES |
27 | select HAVE_KVM_IRQCHIP | 27 | select HAVE_KVM_IRQCHIP |
28 | select KVM_APIC_ARCHITECTURE | 28 | select KVM_APIC_ARCHITECTURE |
29 | select KVM_MMIO | ||
29 | ---help--- | 30 | ---help--- |
30 | Support hosting fully virtualized guest machines using hardware | 31 | Support hosting fully virtualized guest machines using hardware |
31 | virtualization extensions. You will need a fairly recent | 32 | virtualization extensions. You will need a fairly recent |
@@ -47,6 +48,7 @@ config KVM_INTEL | |||
47 | Provides support for KVM on Itanium 2 processors equipped with the VT | 48 | Provides support for KVM on Itanium 2 processors equipped with the VT |
48 | extensions. | 49 | extensions. |
49 | 50 | ||
51 | source drivers/vhost/Kconfig | ||
50 | source drivers/virtio/Kconfig | 52 | source drivers/virtio/Kconfig |
51 | 53 | ||
52 | endif # VIRTUALIZATION | 54 | endif # VIRTUALIZATION |
diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c index 5fdeec5fddcf..d5f4e9161201 100644 --- a/arch/ia64/kvm/kvm-ia64.c +++ b/arch/ia64/kvm/kvm-ia64.c | |||
@@ -23,8 +23,8 @@ | |||
23 | #include <linux/module.h> | 23 | #include <linux/module.h> |
24 | #include <linux/errno.h> | 24 | #include <linux/errno.h> |
25 | #include <linux/percpu.h> | 25 | #include <linux/percpu.h> |
26 | #include <linux/gfp.h> | ||
27 | #include <linux/fs.h> | 26 | #include <linux/fs.h> |
27 | #include <linux/slab.h> | ||
28 | #include <linux/smp.h> | 28 | #include <linux/smp.h> |
29 | #include <linux/kvm_host.h> | 29 | #include <linux/kvm_host.h> |
30 | #include <linux/kvm.h> | 30 | #include <linux/kvm.h> |
@@ -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; |
@@ -982,11 +979,13 @@ long kvm_arch_vm_ioctl(struct file *filp, | |||
982 | r = -EFAULT; | 979 | r = -EFAULT; |
983 | if (copy_from_user(&irq_event, argp, sizeof irq_event)) | 980 | if (copy_from_user(&irq_event, argp, sizeof irq_event)) |
984 | goto out; | 981 | goto out; |
982 | r = -ENXIO; | ||
985 | if (irqchip_in_kernel(kvm)) { | 983 | if (irqchip_in_kernel(kvm)) { |
986 | __s32 status; | 984 | __s32 status; |
987 | status = kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID, | 985 | status = kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID, |
988 | irq_event.irq, irq_event.level); | 986 | irq_event.irq, irq_event.level); |
989 | if (ioctl == KVM_IRQ_LINE_STATUS) { | 987 | if (ioctl == KVM_IRQ_LINE_STATUS) { |
988 | r = -EFAULT; | ||
990 | irq_event.status = status; | 989 | irq_event.status = status; |
991 | if (copy_to_user(argp, &irq_event, | 990 | if (copy_to_user(argp, &irq_event, |
992 | sizeof irq_event)) | 991 | sizeof irq_event)) |
@@ -1377,12 +1376,14 @@ static void free_kvm(struct kvm *kvm) | |||
1377 | 1376 | ||
1378 | static void kvm_release_vm_pages(struct kvm *kvm) | 1377 | static void kvm_release_vm_pages(struct kvm *kvm) |
1379 | { | 1378 | { |
1379 | struct kvm_memslots *slots; | ||
1380 | struct kvm_memory_slot *memslot; | 1380 | struct kvm_memory_slot *memslot; |
1381 | int i, j; | 1381 | int i, j; |
1382 | unsigned long base_gfn; | 1382 | unsigned long base_gfn; |
1383 | 1383 | ||
1384 | for (i = 0; i < kvm->nmemslots; i++) { | 1384 | slots = kvm_memslots(kvm); |
1385 | memslot = &kvm->memslots[i]; | 1385 | for (i = 0; i < slots->nmemslots; i++) { |
1386 | memslot = &slots->memslots[i]; | ||
1386 | base_gfn = memslot->base_gfn; | 1387 | base_gfn = memslot->base_gfn; |
1387 | 1388 | ||
1388 | for (j = 0; j < memslot->npages; j++) { | 1389 | for (j = 0; j < memslot->npages; j++) { |
@@ -1405,6 +1406,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm) | |||
1405 | kfree(kvm->arch.vioapic); | 1406 | kfree(kvm->arch.vioapic); |
1406 | kvm_release_vm_pages(kvm); | 1407 | kvm_release_vm_pages(kvm); |
1407 | kvm_free_physmem(kvm); | 1408 | kvm_free_physmem(kvm); |
1409 | cleanup_srcu_struct(&kvm->srcu); | ||
1408 | free_kvm(kvm); | 1410 | free_kvm(kvm); |
1409 | } | 1411 | } |
1410 | 1412 | ||
@@ -1535,8 +1537,10 @@ long kvm_arch_vcpu_ioctl(struct file *filp, | |||
1535 | goto out; | 1537 | goto out; |
1536 | 1538 | ||
1537 | if (copy_to_user(user_stack, stack, | 1539 | if (copy_to_user(user_stack, stack, |
1538 | sizeof(struct kvm_ia64_vcpu_stack))) | 1540 | sizeof(struct kvm_ia64_vcpu_stack))) { |
1541 | r = -EFAULT; | ||
1539 | goto out; | 1542 | goto out; |
1543 | } | ||
1540 | 1544 | ||
1541 | break; | 1545 | break; |
1542 | } | 1546 | } |
@@ -1576,15 +1580,15 @@ out: | |||
1576 | return r; | 1580 | return r; |
1577 | } | 1581 | } |
1578 | 1582 | ||
1579 | int kvm_arch_set_memory_region(struct kvm *kvm, | 1583 | int kvm_arch_prepare_memory_region(struct kvm *kvm, |
1580 | struct kvm_userspace_memory_region *mem, | 1584 | struct kvm_memory_slot *memslot, |
1581 | struct kvm_memory_slot old, | 1585 | struct kvm_memory_slot old, |
1586 | struct kvm_userspace_memory_region *mem, | ||
1582 | int user_alloc) | 1587 | int user_alloc) |
1583 | { | 1588 | { |
1584 | unsigned long i; | 1589 | unsigned long i; |
1585 | unsigned long pfn; | 1590 | unsigned long pfn; |
1586 | int npages = mem->memory_size >> PAGE_SHIFT; | 1591 | int npages = memslot->npages; |
1587 | struct kvm_memory_slot *memslot = &kvm->memslots[mem->slot]; | ||
1588 | unsigned long base_gfn = memslot->base_gfn; | 1592 | unsigned long base_gfn = memslot->base_gfn; |
1589 | 1593 | ||
1590 | if (base_gfn + npages > (KVM_MAX_MEM_SIZE >> PAGE_SHIFT)) | 1594 | if (base_gfn + npages > (KVM_MAX_MEM_SIZE >> PAGE_SHIFT)) |
@@ -1608,6 +1612,14 @@ int kvm_arch_set_memory_region(struct kvm *kvm, | |||
1608 | return 0; | 1612 | return 0; |
1609 | } | 1613 | } |
1610 | 1614 | ||
1615 | void kvm_arch_commit_memory_region(struct kvm *kvm, | ||
1616 | struct kvm_userspace_memory_region *mem, | ||
1617 | struct kvm_memory_slot old, | ||
1618 | int user_alloc) | ||
1619 | { | ||
1620 | return; | ||
1621 | } | ||
1622 | |||
1611 | void kvm_arch_flush_shadow(struct kvm *kvm) | 1623 | void kvm_arch_flush_shadow(struct kvm *kvm) |
1612 | { | 1624 | { |
1613 | kvm_flush_remote_tlbs(kvm); | 1625 | kvm_flush_remote_tlbs(kvm); |
@@ -1794,7 +1806,8 @@ static int kvm_ia64_sync_dirty_log(struct kvm *kvm, | |||
1794 | { | 1806 | { |
1795 | struct kvm_memory_slot *memslot; | 1807 | struct kvm_memory_slot *memslot; |
1796 | int r, i; | 1808 | int r, i; |
1797 | long n, base; | 1809 | long base; |
1810 | unsigned long n; | ||
1798 | unsigned long *dirty_bitmap = (unsigned long *)(kvm->arch.vm_base + | 1811 | unsigned long *dirty_bitmap = (unsigned long *)(kvm->arch.vm_base + |
1799 | offsetof(struct kvm_vm_data, kvm_mem_dirty_log)); | 1812 | offsetof(struct kvm_vm_data, kvm_mem_dirty_log)); |
1800 | 1813 | ||
@@ -1802,12 +1815,12 @@ static int kvm_ia64_sync_dirty_log(struct kvm *kvm, | |||
1802 | if (log->slot >= KVM_MEMORY_SLOTS) | 1815 | if (log->slot >= KVM_MEMORY_SLOTS) |
1803 | goto out; | 1816 | goto out; |
1804 | 1817 | ||
1805 | memslot = &kvm->memslots[log->slot]; | 1818 | memslot = &kvm->memslots->memslots[log->slot]; |
1806 | r = -ENOENT; | 1819 | r = -ENOENT; |
1807 | if (!memslot->dirty_bitmap) | 1820 | if (!memslot->dirty_bitmap) |
1808 | goto out; | 1821 | goto out; |
1809 | 1822 | ||
1810 | n = ALIGN(memslot->npages, BITS_PER_LONG) / 8; | 1823 | n = kvm_dirty_bitmap_bytes(memslot); |
1811 | base = memslot->base_gfn / BITS_PER_LONG; | 1824 | base = memslot->base_gfn / BITS_PER_LONG; |
1812 | 1825 | ||
1813 | for (i = 0; i < n/sizeof(long); ++i) { | 1826 | for (i = 0; i < n/sizeof(long); ++i) { |
@@ -1823,10 +1836,11 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, | |||
1823 | struct kvm_dirty_log *log) | 1836 | struct kvm_dirty_log *log) |
1824 | { | 1837 | { |
1825 | int r; | 1838 | int r; |
1826 | int n; | 1839 | unsigned long n; |
1827 | struct kvm_memory_slot *memslot; | 1840 | struct kvm_memory_slot *memslot; |
1828 | int is_dirty = 0; | 1841 | int is_dirty = 0; |
1829 | 1842 | ||
1843 | mutex_lock(&kvm->slots_lock); | ||
1830 | spin_lock(&kvm->arch.dirty_log_lock); | 1844 | spin_lock(&kvm->arch.dirty_log_lock); |
1831 | 1845 | ||
1832 | r = kvm_ia64_sync_dirty_log(kvm, log); | 1846 | r = kvm_ia64_sync_dirty_log(kvm, log); |
@@ -1840,12 +1854,13 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, | |||
1840 | /* If nothing is dirty, don't bother messing with page tables. */ | 1854 | /* If nothing is dirty, don't bother messing with page tables. */ |
1841 | if (is_dirty) { | 1855 | if (is_dirty) { |
1842 | kvm_flush_remote_tlbs(kvm); | 1856 | kvm_flush_remote_tlbs(kvm); |
1843 | memslot = &kvm->memslots[log->slot]; | 1857 | memslot = &kvm->memslots->memslots[log->slot]; |
1844 | n = ALIGN(memslot->npages, BITS_PER_LONG) / 8; | 1858 | n = kvm_dirty_bitmap_bytes(memslot); |
1845 | memset(memslot->dirty_bitmap, 0, n); | 1859 | memset(memslot->dirty_bitmap, 0, n); |
1846 | } | 1860 | } |
1847 | r = 0; | 1861 | r = 0; |
1848 | out: | 1862 | out: |
1863 | mutex_unlock(&kvm->slots_lock); | ||
1849 | spin_unlock(&kvm->arch.dirty_log_lock); | 1864 | spin_unlock(&kvm->arch.dirty_log_lock); |
1850 | return r; | 1865 | return r; |
1851 | } | 1866 | } |
diff --git a/arch/ia64/kvm/kvm_fw.c b/arch/ia64/kvm/kvm_fw.c index e4b82319881d..cb548ee9fcae 100644 --- a/arch/ia64/kvm/kvm_fw.c +++ b/arch/ia64/kvm/kvm_fw.c | |||
@@ -75,7 +75,7 @@ static void set_pal_result(struct kvm_vcpu *vcpu, | |||
75 | struct exit_ctl_data *p; | 75 | struct exit_ctl_data *p; |
76 | 76 | ||
77 | p = kvm_get_exit_data(vcpu); | 77 | p = kvm_get_exit_data(vcpu); |
78 | if (p && p->exit_reason == EXIT_REASON_PAL_CALL) { | 78 | if (p->exit_reason == EXIT_REASON_PAL_CALL) { |
79 | p->u.pal_data.ret = result; | 79 | p->u.pal_data.ret = result; |
80 | return ; | 80 | return ; |
81 | } | 81 | } |
@@ -87,7 +87,7 @@ static void set_sal_result(struct kvm_vcpu *vcpu, | |||
87 | struct exit_ctl_data *p; | 87 | struct exit_ctl_data *p; |
88 | 88 | ||
89 | p = kvm_get_exit_data(vcpu); | 89 | p = kvm_get_exit_data(vcpu); |
90 | if (p && p->exit_reason == EXIT_REASON_SAL_CALL) { | 90 | if (p->exit_reason == EXIT_REASON_SAL_CALL) { |
91 | p->u.sal_data.ret = result; | 91 | p->u.sal_data.ret = result; |
92 | return ; | 92 | return ; |
93 | } | 93 | } |
@@ -322,7 +322,7 @@ static u64 kvm_get_pal_call_index(struct kvm_vcpu *vcpu) | |||
322 | struct exit_ctl_data *p; | 322 | struct exit_ctl_data *p; |
323 | 323 | ||
324 | p = kvm_get_exit_data(vcpu); | 324 | p = kvm_get_exit_data(vcpu); |
325 | if (p && (p->exit_reason == EXIT_REASON_PAL_CALL)) | 325 | if (p->exit_reason == EXIT_REASON_PAL_CALL) |
326 | index = p->u.pal_data.gr28; | 326 | index = p->u.pal_data.gr28; |
327 | 327 | ||
328 | return index; | 328 | return index; |
@@ -646,18 +646,16 @@ static void kvm_get_sal_call_data(struct kvm_vcpu *vcpu, u64 *in0, u64 *in1, | |||
646 | 646 | ||
647 | p = kvm_get_exit_data(vcpu); | 647 | p = kvm_get_exit_data(vcpu); |
648 | 648 | ||
649 | if (p) { | 649 | if (p->exit_reason == EXIT_REASON_SAL_CALL) { |
650 | if (p->exit_reason == EXIT_REASON_SAL_CALL) { | 650 | *in0 = p->u.sal_data.in0; |
651 | *in0 = p->u.sal_data.in0; | 651 | *in1 = p->u.sal_data.in1; |
652 | *in1 = p->u.sal_data.in1; | 652 | *in2 = p->u.sal_data.in2; |
653 | *in2 = p->u.sal_data.in2; | 653 | *in3 = p->u.sal_data.in3; |
654 | *in3 = p->u.sal_data.in3; | 654 | *in4 = p->u.sal_data.in4; |
655 | *in4 = p->u.sal_data.in4; | 655 | *in5 = p->u.sal_data.in5; |
656 | *in5 = p->u.sal_data.in5; | 656 | *in6 = p->u.sal_data.in6; |
657 | *in6 = p->u.sal_data.in6; | 657 | *in7 = p->u.sal_data.in7; |
658 | *in7 = p->u.sal_data.in7; | 658 | return ; |
659 | return ; | ||
660 | } | ||
661 | } | 659 | } |
662 | *in0 = 0; | 660 | *in0 = 0; |
663 | } | 661 | } |
diff --git a/arch/ia64/kvm/mmio.c b/arch/ia64/kvm/mmio.c index 9bf55afd08d0..fb8f9f59a1ed 100644 --- a/arch/ia64/kvm/mmio.c +++ b/arch/ia64/kvm/mmio.c | |||
@@ -316,8 +316,8 @@ void emulate_io_inst(struct kvm_vcpu *vcpu, u64 padr, u64 ma) | |||
316 | return; | 316 | return; |
317 | } else { | 317 | } else { |
318 | inst_type = -1; | 318 | inst_type = -1; |
319 | panic_vm(vcpu, "Unsupported MMIO access instruction! \ | 319 | panic_vm(vcpu, "Unsupported MMIO access instruction! " |
320 | Bunld[0]=0x%lx, Bundle[1]=0x%lx\n", | 320 | "Bunld[0]=0x%lx, Bundle[1]=0x%lx\n", |
321 | bundle.i64[0], bundle.i64[1]); | 321 | bundle.i64[0], bundle.i64[1]); |
322 | } | 322 | } |
323 | 323 | ||
diff --git a/arch/ia64/kvm/vcpu.c b/arch/ia64/kvm/vcpu.c index dce75b70cdd5..958815c9787d 100644 --- a/arch/ia64/kvm/vcpu.c +++ b/arch/ia64/kvm/vcpu.c | |||
@@ -1639,8 +1639,8 @@ void vcpu_set_psr(struct kvm_vcpu *vcpu, unsigned long val) | |||
1639 | * Otherwise panic | 1639 | * Otherwise panic |
1640 | */ | 1640 | */ |
1641 | if (val & (IA64_PSR_PK | IA64_PSR_IS | IA64_PSR_VM)) | 1641 | if (val & (IA64_PSR_PK | IA64_PSR_IS | IA64_PSR_VM)) |
1642 | panic_vm(vcpu, "Only support guests with vpsr.pk =0 \ | 1642 | panic_vm(vcpu, "Only support guests with vpsr.pk =0 " |
1643 | & vpsr.is=0\n"); | 1643 | "& vpsr.is=0\n"); |
1644 | 1644 | ||
1645 | /* | 1645 | /* |
1646 | * For those IA64_PSR bits: id/da/dd/ss/ed/ia | 1646 | * For those IA64_PSR bits: id/da/dd/ss/ed/ia |
diff --git a/arch/ia64/kvm/vmm.c b/arch/ia64/kvm/vmm.c index 7a62f75778c5..f0b9cac82414 100644 --- a/arch/ia64/kvm/vmm.c +++ b/arch/ia64/kvm/vmm.c | |||
@@ -51,7 +51,7 @@ static int __init kvm_vmm_init(void) | |||
51 | vmm_fpswa_interface = fpswa_interface; | 51 | vmm_fpswa_interface = fpswa_interface; |
52 | 52 | ||
53 | /*Register vmm data to kvm side*/ | 53 | /*Register vmm data to kvm side*/ |
54 | return kvm_init(&vmm_info, 1024, THIS_MODULE); | 54 | return kvm_init(&vmm_info, 1024, 0, THIS_MODULE); |
55 | } | 55 | } |
56 | 56 | ||
57 | static void __exit kvm_vmm_exit(void) | 57 | static void __exit kvm_vmm_exit(void) |