aboutsummaryrefslogtreecommitdiffstats
path: root/virt/kvm
diff options
context:
space:
mode:
authorMarcelo Tosatti <mtosatti@redhat.com>2009-12-23 11:35:26 -0500
committerMarcelo Tosatti <mtosatti@redhat.com>2010-03-01 10:35:45 -0500
commit79fac95ecfa3969aab8119d37ccd7226165f933a (patch)
tree4103169c7fd2b7fb1ba95dae2db6b3f365476b9d /virt/kvm
parentf656ce0185cabbbb0cf96877306879661297c7ad (diff)
KVM: convert slots_lock to a mutex
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'virt/kvm')
-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
4 files changed, 19 insertions, 19 deletions
diff --git a/virt/kvm/coalesced_mmio.c b/virt/kvm/coalesced_mmio.c
index a736a93ca7b..5de6594260c 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 315a586ec4d..486c604365d 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 f326a6f301c..f01392f51e8 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 659bc12ad16..2b7cd6c0d9c 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{