From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Daney Subject: Re: [PATCH 11/21] MIPS: KVM: Rewrite count/compare timer emulation Date: Fri, 25 Apr 2014 10:00:21 -0700 Message-ID: <535A94A5.1040200@gmail.com> References: <1398439204-26171-1-git-send-email-james.hogan@imgtec.com> <1398439204-26171-12-git-send-email-james.hogan@imgtec.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Paolo Bonzini , Gleb Natapov , kvm@vger.kernel.org, Ralf Baechle , linux-mips@linux-mips.org, Sanjay Lal To: James Hogan Return-path: Received: from mail-ie0-f172.google.com ([209.85.223.172]:53287 "EHLO mail-ie0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751314AbaDYRAX (ORCPT ); Fri, 25 Apr 2014 13:00:23 -0400 Received: by mail-ie0-f172.google.com with SMTP id at1so657487iec.3 for ; Fri, 25 Apr 2014 10:00:23 -0700 (PDT) In-Reply-To: <1398439204-26171-12-git-send-email-james.hogan@imgtec.com> Sender: kvm-owner@vger.kernel.org List-ID: [...] > diff --git a/arch/mips/include/asm/kvm_host.h b/arch/mips/include/asm/kvm_host.h > index f56bb699506e..57c1085fd6ab 100644 > --- a/arch/mips/include/asm/kvm_host.h > +++ b/arch/mips/include/asm/kvm_host.h > @@ -404,8 +404,15 @@ struct kvm_vcpu_arch { > > u32 io_gpr; /* GPR used as IO source/target */ > > - /* Used to calibrate the virutal count register for the guest */ > - int32_t host_cp0_count; > + struct hrtimer comparecount_timer; > + /* Count bias from the raw time */ > + uint32_t count_bias; > + /* Frequency of timer in Hz */ > + uint32_t count_hz; We are currently running with timer frequencies of over 2GHz, so the width of this variable is close to the limit. Your follow-on patch exports this to user-space as part of the KVM ABI. I would suggest, at least for the user-space ABI, to make this a 64-bit wide value. > + /* Dynamic nanosecond bias (multiple of count_period) to avoid overflow */ > + s64 count_dyn_bias; > + /* Period of timer tick in ns */ > + u64 count_period; > > /* Bitmask of exceptions that are pending */ [...]