diff options
author | Peter Zijlstra <peterz@infradead.org> | 2023-05-19 13:21:07 +0300 |
---|---|---|
committer | Peter Zijlstra <peterz@infradead.org> | 2023-06-05 22:11:07 +0300 |
commit | 9397fa2ea3e7634f61da1ab76b9eb88ba04dfdfc (patch) | |
tree | f7e754cc61e0394b21845060b3f41f6b5f7bc450 /arch/x86/include/asm/vdso | |
parent | 77750f78b0b3247c64b9821b49158cafe0506880 (diff) | |
download | linux-9397fa2ea3e7634f61da1ab76b9eb88ba04dfdfc.tar.xz |
clocksource: hyper-v: Adjust hv_read_tsc_page_tsc() to avoid special casing U64_MAX
Currently hv_read_tsc_page_tsc() (ab)uses the (valid) time value of
U64_MAX as an error return. This breaks the clean wrap-around of the
clock.
Modify the function signature to return a boolean state and provide
another u64 pointer to store the actual time on success. This obviates
the need to steal one time value and restores the full counter width.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
Tested-by: Michael Kelley <mikelley@microsoft.com> # Hyper-V
Link: https://lore.kernel.org/r/20230519102715.775630881@infradead.org
Diffstat (limited to 'arch/x86/include/asm/vdso')
-rw-r--r-- | arch/x86/include/asm/vdso/gettimeofday.h | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/arch/x86/include/asm/vdso/gettimeofday.h b/arch/x86/include/asm/vdso/gettimeofday.h index 0badf0a9f03d..c81858d903dc 100644 --- a/arch/x86/include/asm/vdso/gettimeofday.h +++ b/arch/x86/include/asm/vdso/gettimeofday.h @@ -238,10 +238,12 @@ static u64 vread_pvclock(void) #ifdef CONFIG_HYPERV_TIMER static u64 vread_hvclock(void) { - u64 ret = hv_read_tsc_page(&hvclock_page); - if (likely(ret != U64_MAX)) - ret &= S64_MAX; - return ret; + u64 tsc, time; + + if (hv_read_tsc_page_tsc(&hvclock_page, &tsc, &time)) + return time & S64_MAX; + + return U64_MAX; } #endif |