aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/ia64/kvm/kvm-ia64.c4
-rw-r--r--arch/powerpc/kvm/book3s.c4
-rw-r--r--arch/x86/kvm/i8254.c2
-rw-r--r--arch/x86/kvm/i8259.c4
-rw-r--r--arch/x86/kvm/vmx.c8
-rw-r--r--arch/x86/kvm/x86.c16
-rw-r--r--include/linux/kvm_host.h2
-rw-r--r--virt/kvm/coalesced_mmio.c14
-rw-r--r--virt/kvm/eventfd.c10
-rw-r--r--virt/kvm/ioapic.c4
-rw-r--r--virt/kvm/kvm_main.c10
11 files changed, 39 insertions, 39 deletions
diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c
index d5e384641275..e6ac549f8d55 100644
--- a/arch/ia64/kvm/kvm-ia64.c
+++ b/arch/ia64/kvm/kvm-ia64.c
@@ -1834,7 +1834,7 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
1834 struct kvm_memory_slot *memslot; 1834 struct kvm_memory_slot *memslot;
1835 int is_dirty = 0; 1835 int is_dirty = 0;
1836 1836
1837 down_write(&kvm->slots_lock); 1837 mutex_lock(&kvm->slots_lock);
1838 spin_lock(&kvm->arch.dirty_log_lock); 1838 spin_lock(&kvm->arch.dirty_log_lock);
1839 1839
1840 r = kvm_ia64_sync_dirty_log(kvm, log); 1840 r = kvm_ia64_sync_dirty_log(kvm, log);
@@ -1854,7 +1854,7 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
1854 } 1854 }
1855 r = 0; 1855 r = 0;
1856out: 1856out:
1857 up_write(&kvm->slots_lock); 1857 mutex_unlock(&kvm->slots_lock);
1858 spin_unlock(&kvm->arch.dirty_log_lock); 1858 spin_unlock(&kvm->arch.dirty_log_lock);
1859 return r; 1859 return r;
1860} 1860}
diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c
index bb8873dcb20f..492dcc198dd3 100644
--- a/arch/powerpc/kvm/book3s.c
+++ b/arch/powerpc/kvm/book3s.c
@@ -857,7 +857,7 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
857 int is_dirty = 0; 857 int is_dirty = 0;
858 int r, n; 858 int r, n;
859 859
860 down_write(&kvm->slots_lock); 860 mutex_lock(&kvm->slots_lock);
861 861
862 r = kvm_get_dirty_log(kvm, log, &is_dirty); 862 r = kvm_get_dirty_log(kvm, log, &is_dirty);
863 if (r) 863 if (r)
@@ -879,7 +879,7 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
879 879
880 r = 0; 880 r = 0;
881out: 881out:
882 up_write(&kvm->slots_lock); 882 mutex_unlock(&kvm->slots_lock);
883 return r; 883 return r;
884} 884}
885 885
diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c
index 4b433de02e5b..6a74246f80c6 100644
--- a/arch/x86/kvm/i8254.c
+++ b/arch/x86/kvm/i8254.c
@@ -605,7 +605,7 @@ static const struct kvm_io_device_ops speaker_dev_ops = {
605 .write = speaker_ioport_write, 605 .write = speaker_ioport_write,
606}; 606};
607 607
608/* Caller must have writers lock on slots_lock */ 608/* Caller must hold slots_lock */
609struct kvm_pit *kvm_create_pit(struct kvm *kvm, u32 flags) 609struct kvm_pit *kvm_create_pit(struct kvm *kvm, u32 flags)
610{ 610{
611 struct kvm_pit *pit; 611 struct kvm_pit *pit;
diff --git a/arch/x86/kvm/i8259.c b/arch/x86/kvm/i8259.c
index b7d145b20953..d5753a75d58c 100644
--- a/arch/x86/kvm/i8259.c
+++ b/arch/x86/kvm/i8259.c
@@ -533,9 +533,9 @@ struct kvm_pic *kvm_create_pic(struct kvm *kvm)
533 * Initialize PIO device 533 * Initialize PIO device
534 */ 534 */
535 kvm_iodevice_init(&s->dev, &picdev_ops); 535 kvm_iodevice_init(&s->dev, &picdev_ops);
536 down_write(&kvm->slots_lock); 536 mutex_lock(&kvm->slots_lock);
537 ret = kvm_io_bus_register_dev(kvm, KVM_PIO_BUS, &s->dev); 537 ret = kvm_io_bus_register_dev(kvm, KVM_PIO_BUS, &s->dev);
538 up_write(&kvm->slots_lock); 538 mutex_unlock(&kvm->slots_lock);
539 if (ret < 0) { 539 if (ret < 0) {
540 kfree(s); 540 kfree(s);
541 return NULL; 541 return NULL;
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 22ab7137d1d0..f04e2ff21383 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -2223,7 +2223,7 @@ static int alloc_apic_access_page(struct kvm *kvm)
2223 struct kvm_userspace_memory_region kvm_userspace_mem; 2223 struct kvm_userspace_memory_region kvm_userspace_mem;
2224 int r = 0; 2224 int r = 0;
2225 2225
2226 down_write(&kvm->slots_lock); 2226 mutex_lock(&kvm->slots_lock);
2227 if (kvm->arch.apic_access_page) 2227 if (kvm->arch.apic_access_page)
2228 goto out; 2228 goto out;
2229 kvm_userspace_mem.slot = APIC_ACCESS_PAGE_PRIVATE_MEMSLOT; 2229 kvm_userspace_mem.slot = APIC_ACCESS_PAGE_PRIVATE_MEMSLOT;
@@ -2236,7 +2236,7 @@ static int alloc_apic_access_page(struct kvm *kvm)
2236 2236
2237 kvm->arch.apic_access_page = gfn_to_page(kvm, 0xfee00); 2237 kvm->arch.apic_access_page = gfn_to_page(kvm, 0xfee00);
2238out: 2238out:
2239 up_write(&kvm->slots_lock); 2239 mutex_unlock(&kvm->slots_lock);
2240 return r; 2240 return r;
2241} 2241}
2242 2242
@@ -2245,7 +2245,7 @@ static int alloc_identity_pagetable(struct kvm *kvm)
2245 struct kvm_userspace_memory_region kvm_userspace_mem; 2245 struct kvm_userspace_memory_region kvm_userspace_mem;
2246 int r = 0; 2246 int r = 0;
2247 2247
2248 down_write(&kvm->slots_lock); 2248 mutex_lock(&kvm->slots_lock);
2249 if (kvm->arch.ept_identity_pagetable) 2249 if (kvm->arch.ept_identity_pagetable)
2250 goto out; 2250 goto out;
2251 kvm_userspace_mem.slot = IDENTITY_PAGETABLE_PRIVATE_MEMSLOT; 2251 kvm_userspace_mem.slot = IDENTITY_PAGETABLE_PRIVATE_MEMSLOT;
@@ -2260,7 +2260,7 @@ static int alloc_identity_pagetable(struct kvm *kvm)
2260 kvm->arch.ept_identity_pagetable = gfn_to_page(kvm, 2260 kvm->arch.ept_identity_pagetable = gfn_to_page(kvm,
2261 kvm->arch.ept_identity_map_addr >> PAGE_SHIFT); 2261 kvm->arch.ept_identity_map_addr >> PAGE_SHIFT);
2262out: 2262out:
2263 up_write(&kvm->slots_lock); 2263 mutex_unlock(&kvm->slots_lock);
2264 return r; 2264 return r;
2265} 2265}
2266 2266
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 53bc06a68105..aff3479867a8 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2208,14 +2208,14 @@ static int kvm_vm_ioctl_set_nr_mmu_pages(struct kvm *kvm,
2208 if (kvm_nr_mmu_pages < KVM_MIN_ALLOC_MMU_PAGES) 2208 if (kvm_nr_mmu_pages < KVM_MIN_ALLOC_MMU_PAGES)
2209 return -EINVAL; 2209 return -EINVAL;
2210 2210
2211 down_write(&kvm->slots_lock); 2211 mutex_lock(&kvm->slots_lock);
2212 spin_lock(&kvm->mmu_lock); 2212 spin_lock(&kvm->mmu_lock);
2213 2213
2214 kvm_mmu_change_mmu_pages(kvm, kvm_nr_mmu_pages); 2214 kvm_mmu_change_mmu_pages(kvm, kvm_nr_mmu_pages);
2215 kvm->arch.n_requested_mmu_pages = kvm_nr_mmu_pages; 2215 kvm->arch.n_requested_mmu_pages = kvm_nr_mmu_pages;
2216 2216
2217 spin_unlock(&kvm->mmu_lock); 2217 spin_unlock(&kvm->mmu_lock);
2218 up_write(&kvm->slots_lock); 2218 mutex_unlock(&kvm->slots_lock);
2219 return 0; 2219 return 0;
2220} 2220}
2221 2221
@@ -2292,7 +2292,7 @@ static int kvm_vm_ioctl_set_memory_alias(struct kvm *kvm,
2292 if (!aliases) 2292 if (!aliases)
2293 goto out; 2293 goto out;
2294 2294
2295 down_write(&kvm->slots_lock); 2295 mutex_lock(&kvm->slots_lock);
2296 2296
2297 /* invalidate any gfn reference in case of deletion/shrinking */ 2297 /* invalidate any gfn reference in case of deletion/shrinking */
2298 memcpy(aliases, kvm->arch.aliases, sizeof(struct kvm_mem_aliases)); 2298 memcpy(aliases, kvm->arch.aliases, sizeof(struct kvm_mem_aliases));
@@ -2328,7 +2328,7 @@ static int kvm_vm_ioctl_set_memory_alias(struct kvm *kvm,
2328 r = 0; 2328 r = 0;
2329 2329
2330out_unlock: 2330out_unlock:
2331 up_write(&kvm->slots_lock); 2331 mutex_unlock(&kvm->slots_lock);
2332out: 2332out:
2333 return r; 2333 return r;
2334} 2334}
@@ -2462,7 +2462,7 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
2462 unsigned long is_dirty = 0; 2462 unsigned long is_dirty = 0;
2463 unsigned long *dirty_bitmap = NULL; 2463 unsigned long *dirty_bitmap = NULL;
2464 2464
2465 down_write(&kvm->slots_lock); 2465 mutex_lock(&kvm->slots_lock);
2466 2466
2467 r = -EINVAL; 2467 r = -EINVAL;
2468 if (log->slot >= KVM_MEMORY_SLOTS) 2468 if (log->slot >= KVM_MEMORY_SLOTS)
@@ -2512,7 +2512,7 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
2512out_free: 2512out_free:
2513 vfree(dirty_bitmap); 2513 vfree(dirty_bitmap);
2514out: 2514out:
2515 up_write(&kvm->slots_lock); 2515 mutex_unlock(&kvm->slots_lock);
2516 return r; 2516 return r;
2517} 2517}
2518 2518
@@ -2625,7 +2625,7 @@ long kvm_arch_vm_ioctl(struct file *filp,
2625 sizeof(struct kvm_pit_config))) 2625 sizeof(struct kvm_pit_config)))
2626 goto out; 2626 goto out;
2627 create_pit: 2627 create_pit:
2628 down_write(&kvm->slots_lock); 2628 mutex_lock(&kvm->slots_lock);
2629 r = -EEXIST; 2629 r = -EEXIST;
2630 if (kvm->arch.vpit) 2630 if (kvm->arch.vpit)
2631 goto create_pit_unlock; 2631 goto create_pit_unlock;
@@ -2634,7 +2634,7 @@ long kvm_arch_vm_ioctl(struct file *filp,
2634 if (kvm->arch.vpit) 2634 if (kvm->arch.vpit)
2635 r = 0; 2635 r = 0;
2636 create_pit_unlock: 2636 create_pit_unlock:
2637 up_write(&kvm->slots_lock); 2637 mutex_unlock(&kvm->slots_lock);
2638 break; 2638 break;
2639 case KVM_IRQ_LINE_STATUS: 2639 case KVM_IRQ_LINE_STATUS:
2640 case KVM_IRQ_LINE: { 2640 case KVM_IRQ_LINE: {
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 0bb9aa295e6c..bb0314ea9267 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -161,7 +161,7 @@ struct kvm_memslots {
161struct kvm { 161struct kvm {
162 spinlock_t mmu_lock; 162 spinlock_t mmu_lock;
163 spinlock_t requests_lock; 163 spinlock_t requests_lock;
164 struct rw_semaphore slots_lock; 164 struct mutex slots_lock;
165 struct mm_struct *mm; /* userspace tied to this vm */ 165 struct mm_struct *mm; /* userspace tied to this vm */
166 struct kvm_memslots *memslots; 166 struct kvm_memslots *memslots;
167 struct srcu_struct srcu; 167 struct srcu_struct srcu;
diff --git a/virt/kvm/coalesced_mmio.c b/virt/kvm/coalesced_mmio.c
index a736a93ca7b7..5de6594260cb 100644
--- a/virt/kvm/coalesced_mmio.c
+++ b/virt/kvm/coalesced_mmio.c
@@ -110,9 +110,9 @@ int kvm_coalesced_mmio_init(struct kvm *kvm)
110 dev->kvm = kvm; 110 dev->kvm = kvm;
111 kvm->coalesced_mmio_dev = dev; 111 kvm->coalesced_mmio_dev = dev;
112 112
113 down_write(&kvm->slots_lock); 113 mutex_lock(&kvm->slots_lock);
114 ret = kvm_io_bus_register_dev(kvm, KVM_MMIO_BUS, &dev->dev); 114 ret = kvm_io_bus_register_dev(kvm, KVM_MMIO_BUS, &dev->dev);
115 up_write(&kvm->slots_lock); 115 mutex_unlock(&kvm->slots_lock);
116 if (ret < 0) 116 if (ret < 0)
117 goto out_free_dev; 117 goto out_free_dev;
118 118
@@ -140,16 +140,16 @@ int kvm_vm_ioctl_register_coalesced_mmio(struct kvm *kvm,
140 if (dev == NULL) 140 if (dev == NULL)
141 return -EINVAL; 141 return -EINVAL;
142 142
143 down_write(&kvm->slots_lock); 143 mutex_lock(&kvm->slots_lock);
144 if (dev->nb_zones >= KVM_COALESCED_MMIO_ZONE_MAX) { 144 if (dev->nb_zones >= KVM_COALESCED_MMIO_ZONE_MAX) {
145 up_write(&kvm->slots_lock); 145 mutex_unlock(&kvm->slots_lock);
146 return -ENOBUFS; 146 return -ENOBUFS;
147 } 147 }
148 148
149 dev->zone[dev->nb_zones] = *zone; 149 dev->zone[dev->nb_zones] = *zone;
150 dev->nb_zones++; 150 dev->nb_zones++;
151 151
152 up_write(&kvm->slots_lock); 152 mutex_unlock(&kvm->slots_lock);
153 return 0; 153 return 0;
154} 154}
155 155
@@ -163,7 +163,7 @@ int kvm_vm_ioctl_unregister_coalesced_mmio(struct kvm *kvm,
163 if (dev == NULL) 163 if (dev == NULL)
164 return -EINVAL; 164 return -EINVAL;
165 165
166 down_write(&kvm->slots_lock); 166 mutex_lock(&kvm->slots_lock);
167 167
168 i = dev->nb_zones; 168 i = dev->nb_zones;
169 while(i) { 169 while(i) {
@@ -181,7 +181,7 @@ int kvm_vm_ioctl_unregister_coalesced_mmio(struct kvm *kvm,
181 i--; 181 i--;
182 } 182 }
183 183
184 up_write(&kvm->slots_lock); 184 mutex_unlock(&kvm->slots_lock);
185 185
186 return 0; 186 return 0;
187} 187}
diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index 315a586ec4d5..486c604365d9 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -508,7 +508,7 @@ kvm_assign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
508 else 508 else
509 p->wildcard = true; 509 p->wildcard = true;
510 510
511 down_write(&kvm->slots_lock); 511 mutex_lock(&kvm->slots_lock);
512 512
513 /* Verify that there isnt a match already */ 513 /* Verify that there isnt a match already */
514 if (ioeventfd_check_collision(kvm, p)) { 514 if (ioeventfd_check_collision(kvm, p)) {
@@ -524,12 +524,12 @@ kvm_assign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
524 524
525 list_add_tail(&p->list, &kvm->ioeventfds); 525 list_add_tail(&p->list, &kvm->ioeventfds);
526 526
527 up_write(&kvm->slots_lock); 527 mutex_unlock(&kvm->slots_lock);
528 528
529 return 0; 529 return 0;
530 530
531unlock_fail: 531unlock_fail:
532 up_write(&kvm->slots_lock); 532 mutex_unlock(&kvm->slots_lock);
533 533
534fail: 534fail:
535 kfree(p); 535 kfree(p);
@@ -551,7 +551,7 @@ kvm_deassign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
551 if (IS_ERR(eventfd)) 551 if (IS_ERR(eventfd))
552 return PTR_ERR(eventfd); 552 return PTR_ERR(eventfd);
553 553
554 down_write(&kvm->slots_lock); 554 mutex_lock(&kvm->slots_lock);
555 555
556 list_for_each_entry_safe(p, tmp, &kvm->ioeventfds, list) { 556 list_for_each_entry_safe(p, tmp, &kvm->ioeventfds, list) {
557 bool wildcard = !(args->flags & KVM_IOEVENTFD_FLAG_DATAMATCH); 557 bool wildcard = !(args->flags & KVM_IOEVENTFD_FLAG_DATAMATCH);
@@ -571,7 +571,7 @@ kvm_deassign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
571 break; 571 break;
572 } 572 }
573 573
574 up_write(&kvm->slots_lock); 574 mutex_unlock(&kvm->slots_lock);
575 575
576 eventfd_ctx_put(eventfd); 576 eventfd_ctx_put(eventfd);
577 577
diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c
index f326a6f301cc..f01392f51e86 100644
--- a/virt/kvm/ioapic.c
+++ b/virt/kvm/ioapic.c
@@ -372,9 +372,9 @@ int kvm_ioapic_init(struct kvm *kvm)
372 kvm_ioapic_reset(ioapic); 372 kvm_ioapic_reset(ioapic);
373 kvm_iodevice_init(&ioapic->dev, &ioapic_mmio_ops); 373 kvm_iodevice_init(&ioapic->dev, &ioapic_mmio_ops);
374 ioapic->kvm = kvm; 374 ioapic->kvm = kvm;
375 down_write(&kvm->slots_lock); 375 mutex_lock(&kvm->slots_lock);
376 ret = kvm_io_bus_register_dev(kvm, KVM_MMIO_BUS, &ioapic->dev); 376 ret = kvm_io_bus_register_dev(kvm, KVM_MMIO_BUS, &ioapic->dev);
377 up_write(&kvm->slots_lock); 377 mutex_unlock(&kvm->slots_lock);
378 if (ret < 0) 378 if (ret < 0)
379 kfree(ioapic); 379 kfree(ioapic);
380 380
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 659bc12ad16a..2b7cd6c0d9ca 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -429,7 +429,7 @@ static struct kvm *kvm_create_vm(void)
429 kvm_eventfd_init(kvm); 429 kvm_eventfd_init(kvm);
430 mutex_init(&kvm->lock); 430 mutex_init(&kvm->lock);
431 mutex_init(&kvm->irq_lock); 431 mutex_init(&kvm->irq_lock);
432 init_rwsem(&kvm->slots_lock); 432 mutex_init(&kvm->slots_lock);
433 atomic_set(&kvm->users_count, 1); 433 atomic_set(&kvm->users_count, 1);
434 spin_lock(&kvm_lock); 434 spin_lock(&kvm_lock);
435 list_add(&kvm->vm_list, &vm_list); 435 list_add(&kvm->vm_list, &vm_list);
@@ -763,9 +763,9 @@ int kvm_set_memory_region(struct kvm *kvm,
763{ 763{
764 int r; 764 int r;
765 765
766 down_write(&kvm->slots_lock); 766 mutex_lock(&kvm->slots_lock);
767 r = __kvm_set_memory_region(kvm, mem, user_alloc); 767 r = __kvm_set_memory_region(kvm, mem, user_alloc);
768 up_write(&kvm->slots_lock); 768 mutex_unlock(&kvm->slots_lock);
769 return r; 769 return r;
770} 770}
771EXPORT_SYMBOL_GPL(kvm_set_memory_region); 771EXPORT_SYMBOL_GPL(kvm_set_memory_region);
@@ -1997,7 +1997,7 @@ int kvm_io_bus_read(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
1997 return -EOPNOTSUPP; 1997 return -EOPNOTSUPP;
1998} 1998}
1999 1999
2000/* Caller must have write lock on slots_lock. */ 2000/* Caller must hold slots_lock. */
2001int kvm_io_bus_register_dev(struct kvm *kvm, enum kvm_bus bus_idx, 2001int kvm_io_bus_register_dev(struct kvm *kvm, enum kvm_bus bus_idx,
2002 struct kvm_io_device *dev) 2002 struct kvm_io_device *dev)
2003{ 2003{
@@ -2019,7 +2019,7 @@ int kvm_io_bus_register_dev(struct kvm *kvm, enum kvm_bus bus_idx,
2019 return 0; 2019 return 0;
2020} 2020}
2021 2021
2022/* Caller must have write lock on slots_lock. */ 2022/* Caller must hold slots_lock. */
2023int kvm_io_bus_unregister_dev(struct kvm *kvm, enum kvm_bus bus_idx, 2023int kvm_io_bus_unregister_dev(struct kvm *kvm, enum kvm_bus bus_idx,
2024 struct kvm_io_device *dev) 2024 struct kvm_io_device *dev)
2025{ 2025{