From patchwork Fri Mar 25 08:44:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 661211 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p2P8jReF025830 for ; Fri, 25 Mar 2011 08:45:27 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755623Ab1CYIpV (ORCPT ); Fri, 25 Mar 2011 04:45:21 -0400 Received: from tx2ehsobe001.messaging.microsoft.com ([65.55.88.11]:42243 "EHLO TX2EHSOBE002.bigfish.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755266Ab1CYIpE (ORCPT ); Fri, 25 Mar 2011 04:45:04 -0400 Received: from mail80-tx2-R.bigfish.com (10.9.14.251) by TX2EHSOBE002.bigfish.com (10.9.40.22) with Microsoft SMTP Server id 14.1.225.8; Fri, 25 Mar 2011 08:45:03 +0000 Received: from mail80-tx2 (localhost.localdomain [127.0.0.1]) by mail80-tx2-R.bigfish.com (Postfix) with ESMTP id 9357A19A8589; Fri, 25 Mar 2011 08:45:03 +0000 (UTC) X-SpamScore: -2 X-BigFish: VPS-2(zzbb2cKzz1202hzz8275bhz32i668h62h) X-Spam-TCS-SCL: 1:0 X-Forefront-Antispam-Report: KIP:(null); UIP:(null); IPVD:NLI; H:ausb3twp01.amd.com; RD:none; EFVD:NLI Received: from mail80-tx2 (localhost.localdomain [127.0.0.1]) by mail80-tx2 (MessageSwitch) id 1301042703389584_3731; Fri, 25 Mar 2011 08:45:03 +0000 (UTC) Received: from TX2EHSMHS034.bigfish.com (unknown [10.9.14.243]) by mail80-tx2.bigfish.com (Postfix) with ESMTP id 0C77435805A; Fri, 25 Mar 2011 08:45:03 +0000 (UTC) Received: from ausb3twp01.amd.com (163.181.249.108) by TX2EHSMHS034.bigfish.com (10.9.99.134) with Microsoft SMTP Server id 14.1.225.8; Fri, 25 Mar 2011 08:44:59 +0000 X-WSS-ID: 0LILUYU-01-KYK-02 X-M-MSG: Received: from sausexedgep02.amd.com (sausexedgep02-ext.amd.com [163.181.249.73]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by ausb3twp01.amd.com (Tumbleweed MailGate 3.7.2) with ESMTP id 2C69710287F2; Fri, 25 Mar 2011 03:44:53 -0500 (CDT) Received: from sausexhtp01.amd.com (163.181.3.165) by sausexedgep02.amd.com (163.181.36.59) with Microsoft SMTP Server (TLS) id 8.3.106.1; Fri, 25 Mar 2011 03:52:21 -0500 Received: from storexhtp02.amd.com (172.24.4.4) by sausexhtp01.amd.com (163.181.3.165) with Microsoft SMTP Server (TLS) id 8.3.83.0; Fri, 25 Mar 2011 03:44:57 -0500 Received: from gwo.osrc.amd.com (165.204.16.204) by storexhtp02.amd.com (172.24.4.4) with Microsoft SMTP Server id 8.3.83.0; Fri, 25 Mar 2011 04:44:55 -0400 Received: from lemmy.osrc.amd.com (lemmy.osrc.amd.com [165.204.15.93]) by gwo.osrc.amd.com (Postfix) with ESMTP id 76BF049C593; Fri, 25 Mar 2011 08:44:54 +0000 (GMT) Received: by lemmy.osrc.amd.com (Postfix, from userid 1000) id 5A8C3101BA4; Fri, 25 Mar 2011 09:44:54 +0100 (CET) From: Joerg Roedel To: Avi Kivity , Marcelo Tosatti CC: Zachary Amsden , , Joerg Roedel Subject: [PATCH 3/6] KVM: X86: Make tsc_delta calculation a function of guest tsc Date: Fri, 25 Mar 2011 09:44:48 +0100 Message-ID: <1301042691-22929-4-git-send-email-joerg.roedel@amd.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1301042691-22929-1-git-send-email-joerg.roedel@amd.com> References: <1301042691-22929-1-git-send-email-joerg.roedel@amd.com> MIME-Version: 1.0 X-OriginatorOrg: amd.com Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 25 Mar 2011 08:45:27 +0000 (UTC) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 1e7af86..47dd6ed 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -2126,8 +2126,13 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) kvm_x86_ops->vcpu_load(vcpu, cpu); if (unlikely(vcpu->cpu != cpu) || check_tsc_unstable()) { /* Make sure TSC doesn't go backwards */ - s64 tsc_delta = !vcpu->arch.last_host_tsc ? 0 : - native_read_tsc() - vcpu->arch.last_host_tsc; + s64 tsc_delta; + u64 tsc; + + kvm_get_msr(vcpu, MSR_IA32_TSC, &tsc); + tsc_delta = !vcpu->arch.last_guest_tsc ? 0 : + tsc - vcpu->arch.last_guest_tsc; + if (tsc_delta < 0) mark_tsc_unstable("KVM discovered backwards TSC"); if (check_tsc_unstable()) {