aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/x86.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r--arch/x86/kvm/x86.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 9870ce422920..c7b01efe0646 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3974,16 +3974,23 @@ int kvm_arch_set_memory_region(struct kvm *kvm,
3974 */ 3974 */
3975 if (!user_alloc) { 3975 if (!user_alloc) {
3976 if (npages && !old.rmap) { 3976 if (npages && !old.rmap) {
3977 unsigned long userspace_addr;
3978
3977 down_write(&current->mm->mmap_sem); 3979 down_write(&current->mm->mmap_sem);
3978 memslot->userspace_addr = do_mmap(NULL, 0, 3980 userspace_addr = do_mmap(NULL, 0,
3979 npages * PAGE_SIZE, 3981 npages * PAGE_SIZE,
3980 PROT_READ | PROT_WRITE, 3982 PROT_READ | PROT_WRITE,
3981 MAP_SHARED | MAP_ANONYMOUS, 3983 MAP_SHARED | MAP_ANONYMOUS,
3982 0); 3984 0);
3983 up_write(&current->mm->mmap_sem); 3985 up_write(&current->mm->mmap_sem);
3984 3986
3985 if (IS_ERR((void *)memslot->userspace_addr)) 3987 if (IS_ERR((void *)userspace_addr))
3986 return PTR_ERR((void *)memslot->userspace_addr); 3988 return PTR_ERR((void *)userspace_addr);
3989
3990 /* set userspace_addr atomically for kvm_hva_to_rmapp */
3991 spin_lock(&kvm->mmu_lock);
3992 memslot->userspace_addr = userspace_addr;
3993 spin_unlock(&kvm->mmu_lock);
3987 } else { 3994 } else {
3988 if (!old.user_alloc && old.rmap) { 3995 if (!old.user_alloc && old.rmap) {
3989 int ret; 3996 int ret;