From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 0/2] Fix build on i386 due to the latest tsc changes Date: Thu, 16 Feb 2012 15:53:40 +0200 Message-ID: <4F3D0A64.60603@redhat.com> References: <1329400083-22070-1-git-send-email-avi@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: Marcelo Tosatti Return-path: Received: from mx1.redhat.com ([209.132.183.28]:32458 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750866Ab2BPNxm (ORCPT ); Thu, 16 Feb 2012 08:53:42 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q1GDrgw0012151 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 16 Feb 2012 08:53:42 -0500 In-Reply-To: <1329400083-22070-1-git-send-email-avi@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 02/16/2012 03:48 PM, Avi Kivity wrote: > The code fixed by the second patch looks suspect though: > > nsdiff = data - kvm->arch.last_tsc_write; > nsdiff = (nsdiff * 1000) / vcpu->arch.virtual_tsc_khz; > > before the division, nsdiff is in tsc units. Dividing it by > tsc_khz/1000 is equivalent to multiplying it by 1000000 and dividing it by > tsc_hz, so the result is in units of mega-seconds. I expect we want > Actually it results in units of microseconds, while we want nanoseconds. So maybe the correct code is nsdiff = (nsdiff * 1000000) / vcpu->arch.virtual_tsc_khz; returning nanoseconds. I note that if the guest writes a large value into the tsc, this breaks. -- error compiling committee.c: too many arguments to function