aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/lib/test-string_helpers.c
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2020-06-06 23:51:16 +0200
committerThomas Gleixner <tglx@linutronix.de>2020-06-09 16:36:48 +0200
commit72ce778007e57e8996b4bebdec738fc5e1145fd2 (patch)
tree78f343641375fbe0eb2ab6468d02ccd37813b8c4 /lib/test-string_helpers.c
parentclocksource: Remove obsolete ifdef (diff)
downloadwireguard-linux-72ce778007e57e8996b4bebdec738fc5e1145fd2.tar.xz
wireguard-linux-72ce778007e57e8996b4bebdec738fc5e1145fd2.zip
lib/vdso: Provide sanity check for cycles (again)
The original x86 VDSO implementation checked for the validity of the clock source read by testing whether the returned signed cycles value is less than zero. This check was also used by the vdso read function to signal that the current selected clocksource is not VDSO capable. During the rework of the VDSO code the check was removed and replaced with a check for the clocksource mode being != NONE. This turned out to be a mistake because the check is necessary for paravirt and hyperv clock sources. The reason is that these clock sources have their own internal sequence counter to validate the clocksource at the point of reading it. This is necessary because the hypervisor can invalidate the clocksource asynchronously so a check during the VDSO data update is not sufficient. Having a separate indicator for the validity is slower than just validating the cycles value. The check for it being negative turned out to be the fastest implementation and safe as it would require an uptime of ~73 years with a 4GHz counter frequency to result in a false positive. Add an optional function to validate the cycles with a default implementation which allows the compiler to optimize it out for architectures which do not require it. Fixes: 5d51bee725cc ("clocksource: Add common vdso clock mode storage") Reported-by: Miklos Szeredi <miklos@szeredi.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Miklos Szeredi <mszeredi@redhat.com> Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/20200606221531.963970768@linutronix.de
Diffstat (limited to 'lib/test-string_helpers.c')
0 files changed, 0 insertions, 0 deletions