Commit 18fa000a authored by Eduardo Habkost's avatar Eduardo Habkost Committed by Avi Kivity

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: default avatarEduardo Habkost <ehabkost@redhat.com>
Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
parent fa40052c
...@@ -628,11 +628,12 @@ static void init_vmcb(struct vcpu_svm *svm) ...@@ -628,11 +628,12 @@ static void init_vmcb(struct vcpu_svm *svm)
save->rip = 0x0000fff0; save->rip = 0x0000fff0;
svm->vcpu.arch.regs[VCPU_REGS_RIP] = save->rip; svm->vcpu.arch.regs[VCPU_REGS_RIP] = save->rip;
/* /* This is the guest-visible cr0 value.
* cr0 val on cpu init should be 0x60000010, we enable cpu * svm_set_cr0() sets PG and WP and clears NW and CD on save->cr0.
* cache by default. the orderly way is to enable cache in bios.
*/ */
save->cr0 = 0x00000010 | X86_CR0_PG | X86_CR0_WP; svm->vcpu.arch.cr0 = X86_CR0_NW | X86_CR0_CD | X86_CR0_ET;
kvm_set_cr0(&svm->vcpu, svm->vcpu.arch.cr0);
save->cr4 = X86_CR4_PAE; save->cr4 = X86_CR4_PAE;
/* rdx = ?? */ /* rdx = ?? */
......
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