Re: [patch 15/38] ptp: ptp_vmclock: Replace get_cycles() usage

David Woodhouse
2026-04-13T15:33:16Z

[-- Attachment #1: Type: text/plain, Size: 994 bytes --]

On Fri, 2026-04-10 at 14:19 +0200, Thomas Gleixner wrote:
> get_cycles() is not really well defined and similar to other usaage of the
> underlying hardware CPU counters the PTP vmclock should use an explicit
> interface as well.
>
> Implement ptp_vmclock_read_cpu_counter() in arm64 and x86 and simplify the
> Kconfig selection while at it.
>
> No functional change.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> Cc: David Woodhouse <dwmw2@infradead.org>

Acked-by: David Woodhouse <dwmw@amazon.co.uk>

Although I might follow up with a change to make this...

> +static inline u64 ptp_vmclock_read_cpu_counter(void)
> +{
> + return cpu_feature_enabled(X86_FEATURE_TSC) ? rdtsc() : 0;
> +}
> +

... depend on TSC_RELIABLE¹, since if the guest doesn't believe that it
is, then the guest shouldn't be trying to use it as the basis for
precise timing.

¹ (Or... one of the other zoo of TSC flags for the gradually reducing
brokenness over the years...)

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5069 bytes --]