From patchwork Tue Jun 15 07:34:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zachary Amsden X-Patchwork-Id: 106154 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o5F7cinc009615 for ; Tue, 15 Jun 2010 07:38:45 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754712Ab0FOHef (ORCPT ); Tue, 15 Jun 2010 03:34:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42135 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754680Ab0FOHed (ORCPT ); Tue, 15 Jun 2010 03:34:33 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5F7YXWe002094 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 15 Jun 2010 03:34:33 -0400 Received: from mysore (vpn-8-141.rdu.redhat.com [10.11.8.141]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5F7YL2e024602; Tue, 15 Jun 2010 03:34:31 -0400 From: Zachary Amsden To: avi@redhat.com, mtosatti@redhat.com, glommer@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Zachary Amsden Subject: [PATCH 04/17] Fix deep C-state TSC desynchronization Date: Mon, 14 Jun 2010 21:34:06 -1000 Message-Id: <1276587259-32319-5-git-send-email-zamsden@redhat.com> In-Reply-To: <1276587259-32319-1-git-send-email-zamsden@redhat.com> References: <1276587259-32319-1-git-send-email-zamsden@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 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.3 (demeter.kernel.org [140.211.167.41]); Tue, 15 Jun 2010 07:38:45 +0000 (UTC) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index c8289d0..618c435 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -1822,7 +1822,18 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu) { kvm_x86_ops->vcpu_put(vcpu); kvm_put_guest_fpu(vcpu); + vcpu->arch.last_host_tsc = native_read_tsc(); + + /* + * When potentially leaving a CPU with unstable TSCs, we risk + * that the CPU enters deep C-state. If it does, the TSC may + * go out of sync but we will not recalibrate because the test + * vcpu->cpu != cpu can not detect this condition. So set + * vcpu->cpu = -1 to force the recalibration above. + */ + if (check_tsc_unstable()) + vcpu->cpu = -1; } static int is_efer_nx(void)