From: Marcelo Tosatti <mtosatti@redhat.com>
To: kvm <kvm@vger.kernel.org>
Cc: Avi Kivity <avi@redhat.com>
Subject: KVM: VMX: update cr0 read shadow when deactivating cr0.ts passthrough
Date: Mon, 1 Feb 2010 14:48:27 -0200 [thread overview]
Message-ID: <20100201164827.GA3225@amt.cnet> (raw)
On fpu deactivation, the cr0 read shadow is not properly updated, since
it assumes vcpu->arch.cr0 contains the guest visible cr0 value before
guest had control of cr0.ts.
This is not true, since cr0 has been decached (from vmx_fpu_deactivate
itself or somewhere else).
Fix by unconditionally updating cr0 read shadow (this is not a hot path,
in comparison with entry/exit).
Fixes FC8 64 install.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index c1d864a..334b016 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -805,19 +805,16 @@ static void vmx_fpu_activate(struct kvm_vcpu *vcpu)
vmcs_writel(CR0_GUEST_HOST_MASK, ~vcpu->arch.cr0_guest_owned_bits);
}
+static void vmx_decache_cr0_guest_bits(struct kvm_vcpu *vcpu);
+
static void vmx_fpu_deactivate(struct kvm_vcpu *vcpu)
{
- ulong old_ts, old_cr0;
-
- old_ts = kvm_read_cr0_bits(vcpu, X86_CR0_TS);
+ vmx_decache_cr0_guest_bits(vcpu);
vmcs_set_bits(GUEST_CR0, X86_CR0_TS | X86_CR0_MP);
update_exception_bitmap(vcpu);
vcpu->arch.cr0_guest_owned_bits = 0;
vmcs_writel(CR0_GUEST_HOST_MASK, ~vcpu->arch.cr0_guest_owned_bits);
- old_cr0 = vcpu->arch.cr0;
- vcpu->arch.cr0 = (vcpu->arch.cr0 & ~X86_CR0_TS) | old_ts;
- if (vcpu->arch.cr0 != old_cr0)
- vmcs_writel(CR0_READ_SHADOW, vcpu->arch.cr0);
+ vmcs_writel(CR0_READ_SHADOW, vcpu->arch.cr0);
}
static unsigned long vmx_get_rflags(struct kvm_vcpu *vcpu)
next reply other threads:[~2010-02-01 16:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-01 16:48 Marcelo Tosatti [this message]
2010-02-07 11:53 ` KVM: VMX: update cr0 read shadow when deactivating cr0.ts passthrough 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=20100201164827.GA3225@amt.cnet \
--to=mtosatti@redhat.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
/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