Commit fb764416 authored by Rusty Russell's avatar Rusty Russell Committed by Avi Kivity

KVM: Don't assign vcpu->cr3 if it's invalid: check first, set last

sSigned-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
Signed-off-by: default avatarAvi Kivity <avi@qumranet.com>
parent 002c7f7c
...@@ -579,7 +579,6 @@ void set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3) ...@@ -579,7 +579,6 @@ void set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3)
} }
} }
vcpu->cr3 = cr3;
mutex_lock(&vcpu->kvm->lock); mutex_lock(&vcpu->kvm->lock);
/* /*
* Does the new cr3 value map to physical memory? (Note, we * 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) ...@@ -592,8 +591,10 @@ void set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3)
*/ */
if (unlikely(!gfn_to_memslot(vcpu->kvm, cr3 >> PAGE_SHIFT))) if (unlikely(!gfn_to_memslot(vcpu->kvm, cr3 >> PAGE_SHIFT)))
inject_gp(vcpu); inject_gp(vcpu);
else else {
vcpu->cr3 = cr3;
vcpu->mmu.new_cr3(vcpu); vcpu->mmu.new_cr3(vcpu);
}
mutex_unlock(&vcpu->kvm->lock); mutex_unlock(&vcpu->kvm->lock);
} }
EXPORT_SYMBOL_GPL(set_cr3); EXPORT_SYMBOL_GPL(set_cr3);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment