aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm/mmu.c
diff options
context:
space:
mode:
authorShaohua Li <shaohua.li@intel.com>2007-07-23 02:51:37 -0400
committerAvi Kivity <avi@qumranet.com>2007-10-13 04:18:20 -0400
commit11ec2804711896546ee3c945f3786c7f9fdd175a (patch)
tree1e26102931efb8b0b48c440887577d21170ef94a /drivers/kvm/mmu.c
parent15ad71460d75fd7ca41bb248a2310f3f39b302ba (diff)
KVM: Convert vm lock to a mutex
This allows the kvm mmu to perform sleepy operations, such as memory allocation. Signed-off-by: Shaohua Li <shaohua.li@intel.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/mmu.c')
-rw-r--r--drivers/kvm/mmu.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/drivers/kvm/mmu.c b/drivers/kvm/mmu.c
index 396c736e546b..e303b4137bfa 100644
--- a/drivers/kvm/mmu.c
+++ b/drivers/kvm/mmu.c
@@ -275,10 +275,9 @@ static int mmu_topup_memory_caches(struct kvm_vcpu *vcpu)
275 r = __mmu_topup_memory_caches(vcpu, GFP_NOWAIT); 275 r = __mmu_topup_memory_caches(vcpu, GFP_NOWAIT);
276 kvm_mmu_free_some_pages(vcpu); 276 kvm_mmu_free_some_pages(vcpu);
277 if (r < 0) { 277 if (r < 0) {
278 spin_unlock(&vcpu->kvm->lock); 278 mutex_unlock(&vcpu->kvm->lock);
279 r = __mmu_topup_memory_caches(vcpu, GFP_KERNEL); 279 r = __mmu_topup_memory_caches(vcpu, GFP_KERNEL);
280 spin_lock(&vcpu->kvm->lock); 280 mutex_lock(&vcpu->kvm->lock);
281 kvm_mmu_free_some_pages(vcpu);
282 } 281 }
283 return r; 282 return r;
284} 283}
@@ -1069,7 +1068,7 @@ int kvm_mmu_load(struct kvm_vcpu *vcpu)
1069{ 1068{
1070 int r; 1069 int r;
1071 1070
1072 spin_lock(&vcpu->kvm->lock); 1071 mutex_lock(&vcpu->kvm->lock);
1073 r = mmu_topup_memory_caches(vcpu); 1072 r = mmu_topup_memory_caches(vcpu);
1074 if (r) 1073 if (r)
1075 goto out; 1074 goto out;
@@ -1077,7 +1076,7 @@ int kvm_mmu_load(struct kvm_vcpu *vcpu)
1077 kvm_arch_ops->set_cr3(vcpu, vcpu->mmu.root_hpa); 1076 kvm_arch_ops->set_cr3(vcpu, vcpu->mmu.root_hpa);
1078 kvm_mmu_flush_tlb(vcpu); 1077 kvm_mmu_flush_tlb(vcpu);
1079out: 1078out:
1080 spin_unlock(&vcpu->kvm->lock); 1079 mutex_unlock(&vcpu->kvm->lock);
1081 return r; 1080 return r;
1082} 1081}
1083EXPORT_SYMBOL_GPL(kvm_mmu_load); 1082EXPORT_SYMBOL_GPL(kvm_mmu_load);