From patchwork Tue Mar 15 09:36:52 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 635661 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 p2F9bcdG023456 for ; Tue, 15 Mar 2011 09:37:38 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755895Ab1COJhW (ORCPT ); Tue, 15 Mar 2011 05:37:22 -0400 Received: from ch1outboundpool.messaging.microsoft.com ([216.32.181.186]:29639 "EHLO ch1outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754081Ab1COJhR (ORCPT ); Tue, 15 Mar 2011 05:37:17 -0400 Received: from mail221-ch1-R.bigfish.com (216.32.181.174) by CH1EHSOBE009.bigfish.com (10.43.70.59) with Microsoft SMTP Server id 14.1.225.8; Tue, 15 Mar 2011 09:37:16 +0000 Received: from mail221-ch1 (localhost.localdomain [127.0.0.1]) by mail221-ch1-R.bigfish.com (Postfix) with ESMTP id 01D6EEE0347; Tue, 15 Mar 2011 09:37:16 +0000 (UTC) X-SpamScore: -2 X-BigFish: VPS-2(zzbb2cKzz1202hzz8275bhz32i668h61h) X-Spam-TCS-SCL: 0:0 X-Forefront-Antispam-Report: KIP:(null); UIP:(null); IPVD:NLI; H:ausb3twp02.amd.com; RD:none; EFVD:NLI Received: from mail221-ch1 (localhost.localdomain [127.0.0.1]) by mail221-ch1 (MessageSwitch) id 1300181835650516_22110; Tue, 15 Mar 2011 09:37:15 +0000 (UTC) Received: from CH1EHSMHS035.bigfish.com (snatpool1.int.messaging.microsoft.com [10.43.68.250]) by mail221-ch1.bigfish.com (Postfix) with ESMTP id 7845F19E804E; Tue, 15 Mar 2011 09:37:15 +0000 (UTC) Received: from ausb3twp02.amd.com (163.181.249.109) by CH1EHSMHS035.bigfish.com (10.43.70.35) with Microsoft SMTP Server id 14.1.225.8; Tue, 15 Mar 2011 09:37:14 +0000 X-WSS-ID: 0LI3EPZ-02-7QE-02 X-M-MSG: Received: from sausexedgep01.amd.com (sausexedgep01-ext.amd.com [163.181.249.72]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by ausb3twp02.amd.com (Tumbleweed MailGate 3.7.2) with ESMTP id 204DFC8691; Tue, 15 Mar 2011 04:37:11 -0500 (CDT) Received: from sausexhtp02.amd.com (163.181.3.152) by sausexedgep01.amd.com (163.181.36.54) with Microsoft SMTP Server (TLS) id 8.3.106.1; Tue, 15 Mar 2011 04:44:08 -0500 Received: from storexhtp01.amd.com (172.24.4.3) by sausexhtp02.amd.com (163.181.3.152) with Microsoft SMTP Server (TLS) id 8.3.83.0; Tue, 15 Mar 2011 04:37:13 -0500 Received: from gwo.osrc.amd.com (165.204.16.204) by storexhtp01.amd.com (172.24.4.3) with Microsoft SMTP Server id 8.3.83.0; Tue, 15 Mar 2011 05:37:12 -0400 Received: from lemmy.osrc.amd.com (lemmy.osrc.amd.com [165.204.15.93]) by gwo.osrc.amd.com (Postfix) with ESMTP id 250A049C58F; Tue, 15 Mar 2011 09:37:12 +0000 (GMT) Received: by lemmy.osrc.amd.com (Postfix, from userid 1000) id 156C9FFCE5; Tue, 15 Mar 2011 10:37:12 +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: Tue, 15 Mar 2011 10:36:52 +0100 Message-ID: <1300181815-16190-4-git-send-email-joerg.roedel@amd.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1300181815-16190-1-git-send-email-joerg.roedel@amd.com> References: <1300181815-16190-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]); Tue, 15 Mar 2011 09:37:38 +0000 (UTC) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 50daff2..fbeb5ae 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -2127,8 +2127,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()) {