Merge branch 'x86-fpu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[cascardo/linux.git] / arch / x86 / kvm / vmx.c
index b06737d..851aa7c 100644 (file)
@@ -1493,8 +1493,12 @@ static void __vmx_load_host_state(struct vcpu_vmx *vmx)
 #ifdef CONFIG_X86_64
        wrmsrl(MSR_KERNEL_GS_BASE, vmx->msr_host_kernel_gs_base);
 #endif
-       if (user_has_fpu())
-               clts();
+       /*
+        * If the FPU is not active (through the host task or
+        * the guest vcpu), then restore the cr0.TS bit.
+        */
+       if (!user_has_fpu() && !vmx->vcpu.guest_fpu_loaded)
+               stts();
        load_gdt(&__get_cpu_var(host_gdt));
 }
 
@@ -3743,7 +3747,7 @@ static void vmx_set_constant_host_state(void)
        unsigned long tmpl;
        struct desc_ptr dt;
 
-       vmcs_writel(HOST_CR0, read_cr0() X86_CR0_TS);  /* 22.2.3 */
+       vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS);  /* 22.2.3 */
        vmcs_writel(HOST_CR4, read_cr4());  /* 22.2.3, 22.2.5 */
        vmcs_writel(HOST_CR3, read_cr3());  /* 22.2.3  FIXME: shadow tables */