x86/vdso: Fix gettimeofday masking
authorPeter Zijlstra <peterz@infradead.org>
Fri, 19 May 2023 10:21:06 +0000 (12:21 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Mon, 5 Jun 2023 19:11:07 +0000 (21:11 +0200)
commit77750f78b0b3247c64b9821b49158cafe0506880
tree0b3efda22d56270b3e3b34a072d0865f1ddc2249
parentfc4a0db4149afcdae2527f0d8c376accca34adc9
x86/vdso: Fix gettimeofday masking

Because of how the virtual clocks use U64_MAX as an exception value
instead of a valid time, the clocks can no longer be assumed to wrap
cleanly. This is then compounded by arch_vdso_cycles_ok() rejecting
everything with the MSB/Sign-bit set.

Therefore, the effective mask becomes S64_MAX, and the comment with
vdso_calc_delta() that states the mask is U64_MAX and isn't optimized
out is just plain silly.

Now, the code has a negative filter -- to deal with TSC wobbles:

if (cycles > last)

which is just plain wrong, because it should've been written as:

if ((s64)(cycles - last) > 0)

to take wrapping into account, but per all the above, we don't
actually wrap on u64 anymore.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Michael Kelley <mikelley@microsoft.com> # Hyper-V
Link: https://lore.kernel.org/r/20230519102715.704767397@infradead.org
arch/x86/include/asm/vdso/gettimeofday.h