From patchwork Mon Dec 14 11:22:20 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 67262 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nBEBgC2o009662 for ; Mon, 14 Dec 2009 11:42:12 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756984AbZLNLli (ORCPT ); Mon, 14 Dec 2009 06:41:38 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756962AbZLNLlh (ORCPT ); Mon, 14 Dec 2009 06:41:37 -0500 Received: from mail-va3.bigfish.com ([216.32.180.111]:43826 "EHLO mail10-va3-R.bigfish.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756922AbZLNLlg (ORCPT ); Mon, 14 Dec 2009 06:41:36 -0500 X-Greylist: delayed 1138 seconds by postgrey-1.27 at vger.kernel.org; Mon, 14 Dec 2009 06:41:35 EST Received: from mail10-va3 (localhost.localdomain [127.0.0.1]) by mail10-va3-R.bigfish.com (Postfix) with ESMTP id 5E0D5B08C14; Mon, 14 Dec 2009 11:22:34 +0000 (UTC) X-SpamScore: 3 X-BigFish: VPS3(zzab9bhzz1202hzzz32i6bh43j61h) X-Spam-TCS-SCL: 0:0 X-MS-Exchange-Organization-Antispam-Report: OrigIP: 163.181.251.8; Service: EHS Received: from mail10-va3 (localhost.localdomain [127.0.0.1]) by mail10-va3 (MessageSwitch) id 1260789752872295_24794; Mon, 14 Dec 2009 11:22:32 +0000 (UTC) Received: from VA3EHSMHS023.bigfish.com (unknown [10.7.14.237]) by mail10-va3.bigfish.com (Postfix) with ESMTP id D15E5196804B; Mon, 14 Dec 2009 11:22:32 +0000 (UTC) Received: from ausb3extmailp01.amd.com (163.181.251.8) by VA3EHSMHS023.bigfish.com (10.7.99.33) with Microsoft SMTP Server (TLS) id 14.0.482.32; Mon, 14 Dec 2009 11:22:30 +0000 Received: from ausb3twp02.amd.com ([163.181.250.38]) by ausb3extmailp01.amd.com (Switch-3.2.7/Switch-3.2.7) with ESMTP id nBEBMO7b031812; Mon, 14 Dec 2009 05:22:27 -0600 X-WSS-ID: 0KUN3LB-02-03F-02 X-M-MSG: Received: from sausexbh2.amd.com (SAUSEXBH2.amd.com [163.181.22.102]) by ausb3twp02.amd.com (Tumbleweed MailGate 3.7.2) with ESMTP id 21950C8B15; Mon, 14 Dec 2009 05:22:22 -0600 (CST) Received: from sausexmb1.amd.com ([163.181.3.156]) by sausexbh2.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 14 Dec 2009 05:22:26 -0600 Received: from seurexmb1.amd.com ([165.204.9.130]) by sausexmb1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 14 Dec 2009 05:22:25 -0600 Received: from lemmy.amd.com ([165.204.15.93]) by seurexmb1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 14 Dec 2009 12:22:23 +0100 Received: by lemmy.amd.com (Postfix, from userid 41430) id B3E0BC9A71; Mon, 14 Dec 2009 12:22:23 +0100 (CET) From: Joerg Roedel To: Avi Kivity , Marcelo Tosatti CC: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Joerg Roedel Subject: [PATCH] KVM: SVM: Adjust tsc_offset only if tsc_unstable Date: Mon, 14 Dec 2009 12:22:20 +0100 Message-ID: <1260789740-14847-1-git-send-email-joerg.roedel@amd.com> X-Mailer: git-send-email 1.6.5.4 X-OriginalArrivalTime: 14 Dec 2009 11:22:23.0829 (UTC) FILETIME=[B56B0050:01CA7CAF] MIME-Version: 1.0 X-Reverse-DNS: unknown Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 3de0b37..cb04378 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -767,14 +767,16 @@ static void svm_vcpu_load(struct kvm_vcpu *vcpu, int cpu) if (unlikely(cpu != vcpu->cpu)) { u64 delta; - /* - * Make sure that the guest sees a monotonically - * increasing TSC. - */ - delta = vcpu->arch.host_tsc - native_read_tsc(); - svm->vmcb->control.tsc_offset += delta; - if (is_nested(svm)) - svm->nested.hsave->control.tsc_offset += delta; + if (check_tsc_unstable()) { + /* + * Make sure that the guest sees a monotonically + * increasing TSC. + */ + delta = vcpu->arch.host_tsc - native_read_tsc(); + svm->vmcb->control.tsc_offset += delta; + if (is_nested(svm)) + svm->nested.hsave->control.tsc_offset += delta; + } vcpu->cpu = cpu; kvm_migrate_timers(vcpu); svm->asid_generation = 0;