From mboxrd@z Thu Jan 1 00:00:00 1970 From: Boris Ostrovsky Subject: Re: [PATCH v2 2/2] x86/HVM: Use fixed TSC value when saving or restoring domain Date: Fri, 04 Apr 2014 11:54:00 -0400 Message-ID: <533ED598.3040405@oracle.com> References: <1396367638-4111-1-git-send-email-boris.ostrovsky@oracle.com> <1396367638-4111-3-git-send-email-boris.ostrovsky@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1396367638-4111-3-git-send-email-boris.ostrovsky@oracle.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Boris Ostrovsky Cc: kevin.tian@intel.com, keir@xen.org, ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com, jun.nakajima@intel.com, eddie.dong@intel.com, ian.jackson@eu.citrix.com, xen-devel@lists.xen.org, jbeulich@suse.com, suravee.suthikulpanit@amd.com List-Id: xen-devel@lists.xenproject.org On 04/01/2014 11:53 AM, Boris Ostrovsky wrote: > When a domain is saved each VCPU's TSC value needs to be preserved. To get it we > use hvm_get_guest_tsc(). This routine (either itself or via get_s_time() which > it may call) calculates VCPU's TSC based on current host's TSC value (by doing a > rdtscll()). Since this is performed for each VCPU separately we end up with > un-synchronized TSCs. > > Similarly, during a restore each VCPU is assigned its TSC based on host's current > tick, causing virtual TSCs to diverge further. > > With this, we can easily get into situation where a guest may see time going > backwards. > > Instead of reading new TSC value for each VCPU when saving/restoring it we should > use the same value across all VCPUs. > > (As part of the patch, update rdtscll's definition so that its variables don't > clash with outer code) > > Signed-off-by: Boris Ostrovsky > Reviewed-by: Kevin Tian This patch will need to be updated as it doesn't quite fix the problem on some AMD processors (they may do one extra rdtsc in svm_set_tsc_offset()). -boris