aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/vmx.c
diff options
context:
space:
mode:
authorIzik Eidus <izike@qumranet.com>2008-02-10 11:04:15 -0500
committerAvi Kivity <avi@qumranet.com>2008-03-04 08:19:40 -0500
commit72dc67a69690288538142df73a7e3ac66fea68dc (patch)
treef40cc5ef0c66686a469977fd438e5b6786f16280 /arch/x86/kvm/vmx.c
parentc7ac679c160db864810920df61a6ed14275011aa (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 'arch/x86/kvm/vmx.c')
-rw-r--r--arch/x86/kvm/vmx.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index ad36447e696e..86f5bf121838 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -1477,7 +1477,7 @@ static int alloc_apic_access_page(struct kvm *kvm)
1477 struct kvm_userspace_memory_region kvm_userspace_mem; 1477 struct kvm_userspace_memory_region kvm_userspace_mem;
1478 int r = 0; 1478 int r = 0;
1479 1479
1480 down_write(&current->mm->mmap_sem); 1480 down_write(&kvm->slots_lock);
1481 if (kvm->arch.apic_access_page) 1481 if (kvm->arch.apic_access_page)
1482 goto out; 1482 goto out;
1483 kvm_userspace_mem.slot = APIC_ACCESS_PAGE_PRIVATE_MEMSLOT; 1483 kvm_userspace_mem.slot = APIC_ACCESS_PAGE_PRIVATE_MEMSLOT;
@@ -1487,9 +1487,12 @@ static int alloc_apic_access_page(struct kvm *kvm)
1487 r = __kvm_set_memory_region(kvm, &kvm_userspace_mem, 0); 1487 r = __kvm_set_memory_region(kvm, &kvm_userspace_mem, 0);
1488 if (r) 1488 if (r)
1489 goto out; 1489 goto out;
1490
1491 down_read(&current->mm->mmap_sem);
1490 kvm->arch.apic_access_page = gfn_to_page(kvm, 0xfee00); 1492 kvm->arch.apic_access_page = gfn_to_page(kvm, 0xfee00);
1493 up_read(&current->mm->mmap_sem);
1491out: 1494out:
1492 up_write(&current->mm->mmap_sem); 1495 up_write(&kvm->slots_lock);
1493 return r; 1496 return r;
1494} 1497}
1495 1498