Skip to content

Commit

Permalink
KVM: Allow reading aliases with mmu_lock
Browse files Browse the repository at this point in the history
This allows the mmu notifier code to run unalias_gfn with only the
mmu_lock held.  Only alias writes need the mmu_lock held. Readers will
either take the slots_lock in read mode or the mmu_lock.

Signed-off-by: Andrea Arcangeli <andrea@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
  • Loading branch information
Andrea Arcangeli authored and Avi Kivity committed Jul 29, 2008
1 parent 6e86841 commit a1708ce
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions arch/x86/kvm/x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -1495,6 +1495,7 @@ static int kvm_vm_ioctl_set_memory_alias(struct kvm *kvm,
goto out;

down_write(&kvm->slots_lock);
spin_lock(&kvm->mmu_lock);

p = &kvm->arch.aliases[alias->slot];
p->base_gfn = alias->guest_phys_addr >> PAGE_SHIFT;
Expand All @@ -1506,6 +1507,7 @@ static int kvm_vm_ioctl_set_memory_alias(struct kvm *kvm,
break;
kvm->arch.naliases = n;

spin_unlock(&kvm->mmu_lock);
kvm_mmu_zap_all(kvm);

up_write(&kvm->slots_lock);
Expand Down

0 comments on commit a1708ce

Please sign in to comment.