From: Joerg Roedel Date: Mon, 21 Jan 2008 12:09:33 +0000 (+0100) Subject: KVM: SVM: Fix lazy FPU switching X-Git-Tag: v2.6.25-rc4~97^2~13 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=334df50a866ff7e234c9566960997ca5b9d0a382;p=karo-tx-linux.git KVM: SVM: Fix lazy FPU switching If the guest writes to cr0 and leaves the TS flag at 0 while vcpu->fpu_active is also 0, the TS flag in the guest's cr0 gets lost. This leads to corrupt FPU state an causes Windows Vista 64bit to crash very soon after boot. This patch fixes this bug. Signed-off-by: Joerg Roedel Signed-off-by: Markus Rechberger Signed-off-by: Avi Kivity --- diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index de755cb1431d..511628916c4b 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -792,6 +792,8 @@ static void svm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0) vcpu->arch.cr0 = cr0; cr0 |= X86_CR0_PG | X86_CR0_WP; cr0 &= ~(X86_CR0_CD | X86_CR0_NW); + if (!vcpu->fpu_active) + cr0 |= X86_CR0_TS; svm->vmcb->save.cr0 = cr0; }