From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55167) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XF3po-0002UY-AE for qemu-devel@nongnu.org; Wed, 06 Aug 2014 12:13:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XF3pi-0005Vy-2x for qemu-devel@nongnu.org; Wed, 06 Aug 2014 12:13:04 -0400 Received: from mail-we0-x22d.google.com ([2a00:1450:400c:c03::22d]:62766) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XF3ph-0005Vf-Rs for qemu-devel@nongnu.org; Wed, 06 Aug 2014 12:12:57 -0400 Received: by mail-we0-f173.google.com with SMTP id q58so2951452wes.18 for ; Wed, 06 Aug 2014 09:12:57 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Wed, 6 Aug 2014 18:12:29 +0200 Message-Id: <1407341555-13173-6-git-send-email-pbonzini@redhat.com> In-Reply-To: <1407341555-13173-1-git-send-email-pbonzini@redhat.com> References: <1407341555-13173-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 05/11] icount: Fix virtual clock start value on ARM List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Sebastian Tanase From: Sebastian Tanase When using the icount option on ARM, the virtual clock starts counting at realtime clock but it should start at 0. The reason why the virtual clock starts at realtime clock is because the first time we call qemu_clock_warp (which calls icount_warp_rt) in tcg_exec_all, qemu_icount_bias (which is part of the virtual time computation mechanism) will increment by realtime - vm_clock_warp_start, with vm_clock_warp_start being 0 (see icount_warp_rt in cpus.c). By changing the value of vm_clock_warp_start from 0 to -1, the first time we call qemu_clock_warp which calls icount_warp_rt, we will return immediatly because icount_warp_rt first checks if vm_clock_warp_start is -1 and if it's the case it returns. Therefore, qemu_icount_bias will first be incremented by the value of a virtual timer deadline when the virtual cpu goes from active to inactive. The virtual time will start at 0 and increment based on the instruction counter when the vcpu is active or the qemu_icount_bias value when inactive. Signed-off-by: Sebastian Tanase Signed-off-by: Paolo Bonzini --- cpus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpus.c b/cpus.c index 62636a6..bbb8d4e 100644 --- a/cpus.c +++ b/cpus.c @@ -102,7 +102,7 @@ static bool all_cpu_threads_idle(void) /* Protected by TimersState seqlock */ -static int64_t vm_clock_warp_start; +static int64_t vm_clock_warp_start = -1; /* Conversion factor from emulated instructions to virtual clock ticks. */ static int icount_time_shift; /* Arbitrarily pick 1MIPS as the minimum allowable speed. */ -- 1.9.3