]> git.openfabrics.org - ~shefty/rdma-dev.git/commitdiff
KVM: Don't assign vcpu->cr3 if it's invalid: check first, set last
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 31 Jul 2007 10:45:03 +0000 (20:45 +1000)
committerAvi Kivity <avi@qumranet.com>
Sat, 13 Oct 2007 08:18:22 +0000 (10:18 +0200)
sSigned-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Avi Kivity <avi@qumranet.com>
drivers/kvm/kvm_main.c

index 2be6b1ca1a06680008902510e3e52f12ead87295..5dc60170278241235d34009b6094b63fcd10c7b3 100644 (file)
@@ -579,7 +579,6 @@ void set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3)
                }
        }
 
-       vcpu->cr3 = cr3;
        mutex_lock(&vcpu->kvm->lock);
        /*
         * Does the new cr3 value map to physical memory? (Note, we
@@ -592,8 +591,10 @@ void set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3)
         */
        if (unlikely(!gfn_to_memslot(vcpu->kvm, cr3 >> PAGE_SHIFT)))
                inject_gp(vcpu);
-       else
+       else {
+               vcpu->cr3 = cr3;
                vcpu->mmu.new_cr3(vcpu);
+       }
        mutex_unlock(&vcpu->kvm->lock);
 }
 EXPORT_SYMBOL_GPL(set_cr3);