From: Eduardo Habkost <ehabkost@redhat.com>
To: Avi Kivity <avi@redhat.com>, Marcelo Tosatti <mtosatti@redhat.com>
Cc: kvm@vger.kernel.org
Subject: [PATCH 2/3] kvm: svm: reset cr0 properly on vcpu reset
Date: Sat, 24 Oct 2009 02:49:59 -0200 [thread overview]
Message-ID: <1256359800-16893-3-git-send-email-ehabkost@redhat.com> (raw)
In-Reply-To: <1256359800-16893-1-git-send-email-ehabkost@redhat.com>
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>
---
arch/x86/kvm/svm.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 170b2d9..6b86a11 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -626,11 +626,12 @@ static void init_vmcb(struct vcpu_svm *svm)
save->rip = 0x0000fff0;
svm->vcpu.arch.regs[VCPU_REGS_RIP] = save->rip;
- /*
- * cr0 val on cpu init should be 0x60000010, we enable cpu
- * cache by default. the orderly way is to enable cache in bios.
+ /* This is the guest-visible cr0 value.
+ * svm_set_cr0() sets PG and WP and clears NW and CD on save->cr0.
*/
- 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;
/* rdx = ?? */
--
1.6.3.rc4.29.g8146
next prev parent reply other threads:[~2009-10-24 4:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-24 4:49 [PATCH 0/3] kvm: fix cr0 initialization on SIPI reset Eduardo Habkost
2009-10-24 4:49 ` [PATCH 1/3] kvm: vmx: use macros instead of hex value on cr0 initialization Eduardo Habkost
2009-10-24 4:49 ` Eduardo Habkost [this message]
2010-03-17 18:17 ` [PATCH 2/3] kvm: svm: reset cr0 properly on vcpu reset Alexander Graf
2010-03-17 21:42 ` Eduardo Habkost
2010-03-17 21:48 ` Alexander Graf
2010-03-19 14:51 ` Eduardo Habkost
2010-03-19 15:14 ` Alexander Graf
2009-10-24 4:50 ` [PATCH 3/3] kvm: svm: init_vmcb(): remove redundant save->cr0 initialization Eduardo Habkost
2009-10-25 9:40 ` [PATCH 0/3] kvm: fix cr0 initialization on SIPI reset Avi Kivity
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1256359800-16893-3-git-send-email-ehabkost@redhat.com \
--to=ehabkost@redhat.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox