History

timekeeping/vsyscall: Update VDSO data unconditionally

The update of the VDSO data is depending on __arch_use_vsyscall() returning True. This is a leftover from the attempt to map the features of various architectures 1:1 into generic code. The usage of __arch_use_vsyscall() in the actual vsyscall implementations got dropped and replaced by the requirement for the architecture code to return U64_MAX if the global clocksource is not usable in the VDSO. But the __arch_use_vsyscall() check in the update code stayed which causes the VDSO data to be stale or invalid when an architecture actually implements that function and returns False when the current clocksource is not usable in the VDSO. As a consequence the VDSO implementations of clock_getres(), time(), clock_gettime(CLOCK_.*_COARSE) operate on invalid data and return bogus information. Remove the __arch_use_vsyscall() check from the VDSO update function and update the VDSO data unconditionally. [ tglx: Massaged changelog and removed the now useless implementations in asm-generic/ARM64/MIPS ]

Huacai Chen committed 7 years ago

Commit 52338411 parent d7e8d144 files · +3 −27Browse files

Unified · Split

4 files
  1. arch/arm64/include/asm/vdso/vsyscall.h +0 −7
  2. arch/mips/include/asm/vdso/vsyscall.h +0 −7
  3. include/asm-generic/vdso/vsyscall.h +0 −7
  4. kernel/time/vsyscall.c +3 −6
arch/arm64/include/asm/vdso/vsyscall.h+0−7
@@ -30,13 +30,6 @@ int __arm64_get_clock_mode(struct timekeeper *tk) · 29 unmodified lines
30}30}
31#define __arch_get_clock_mode __arm64_get_clock_mode31#define __arch_get_clock_mode __arm64_get_clock_mode
32 32
33static __always_inline
34int __arm64_use_vsyscall(struct vdso_data *vdata)
35{
36 return !vdata[CS_HRES_COARSE].clock_mode;
37}
38#define __arch_use_vsyscall __arm64_use_vsyscall
39
40static __always_inline33static __always_inline
41void __arm64_update_vsyscall(struct vdso_data *vdata, struct timekeeper *tk)34void __arm64_update_vsyscall(struct vdso_data *vdata, struct timekeeper *tk)
42{35{
arch/mips/include/asm/vdso/vsyscall.h+0−7
@@ -28,13 +28,6 @@ int __mips_get_clock_mode(struct timekeeper *tk) · 27 unmodified lines
28}28}
29#define __arch_get_clock_mode __mips_get_clock_mode29#define __arch_get_clock_mode __mips_get_clock_mode
30 30
31static __always_inline
32int __mips_use_vsyscall(struct vdso_data *vdata)
33{
34 return (vdata[CS_HRES_COARSE].clock_mode != VDSO_CLOCK_NONE);
35}
36#define __arch_use_vsyscall __mips_use_vsyscall
37
38/* The asm-generic header needs to be included after the definitions above */31/* The asm-generic header needs to be included after the definitions above */
39#include <asm-generic/vdso/vsyscall.h>32#include <asm-generic/vdso/vsyscall.h>
40 33
include/asm-generic/vdso/vsyscall.h+0−7
@@ -25,13 +25,6 @@ static __always_inline int __arch_get_clock_mode(struct timekeeper *tk) · 24 unmodified lines
25}25}
26#endif /* __arch_get_clock_mode */26#endif /* __arch_get_clock_mode */
27 27
28#ifndef __arch_use_vsyscall
29static __always_inline int __arch_use_vsyscall(struct vdso_data *vdata)
30{
31 return 1;
32}
33#endif /* __arch_use_vsyscall */
34
35#ifndef __arch_update_vsyscall28#ifndef __arch_update_vsyscall
36static __always_inline void __arch_update_vsyscall(struct vdso_data *vdata,29static __always_inline void __arch_update_vsyscall(struct vdso_data *vdata,
37 struct timekeeper *tk)30 struct timekeeper *tk)
kernel/time/vsyscall.c+3−6
@@ -110,8 +110,7 @@ void update_vsyscall(struct timekeeper *tk) · 109 unmodified lines
110 nsec = nsec + tk->wall_to_monotonic.tv_nsec;110 nsec = nsec + tk->wall_to_monotonic.tv_nsec;
111 vdso_ts->sec += __iter_div_u64_rem(nsec, NSEC_PER_SEC, &vdso_ts->nsec);111 vdso_ts->sec += __iter_div_u64_rem(nsec, NSEC_PER_SEC, &vdso_ts->nsec);
112 112
113 if (__arch_use_vsyscall(vdata))113 update_vdso_data(vdata, tk);
114 update_vdso_data(vdata, tk);
115 114
116 __arch_update_vsyscall(vdata, tk);115 __arch_update_vsyscall(vdata, tk);
117 116
@@ -124,10 +123,8 @@ void update_vsyscall_tz(void) · 6 unmodified lines
124{123{
125 struct vdso_data *vdata = __arch_get_k_vdso_data();124 struct vdso_data *vdata = __arch_get_k_vdso_data();
126 125
127 if (__arch_use_vsyscall(vdata)) {126 vdata[CS_HRES_COARSE].tz_minuteswest = sys_tz.tz_minuteswest;
128 vdata[CS_HRES_COARSE].tz_minuteswest = sys_tz.tz_minuteswest;127 vdata[CS_HRES_COARSE].tz_dsttime = sys_tz.tz_dsttime;
129 vdata[CS_HRES_COARSE].tz_dsttime = sys_tz.tz_dsttime;
130 }
131 128
132 __arch_sync_vdso_data(vdata);129 __arch_sync_vdso_data(vdata);
133}130}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t