diff options
author | Izik Eidus <izike@qumranet.com> | 2008-02-10 11:04:15 -0500 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2008-03-04 08:19:40 -0500 |
commit | 72dc67a69690288538142df73a7e3ac66fea68dc (patch) | |
tree | f40cc5ef0c66686a469977fd438e5b6786f16280 /virt | |
parent | c7ac679c160db864810920df61a6ed14275011aa (diff) |
KVM: remove the usage of the mmap_sem for the protection of the memory slots.
This patch replaces the mmap_sem lock for the memory slots with a new
kvm private lock, it is needed beacuse untill now there were cases where
kvm accesses user memory while holding the mmap semaphore.
Signed-off-by: Izik Eidus <izike@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'virt')
-rw-r--r-- | virt/kvm/kvm_main.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 32fbf800696..b2e12893e3f 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c | |||
@@ -169,6 +169,7 @@ static struct kvm *kvm_create_vm(void) | |||
169 | kvm_io_bus_init(&kvm->pio_bus); | 169 | kvm_io_bus_init(&kvm->pio_bus); |
170 | mutex_init(&kvm->lock); | 170 | mutex_init(&kvm->lock); |
171 | kvm_io_bus_init(&kvm->mmio_bus); | 171 | kvm_io_bus_init(&kvm->mmio_bus); |
172 | init_rwsem(&kvm->slots_lock); | ||
172 | spin_lock(&kvm_lock); | 173 | spin_lock(&kvm_lock); |
173 | list_add(&kvm->vm_list, &vm_list); | 174 | list_add(&kvm->vm_list, &vm_list); |
174 | spin_unlock(&kvm_lock); | 175 | spin_unlock(&kvm_lock); |
@@ -339,9 +340,9 @@ int kvm_set_memory_region(struct kvm *kvm, | |||
339 | { | 340 | { |
340 | int r; | 341 | int r; |
341 | 342 | ||
342 | down_write(¤t->mm->mmap_sem); | 343 | down_write(&kvm->slots_lock); |
343 | r = __kvm_set_memory_region(kvm, mem, user_alloc); | 344 | r = __kvm_set_memory_region(kvm, mem, user_alloc); |
344 | up_write(¤t->mm->mmap_sem); | 345 | up_write(&kvm->slots_lock); |
345 | return r; | 346 | return r; |
346 | } | 347 | } |
347 | EXPORT_SYMBOL_GPL(kvm_set_memory_region); | 348 | EXPORT_SYMBOL_GPL(kvm_set_memory_region); |