Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a1708ce8 authored by Andrea Arcangeli's avatar Andrea Arcangeli Committed by Avi Kivity
Browse files

KVM: Allow reading aliases with mmu_lock



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: default avatarAndrea Arcangeli <andrea@qumranet.com>
Signed-off-by: default avatarAvi Kivity <avi@qumranet.com>
parent 6e86841d
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -1495,6 +1495,7 @@ static int kvm_vm_ioctl_set_memory_alias(struct kvm *kvm,
		goto out;
		goto out;


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


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


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


	up_write(&kvm->slots_lock);
	up_write(&kvm->slots_lock);