From patchwork Wed Dec 30 16:25:42 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 70275 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.2) with ESMTP id nBUGPuD9003754 for ; Wed, 30 Dec 2009 16:25:57 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752508AbZL3QZv (ORCPT ); Wed, 30 Dec 2009 11:25:51 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752502AbZL3QZv (ORCPT ); Wed, 30 Dec 2009 11:25:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:12392 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752518AbZL3QZs (ORCPT ); Wed, 30 Dec 2009 11:25:48 -0500 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nBUGPkWJ031369 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 30 Dec 2009 11:25:46 -0500 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nBUGPjEn019111; Wed, 30 Dec 2009 11:25:46 -0500 Received: from localhost.localdomain (file.tlv.redhat.com [10.35.255.8]) by cleopatra.tlv.redhat.com (Postfix) with ESMTP id 25E11250054; Wed, 30 Dec 2009 18:25:43 +0200 (IST) From: Avi Kivity To: Marcelo Tosatti , Sheng Yang , Joerg Roedel Cc: kvm@vger.kernel.org Subject: [PATCH 5/5] KVM: VMX: Give the guest ownership of cr0.ts when the fpu is active Date: Wed, 30 Dec 2009 18:25:42 +0200 Message-Id: <1262190342-18611-6-git-send-email-avi@redhat.com> In-Reply-To: <1262190342-18611-1-git-send-email-avi@redhat.com> References: <1262190342-18611-1-git-send-email-avi@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 7e0b45e..81dc432 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -797,12 +797,23 @@ static void vmx_fpu_activate(struct kvm_vcpu *vcpu) if (kvm_read_cr0_bits(vcpu, X86_CR0_TS)) vmcs_set_bits(GUEST_CR0, X86_CR0_TS); update_exception_bitmap(vcpu); + vcpu->arch.cr0_guest_owned_bits = X86_CR0_TS; + vmcs_writel(CR0_GUEST_HOST_MASK, ~vcpu->arch.cr0_guest_owned_bits); } static void vmx_fpu_deactivate(struct kvm_vcpu *vcpu) { + ulong old_ts, old_cr0; + + old_ts = kvm_read_cr0_bits(vcpu, X86_CR0_TS); vmcs_set_bits(GUEST_CR0, X86_CR0_TS); 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); } static unsigned long vmx_get_rflags(struct kvm_vcpu *vcpu)