* [PATCH] KVM: VMX: Fix clts
@ 2010-01-24 10:17 Avi Kivity
2010-01-25 13:25 ` Marcelo Tosatti
0 siblings, 1 reply; 2+ messages in thread
From: Avi Kivity @ 2010-01-24 10:17 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: kvm
The simplistic clts implementation has a couple of flaws:
- kvm_read_cr0_bits() is temporarily unsynchronized when vcpu->arch.cr0 changes
- if the fpu is active, we need to clear GUEST_CR0.TS, not just
CR_READ_SHADOW.TS, so that we don't send the guest an unexpected #NM.
Fix by replacing custom logic with a call to vmx_set_cr0(), which does the
right thing, albeit less efficiently.
Signed-off-by: Avi Kivity <avi@redhat.com>
---
arch/x86/kvm/vmx.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 9f56110..d27ff6a 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -3007,8 +3007,7 @@ static int handle_cr(struct kvm_vcpu *vcpu)
};
break;
case 2: /* clts */
- vcpu->arch.cr0 &= ~X86_CR0_TS;
- vmcs_writel(CR0_READ_SHADOW, kvm_read_cr0(vcpu));
+ vmx_set_cr0(vcpu, kvm_read_cr0_bits(vcpu, ~X86_CR0_TS));
trace_kvm_cr_write(0, kvm_read_cr0(vcpu));
skip_emulated_instruction(vcpu);
return 1;
--
1.6.5.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] KVM: VMX: Fix clts
2010-01-24 10:17 [PATCH] KVM: VMX: Fix clts Avi Kivity
@ 2010-01-25 13:25 ` Marcelo Tosatti
0 siblings, 0 replies; 2+ messages in thread
From: Marcelo Tosatti @ 2010-01-25 13:25 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm
On Sun, Jan 24, 2010 at 12:17:23PM +0200, Avi Kivity wrote:
> The simplistic clts implementation has a couple of flaws:
> - kvm_read_cr0_bits() is temporarily unsynchronized when vcpu->arch.cr0 changes
> - if the fpu is active, we need to clear GUEST_CR0.TS, not just
> CR_READ_SHADOW.TS, so that we don't send the guest an unexpected #NM.
>
> Fix by replacing custom logic with a call to vmx_set_cr0(), which does the
> right thing, albeit less efficiently.
>
> Signed-off-by: Avi Kivity <avi@redhat.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-01-25 13:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-24 10:17 [PATCH] KVM: VMX: Fix clts Avi Kivity
2010-01-25 13:25 ` Marcelo Tosatti
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox