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

From: David Woodhouse

Date: Mon Apr 13 2026 - 11:33:27 EST


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@xxxxxxxxxx>
> Cc: David Woodhouse <dwmw2@xxxxxxxxxxxxx>

Acked-by: David Woodhouse <dwmw@xxxxxxxxxxxx>

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: smime.p7s
Description: S/MIME cryptographic signature