[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v1 2/5] timer: arm: Introduce functions to get the host cntfr
From: |
Peter Maydell |
Subject: |
Re: [PATCH v1 2/5] timer: arm: Introduce functions to get the host cntfrq |
Date: |
Tue, 10 Dec 2019 15:47:39 +0000 |
On Wed, 16 Oct 2019 at 15:34, Andrew Jones <address@hidden> wrote:
>
> When acceleration like KVM is in use it's necessary to use the host's
> counter frequency when converting ticks to or from time units.
>
> Signed-off-by: Andrew Jones <address@hidden>
> Reviewed-by: Richard Henderson <address@hidden>
> ---
> include/qemu/timer.h | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/include/qemu/timer.h b/include/qemu/timer.h
> index 85bc6eb00b21..8941ddea8242 100644
> --- a/include/qemu/timer.h
> +++ b/include/qemu/timer.h
> @@ -1006,6 +1006,22 @@ static inline int64_t cpu_get_host_ticks(void)
> }
> #endif
>
> +#if defined(__aarch64__)
> +static inline uint32_t cpu_get_host_tick_frequency(void)
> +{
> + uint64_t frq;
> + asm volatile("mrs %0, cntfrq_el0" : "=r" (frq));
> + return frq;
> +}
> +#elif defined(__arm__)
> +static inline uint32_t cpu_get_host_tick_frequency(void)
> +{
> + uint32_t frq;
> + asm volatile("mrc p15, 0, %0, c14, c0, 0" : "=r" (frq));
> + return frq;
> +}
> +#endif
Don't we want to know what the guest counter frequency
is, not the host counter frequency? That is, I would have
expected that we get this value via doing a KVM ONE_REG ioctl
to ask the kernel what the guest cntfrq is. Are we using
the host value on the assumption that the guest might have
misprogrammed their copy of the register?
thanks
-- PMM
- Re: [PATCH v1 2/5] timer: arm: Introduce functions to get the host cntfrq,
Peter Maydell <=