diff options
author | Andrea Arcangeli <andrea@qumranet.com> | 2008-07-25 10:32:03 -0400 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2008-07-29 05:33:50 -0400 |
commit | 604b38ac0369bd50fcbb33344aa5553c071009f7 (patch) | |
tree | 149325ef8ddbeb607a19052bb807383a6aa7a549 /arch | |
parent | a1708ce8a362c4999f1201237ae7b77c4d13af82 (diff) |
KVM: Allow browsing memslots with mmu_lock
This allows reading memslots with only the mmu_lock hold for mmu
notifiers that runs in atomic context and with mmu_lock held.
Signed-off-by: Andrea Arcangeli <andrea@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/kvm/x86.c | 21 |
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(¤t->mm->mmap_sem); | 3979 | down_write(¤t->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(¤t->mm->mmap_sem); | 3985 | up_write(¤t->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; |