From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joerg Roedel Subject: Re: [patch 7/8] Dont mark TSC unstable due to S4 suspend Date: Wed, 8 Feb 2012 16:18:48 +0100 Message-ID: <20120208151848.GC22598@amd.com> References: <20120203174349.110232777@amt.cnet> <20120203174449.321042059@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Cc: , To: Marcelo Tosatti Return-path: Received: from va3ehsobe010.messaging.microsoft.com ([216.32.180.30]:50282 "EHLO VA3EHSOBE009.bigfish.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752111Ab2BHPUX (ORCPT ); Wed, 8 Feb 2012 10:20:23 -0500 Content-Disposition: inline In-Reply-To: <20120203174449.321042059@amt.cnet> Sender: kvm-owner@vger.kernel.org List-ID: On Fri, Feb 03, 2012 at 03:43:56PM -0200, Marcelo Tosatti wrote: > + if (backwards_tsc) { > + u64 delta_cyc = max_tsc - local_tsc; > + list_for_each_entry(kvm, &vm_list, vm_list) { > + kvm_for_each_vcpu(i, vcpu, kvm) { > + vcpu->arch.tsc_offset_adjustment += delta_cyc; > + vcpu->arch.last_host_tsc = local_tsc; > + } > + > + /* > + * We have to disable TSC offset matching.. if you were > + * booting a VM while issuing an S4 host suspend.... > + * you may have some problem. Solving this issue is > + * left as an exercise to the reader. > + */ > + kvm->arch.last_tsc_nsec = 0; > + kvm->arch.last_tsc_write = 0; > + } > + > + } > + return 0; This is not going to work when tsc-scaling is enabled. The adjust_tsc_offset_host() function just scales the offset the same way the tsc is scaled. But that is broken because the tsc-offset is applied _after_ the tsc-ratio by scaling hardware. So to get the desired tsc-value in the guest the offset needs to be scaled in the opposite direction as the tsc itself. This is rather complicated to implement. I suggest to drop patch 6/8 and just let adjust_tsc_offset() be using guest-tsc units. These loops have to be changed then to work with the guest-tsc instead of the host-tsc. Joerg -- AMD Operating System Research Center Advanced Micro Devices GmbH Einsteinring 24 85609 Dornach General Managers: Alberto Bozzo Registration: Dornach, Landkr. Muenchen; Registerger. Muenchen, HRB Nr. 43632