Re: [PATCH 14/21] MIPS: KVM: Add nanosecond count bias KVM register

David Daney
2014-04-25T17:27:20Z

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 <james.hogan@imgtec.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Gleb Natapov <gleb@kernel.org>
> Cc: kvm@vger.kernel.org
> Cc: Ralf Baechle <ralf@linux-mips.org>
> Cc: linux-mips@linux-mips.org
> Cc: David Daney <david.daney@cavium.com>
> Cc: Sanjay Lal <sanjayl@kymasys.com>
> ---
> 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(+)
>