From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Daney Subject: Re: [PATCH 14/21] MIPS: KVM: Add nanosecond count bias KVM register Date: Fri, 25 Apr 2014 10:27:17 -0700 Message-ID: <535A9AF5.30105@gmail.com> References: <1398439204-26171-1-git-send-email-james.hogan@imgtec.com> <1398439204-26171-15-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, David Daney , Sanjay Lal To: James Hogan Return-path: Received: from mail-ig0-f181.google.com ([209.85.213.181]:53361 "EHLO mail-ig0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752434AbaDYR1U (ORCPT ); Fri, 25 Apr 2014 13:27:20 -0400 Received: by mail-ig0-f181.google.com with SMTP id h18so2467554igc.8 for ; Fri, 25 Apr 2014 10:27:20 -0700 (PDT) In-Reply-To: <1398439204-26171-15-git-send-email-james.hogan@imgtec.com> Sender: kvm-owner@vger.kernel.org List-ID: On 04/25/2014 08:19 AM, James Hogan wrote: > Expose the KVM guest CP0_Count bias (from the monotonic kernel time) to > userland in nanosecond units via a new KVM_REG_MIPS_COUNT_BIAS register > accessible with the KVM_{GET,SET}_ONE_REG ioctls. This gives userland > control of the bias so that it can exactly match its own monotonic time. > > The nanosecond bias is stored separately from the raw bias used > internally (since nanoseconds isn't a convenient or efficient unit for > various timer calculations), and is recalculated each time the raw count > bias is altered. The raw count bias used in CP0_Count determination is > recalculated when the nanosecond bias is altered via the KVM_SET_ONE_REG > ioctl. > Is this really necessary? The architecture has CP0_COUNT. How does the concept of this noew synthetic bias value interact with the architecture's CP0_COUNT? It seems like by adding this you new have two ways to access and manipulate the same thing. 1) The architecturally specified CP0_COUNT. 2) This new bias thing. What if we just let userspace directly manipulate the CP0_COUNT, and if necessary only maintain a bias as an internal implementation detail? David Daney. > Signed-off-by: James Hogan > Cc: Paolo Bonzini > Cc: Gleb Natapov > Cc: kvm@vger.kernel.org > Cc: Ralf Baechle > Cc: linux-mips@linux-mips.org > Cc: David Daney > Cc: Sanjay Lal > --- > arch/mips/include/asm/kvm_host.h | 3 +++ > arch/mips/include/uapi/asm/kvm.h | 9 ++++++++ > arch/mips/kvm/kvm_mips.c | 3 +++ > arch/mips/kvm/kvm_mips_emul.c | 46 ++++++++++++++++++++++++++++++++++++++++ > arch/mips/kvm/kvm_trap_emul.c | 6 ++++++ > 5 files changed, 67 insertions(+) >