KVM: SVM: Reset cr0 properly on vcpu reset
authorEduardo Habkost <ehabkost@redhat.com>
Sat, 24 Oct 2009 04:49:59 +0000 (02:49 -0200)
committerAvi Kivity <avi@redhat.com>
Thu, 3 Dec 2009 07:32:21 +0000 (09:32 +0200)
commit18fa000ae453767b59ab97477925895a3f0c46ea
tree47758dbcc1ac7294277cfd20457d7a39515eb1ba
parentfa40052ca04bdbbeb20b839cc8ffe9fa7beefbe9
KVM: SVM: Reset cr0 properly on vcpu reset

svm_vcpu_reset() was not properly resetting the contents of the guest-visible
cr0 register, causing the following issue:
https://bugzilla.redhat.com/show_bug.cgi?id=525699

Without resetting cr0 properly, the vcpu was running the SIPI bootstrap routine
with paging enabled, making the vcpu get a pagefault exception while trying to
run it.

Instead of setting vmcb->save.cr0 directly, the new code just resets
kvm->arch.cr0 and calls kvm_set_cr0(). The bits that were set/cleared on
vmcb->save.cr0 (PG, WP, !CD, !NW) will be set properly by svm_set_cr0().

kvm_set_cr0() is used instead of calling svm_set_cr0() directly to make sure
kvm_mmu_reset_context() is called to reset the mmu to nonpaging mode.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
arch/x86/kvm/svm.c