diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2007-07-31 06:45:03 -0400 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2007-10-13 04:18:22 -0400 |
commit | fb764416492a1204c20fdf4507019012d27bd1a2 (patch) | |
tree | f20613a42ae71afd741b65a0e544d865acda9c12 /drivers/kvm | |
parent | 002c7f7c32a6123f0894d7d579ffae8e98911830 (diff) |
KVM: Don't assign vcpu->cr3 if it's invalid: check first, set last
sSigned-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm')
-rw-r--r-- | drivers/kvm/kvm_main.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c index 2be6b1ca1a06..5dc601702782 100644 --- a/drivers/kvm/kvm_main.c +++ b/drivers/kvm/kvm_main.c | |||
@@ -579,7 +579,6 @@ void set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3) | |||
579 | } | 579 | } |
580 | } | 580 | } |
581 | 581 | ||
582 | vcpu->cr3 = cr3; | ||
583 | mutex_lock(&vcpu->kvm->lock); | 582 | mutex_lock(&vcpu->kvm->lock); |
584 | /* | 583 | /* |
585 | * Does the new cr3 value map to physical memory? (Note, we | 584 | * 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 | */ | 591 | */ |
593 | if (unlikely(!gfn_to_memslot(vcpu->kvm, cr3 >> PAGE_SHIFT))) | 592 | if (unlikely(!gfn_to_memslot(vcpu->kvm, cr3 >> PAGE_SHIFT))) |
594 | inject_gp(vcpu); | 593 | inject_gp(vcpu); |
595 | else | 594 | else { |
595 | vcpu->cr3 = cr3; | ||
596 | vcpu->mmu.new_cr3(vcpu); | 596 | vcpu->mmu.new_cr3(vcpu); |
597 | } | ||
597 | mutex_unlock(&vcpu->kvm->lock); | 598 | mutex_unlock(&vcpu->kvm->lock); |
598 | } | 599 | } |
599 | EXPORT_SYMBOL_GPL(set_cr3); | 600 | EXPORT_SYMBOL_GPL(set_cr3); |